<s> from __future__ import unicode_literals <EOL> from django . test import TestCase <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . core . exceptions import ValidationError <EOL> from djangobmf . workflow import State <EOL> from djangobmf . workflow import Transition <EOL> from djangobmf . workflow import Workflow <EOL> from django . contrib . auth . models import User <EOL> class ClassTests ( TestCase ) : <EOL> def test_state ( self ) : <EOL> obj = State ( b'<STR_LIT:name>' ) <EOL> self . assertEqual ( obj . name , b"<STR_LIT:name>" ) <EOL> self . assertEqual ( str ( obj ) , "<STR_LIT:name>" ) <EOL> self . assertEqual ( repr ( obj ) , "<STR_LIT>" ) <EOL> def test_transition ( self ) : <EOL> obj = Transition ( b'<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT:to>' ) <EOL> self . assertEqual ( obj . name , b"<STR_LIT:name>" ) <EOL> self . assertEqual ( str ( obj ) , "<STR_LIT:name>" ) <EOL> self . assertEqual ( repr ( obj ) , "<STR_LIT>" ) <EOL> self . assertEqual ( obj . sources , [ "<STR_LIT>" , ] ) <EOL> obj = Transition ( '<STR_LIT:name>' , object , '<STR_LIT:to>' ) <EOL> self . assertEqual ( obj . sources , [ object , ] ) <EOL> obj = Transition ( '<STR_LIT:name>' , [ '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT:to>' ) <EOL> self . assertEqual ( obj . sources , [ "<STR_LIT>" , "<STR_LIT>" , ] ) <EOL> self . assertEqual ( obj . affected_states ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:to>" ] ) <EOL> def test_validation ( self ) : <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class Transitions : <EOL> pass <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> pass <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> pass <EOL> class Transitions : <EOL> pass <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> test = State ( '<STR_LIT>' , default = False ) <EOL> class Transitions : <EOL> pass <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> test1 = State ( '<STR_LIT>' , default = True ) <EOL> test2 = State ( '<STR_LIT>' , default = True ) <EOL> class Transitions : <EOL> pass <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> test1 = State ( '<STR_LIT>' , default = True ) <EOL> test2 = State ( '<STR_LIT>' ) <EOL> class Transitions : <EOL> trans1 = Transition ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> test1 = State ( '<STR_LIT>' , default = True ) <EOL> test2 = State ( '<STR_LIT>' ) <EOL> class Transitions : <EOL> instance = Transition ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> test1 = State ( '<STR_LIT>' , default = True ) <EOL> test2 = State ( '<STR_LIT>' ) <EOL> class Transitions : <EOL> _test = Transition ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ImproperlyConfigured , msg = msg ) : <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> test1 = State ( '<STR_LIT>' , default = True ) <EOL> test2 = State ( '<STR_LIT>' ) <EOL> class Transitions : <EOL> user = Transition ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_api ( self ) : <EOL> user = User ( ) <EOL> user . save ( ) <EOL> class TestWF ( Workflow ) : <EOL> class States : <EOL> test1 = State ( '<STR_LIT>' , default = True ) <EOL> test2 = State ( '<STR_LIT>' ) <EOL> test3 = State ( '<STR_LIT>' ) <EOL> test4 = State ( '<STR_LIT>' ) <EOL> test5 = State ( '<STR_LIT>' ) <EOL> class Transitions : <EOL> trans1 = Transition ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> trans2 = Transition ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> trans3 = Transition ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> trans4 = Transition ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def trans2 ( self ) : <EOL> return '<STR_LIT>' <EOL> def trans3 ( self ) : <EOL> return self . trans2 ( ) <EOL> WF = TestWF ( ) <EOL> self . assertTrue ( hasattr ( WF , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> WF . _set_state ( '<STR_LIT>' ) <EOL> self . assertEqual ( str ( WF ) , "<STR_LIT>" ) <EOL> self . assertEqual ( WF . _from_here ( ) , [ ( '<STR_LIT>' , WF . _transitions [ '<STR_LIT>' ] ) , ( '<STR_LIT>' , WF . _transitions [ '<STR_LIT>' ] ) ] ) <EOL> msg = "<STR_LIT>" <EOL> with self . assertRaises ( ValidationError , msg = msg ) : <EOL> WF . _call ( '<STR_LIT>' , None , user ) <EOL> self . assertEqual ( WF . _call ( '<STR_LIT>' , None , user ) , "<STR_LIT>" ) <EOL> self . assertEqual ( WF . _call ( '<STR_LIT>' , None , user ) , "<STR_LIT>" ) <EOL> self . assertEqual ( WF . _call ( '<STR_LIT>' , None , user ) , None ) <EOL> '''<STR_LIT>''' </s>
