<s> from django . contrib . auth . models import User <EOL> from django . test import TestCase <EOL> from django . db . models import Q <EOL> from django . template . defaultfilters import slugify <EOL> from projector . models import Project , Transition , Status <EOL> class ProjectorStatusTransition ( TestCase ) : <EOL> def setUp ( self ) : <EOL> name = u'<STR_LIT>' <EOL> self . admin = User . objects . create_superuser ( <EOL> username = name , <EOL> email = '<STR_LIT>' , <EOL> password = '<STR_LIT>' , <EOL> ) <EOL> self . project = Project . objects . create_project ( <EOL> name = name , <EOL> slug = slugify ( name ) , <EOL> author = self . admin , <EOL> ) <EOL> Status . objects . create ( name = '<STR_LIT>' , project = self . project , order = <NUM_LIT:2> ) <EOL> Status . objects . create ( name = '<STR_LIT>' , project = self . project , order = <NUM_LIT:3> ) <EOL> Transition . objects . filter ( <EOL> Q ( source__project = self . project ) | <EOL> Q ( destination__project = self . project ) ) . delete ( ) <EOL> def test_notransitions ( self ) : <EOL> statuses = self . project . status_set . all ( ) <EOL> for src in statuses : <EOL> for dst in statuses : <EOL> self . assertFalse ( src . can_change_to ( dst ) ) <EOL> def test_transition ( self ) : <EOL> s1 , s2 = self . project . status_set . all ( ) [ : <NUM_LIT:2> ] <EOL> Transition . objects . create ( source = s1 , destination = s2 ) <EOL> self . assertTrue ( s1 . can_change_to ( s2 ) ) <EOL> self . assertFalse ( s2 . can_change_to ( s1 ) ) <EOL> Transition . objects . create ( source = s2 , destination = s1 ) <EOL> self . assertTrue ( s1 . can_change_to ( s2 ) ) <EOL> self . assertTrue ( s2 . can_change_to ( s1 ) ) </s>
