Example #1
0
 def test_pop_back(self):
     ''' Must make the image with next smaller index active when the active is poped'''
     chain.insert_image_before( self.p_state )               # add before active
     self.assertEqual( system.get_index( self.p_state ), 1 ) # active is 1st
     chain.pop_back( self.p_state )                          # delete the last (active)
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
     self.assertEqual( chain.get_noi( self.p_state ), 1 )    # total 1 image
Example #2
0
 def test_jump(self):
     ''' Must change the active image to the one pointed by idx_image'''
     chain.insert_image_before( self.p_state )               # active is 1st
     chain.jump_to_image( self.p_state, idx_image=0 )        # jump to 0th
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
     chain.jump_to_image( self.p_state, idx_image=1 )        # jump to 1st
     self.assertEqual( system.get_index( self.p_state ), 1 ) # active is 1st
Example #3
0
 def test_replace_outoflimits(self):
     ''' Must leave current image unchanged if it tries to replace an non existing image'''
     chain.replace_image( self.p_state, idx_image=5 )        # replace 0th with 5th (not exist)
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
     self.assertEqual( chain.get_noi( self.p_state ), 1 )    # total 1 image
     chain.replace_image( self.p_state, idx_image=-5 )       # replace 0th with -5th (not exist)
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
     self.assertEqual( chain.get_noi( self.p_state ), 1 )    # total 1 image
Example #4
0
 def test_switching(self):
     ''' For Next in the back and Prev in the front active must remain unchanged'''
     chain.insert_image_before( self.p_state )               # add before active
     self.assertEqual( system.get_index( self.p_state ), 1 ) # active is 1st
     chain.next_image( self.p_state )                        # no next image
     self.assertEqual( system.get_index( self.p_state ), 1 ) # active is 1st
     chain.prev_image( self.p_state )                        # go to prev image
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
     chain.prev_image( self.p_state )                        # no prev image
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
Example #5
0
 def test_delete_outoflimits(self):
     
     chain.insert_image_before( self.p_state )               # active is 1st
     chain.insert_image_before( self.p_state )               # active is 2nd
     self.assertEqual( system.get_index( self.p_state ), 2 ) # active is 2nd
     self.assertEqual( chain.get_noi( self.p_state ), 3 )    # total 3 images
     
     # test the deletion of a non existing image with positive idx
     chain.delete_image( self.p_state, idx_image=5 )         # delete -5th (not exist)
     self.assertEqual( chain.get_noi( self.p_state ), 3 )    # total 3 images
     
     # test the deletion of a non existing image with negative idx
     chain.delete_image( self.p_state, idx_image=-5 )        # delete -5th (not exist)
     self.assertEqual( chain.get_noi( self.p_state ), 2 )    # total 2 images
     self.assertEqual( system.get_index( self.p_state ), 1 ) # active is 1st
Example #6
0
 def test_get_index(self):
     index = system.get_index(self.p_state)
     self.assertEqual(index, 0)
Example #7
0
 def test_trivial_switching(self):
     ''' Next or Prev image in image of length 1 should result to 0th active'''
     chain.next_image( self.p_state )                        # no next image
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
     chain.prev_image( self.p_state )                        # no prev image
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
Example #8
0
 def test_push_back(self):
     ''' Must add one image and leave active's index unchanged '''
     chain.push_back( self.p_state )                         # add after all
     self.assertEqual( chain.get_noi( self.p_state ), 2 )    # total 2 images
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
Example #9
0
 def test_insert_before(self):
     ''' Must reindex (increment by one) active image '''
     chain.insert_image_before( self.p_state )               # add before active
     self.assertEqual( chain.get_noi( self.p_state ), 2 )    # total 2 images
     self.assertEqual( system.get_index( self.p_state ), 1 ) # active is 1st
Example #10
0
 def test_insert_after(self):
     ''' Must leave the index of active image the same '''
     chain.insert_image_after( self.p_state )                # add after active
     self.assertEqual( chain.get_noi( self.p_state ), 2 )    # total 2 images
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
Example #11
0
 def test_active_image(self):
     ''' Must return the index of the active image '''
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
Example #12
0
 def test_remove_smallest_index_active(self):
     '''' Must set the active to the image with the smallest index left'''
     chain.insert_image_after( self.p_state )                # active is 0th
     chain.delete_image( self.p_state )                      # delete 0th
     self.assertEqual( chain.get_noi( self.p_state ), 1 )    # total 1 image
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
Example #13
0
 def test_replace_trivial(self):
     ''' Must leave active image same if replace by its self'''
     chain.replace_image( self.p_state, idx_image=0 )        # replace 0th with 0th
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
Example #14
0
 def test_jump_outoflimits(self):
     '''' Must leave current active image unchanged if jump is out of chain limits'''
     chain.jump_to_image( self.p_state, idx_image=5 )        # jump to non existing
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
     chain.jump_to_image( self.p_state, idx_image=-5 )       # jump to non existing (negative)
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th
Example #15
0
 def test_jump_trivial(self):
     ''' Must leave active image same if jump to the active'''
     chain.jump_to_image( self.p_state, idx_image=0 )        # jump to active itself
     self.assertEqual( system.get_index( self.p_state ), 0 ) # active is 0th (the same)