<s> from __future__ import unicode_literals <EOL> import unittest <EOL> from ... events import Event <EOL> from . . import rules <EOL> from . . import classifier <EOL> class TestClassifier ( unittest . TestCase ) : <EOL> def test_inc ( self ) : <EOL> c = classifier . Classifier ( ) <EOL> c . inc ( rules . Match ( "<STR_LIT:a>" , "<STR_LIT:b>" ) , "<STR_LIT:X>" ) <EOL> self . assertEqual ( [ "<STR_LIT:X>" ] , sorted ( c . classify ( Event ( a = "<STR_LIT:b>" ) ) ) ) <EOL> self . assertFalse ( c . is_empty ( ) ) <EOL> c . inc ( rules . Or ( rules . Match ( "<STR_LIT:a>" , "<STR_LIT:b>" ) , rules . Match ( "<STR_LIT:a>" , "<STR_LIT:c>" ) ) , "<STR_LIT:Y>" ) <EOL> self . assertEqual ( [ "<STR_LIT:X>" , "<STR_LIT:Y>" ] , sorted ( c . classify ( Event ( a = "<STR_LIT:b>" ) ) ) ) <EOL> self . assertEqual ( [ "<STR_LIT:Y>" ] , sorted ( c . classify ( Event ( a = "<STR_LIT:c>" ) ) ) ) <EOL> self . assertFalse ( c . is_empty ( ) ) <EOL> def test_dec ( self ) : <EOL> c = classifier . Classifier ( ) <EOL> c . inc ( rules . Match ( "<STR_LIT:a>" , "<STR_LIT:b>" ) , "<STR_LIT:X>" ) <EOL> c . inc ( rules . Match ( "<STR_LIT:a>" , "<STR_LIT:b>" ) , "<STR_LIT:Y>" ) <EOL> c . dec ( rules . Match ( "<STR_LIT:a>" , "<STR_LIT:b>" ) , "<STR_LIT:X>" ) <EOL> self . assertEqual ( [ "<STR_LIT:Y>" ] , sorted ( c . classify ( Event ( a = "<STR_LIT:b>" ) ) ) ) <EOL> self . assertFalse ( c . is_empty ( ) ) <EOL> c . dec ( rules . Match ( "<STR_LIT:a>" , "<STR_LIT:b>" ) , "<STR_LIT:Y>" ) <EOL> self . assertEqual ( [ ] , sorted ( c . classify ( Event ( a = "<STR_LIT:b>" ) ) ) ) <EOL> self . assertTrue ( c . is_empty ( ) ) </s>
