<s> from __future__ import absolute_import <EOL> from sentry . testutils . cases import RuleTestCase <EOL> from sentry . rules . conditions . tagged_event import TaggedEventCondition , MatchType <EOL> class TaggedEventConditionTest ( RuleTestCase ) : <EOL> rule_cls = TaggedEventCondition <EOL> def get_event ( self ) : <EOL> event = self . event <EOL> event . data [ '<STR_LIT>' ] = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> return event <EOL> def test_equals ( self ) : <EOL> event = self . get_event ( ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . EQUAL , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertPasses ( rule , event ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . EQUAL , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertDoesNotPass ( rule , event ) <EOL> def test_does_not_equal ( self ) : <EOL> event = self . get_event ( ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . NOT_EQUAL , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertDoesNotPass ( rule , event ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . NOT_EQUAL , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertPasses ( rule , event ) <EOL> def test_starts_with ( self ) : <EOL> event = self . get_event ( ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . STARTS_WITH , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertPasses ( rule , event ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . STARTS_WITH , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertDoesNotPass ( rule , event ) <EOL> def test_ends_with ( self ) : <EOL> event = self . get_event ( ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . ENDS_WITH , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertPasses ( rule , event ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . ENDS_WITH , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertDoesNotPass ( rule , event ) <EOL> def test_contains ( self ) : <EOL> event = self . get_event ( ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . CONTAINS , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertPasses ( rule , event ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . CONTAINS , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertDoesNotPass ( rule , event ) <EOL> def test_does_not_contain ( self ) : <EOL> event = self . get_event ( ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . NOT_CONTAINS , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertDoesNotPass ( rule , event ) <EOL> rule = self . get_rule ( { <EOL> '<STR_LIT>' : MatchType . NOT_CONTAINS , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertPasses ( rule , event ) </s>
