<s> from django . test import TestCase <EOL> from django . utils import timezone <EOL> from django . core . urlresolvers import reverse <EOL> import aristotle_mdr . models as models <EOL> import aristotle_mdr . tests . utils as utils <EOL> from django . test . utils import setup_test_environment <EOL> setup_test_environment ( ) <EOL> class SupersededProperty ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . wg = models . Workgroup . objects . create ( name = "<STR_LIT>" ) <EOL> self . item1 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg ) <EOL> self . item2 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg ) <EOL> self . ra = models . RegistrationAuthority . objects . create ( name = "<STR_LIT>" ) <EOL> def test_is_supersede_property ( self ) : <EOL> self . assertFalse ( self . item1 . is_superseded ) <EOL> self . item1 . superseded_by = self . item2 <EOL> self . item1 . save ( ) <EOL> self . assertTrue ( self . item1 . is_superseded ) <EOL> s = models . Status . objects . create ( <EOL> concept = self . item1 , <EOL> registrationAuthority = self . ra , <EOL> registrationDate = timezone . now ( ) , <EOL> state = self . ra . public_state <EOL> ) <EOL> self . assertFalse ( self . item1 . is_superseded ) <EOL> s . state = models . STATES . superseded <EOL> s . save ( ) <EOL> self . assertTrue ( self . item1 . is_superseded ) <EOL> class SupersedePage ( utils . LoggedInViewPages , TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( SupersedePage , self ) . setUp ( ) <EOL> self . item1 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> self . item2 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> self . item3 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg2 ) <EOL> self . item4 = models . Property . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> def test_supersede ( self ) : <EOL> self . logout ( ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) ) <EOL> self . assertRedirects ( <EOL> response , <EOL> reverse ( "<STR_LIT>" ) + "<STR_LIT>" + reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) <EOL> ) <EOL> self . login_editor ( ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( self . item1 . superseded_by , None ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : self . item1 . id } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( models . ObjectClass . objects . get ( id = self . item1 . id ) . superseded_by , None ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : self . item2 . id } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertEqual ( models . ObjectClass . objects . get ( id = self . item1 . id ) . superseded_by , self . item2 ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : self . item3 . id } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( models . ObjectClass . objects . get ( id = self . item1 . id ) . superseded_by , self . item2 ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : self . item4 . id } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertEqual ( models . ObjectClass . objects . get ( id = self . item1 . id ) . superseded_by , self . item2 ) <EOL> class DeprecatePage ( utils . LoggedInViewPages , TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( DeprecatePage , self ) . setUp ( ) <EOL> self . item1 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> self . item2 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> self . item3 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> self . item4 = models . Property . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> self . item1 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> self . item2 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> self . item3 = models . ObjectClass . objects . create ( name = "<STR_LIT>" , workgroup = self . wg2 ) <EOL> self . item4 = models . Property . objects . create ( name = "<STR_LIT>" , workgroup = self . wg1 ) <EOL> def test_deprecate ( self ) : <EOL> self . logout ( ) <EOL> response = self . client . get ( reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) ) <EOL> self . assertRedirects ( <EOL> response , <EOL> reverse ( "<STR_LIT>" ) + "<STR_LIT>" + <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) <EOL> ) <EOL> self . login_editor ( ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertListEqual ( list ( self . item1 . supersedes . all ( ) ) , [ ] ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : [ self . item1 . id ] } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertListEqual ( list ( self . item1 . supersedes . all ( ) ) , [ ] ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : [ self . item2 . id , self . item3 . id ] } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertListEqual ( list ( self . item1 . supersedes . all ( ) ) , [ ] ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : [ self . item2 . id ] } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertListEqual ( list ( self . item1 . supersedes . all ( ) ) , [ self . item2 ] ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : [ self . item3 . id ] } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertListEqual ( list ( self . item1 . supersedes . all ( ) ) , [ self . item2 ] ) <EOL> response = self . client . post ( <EOL> reverse ( '<STR_LIT>' , args = [ self . item1 . id ] ) , <EOL> { '<STR_LIT>' : [ self . item4 . id ] } <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertListEqual ( list ( self . item1 . supersedes . all ( ) ) , [ self . item2 ] ) </s>
