<s> import mock <EOL> from cloudferry . lib . scheduler import cursor <EOL> from tests import test <EOL> class CursorTestCase ( test . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( CursorTestCase , self ) . setUp ( ) <EOL> self . elements = [ <EOL> mock . Mock ( next_element = [ None ] , prev_element = None , parall_elem = [ ] , <EOL> num_element = cursor . DEFAULT ) for _ in range ( <NUM_LIT:7> ) ] <EOL> self . elements [ <NUM_LIT:0> ] . next_element = [ self . elements [ <NUM_LIT:1> ] ] <EOL> self . elements [ <NUM_LIT:1> ] . prev_element = self . elements [ <NUM_LIT:0> ] <EOL> self . elements [ <NUM_LIT:1> ] . next_element = [ self . elements [ <NUM_LIT:4> ] , self . elements [ <NUM_LIT:2> ] , <EOL> self . elements [ <NUM_LIT:3> ] ] <EOL> self . elements [ <NUM_LIT:2> ] . prev_element = self . elements [ <NUM_LIT:1> ] <EOL> self . elements [ <NUM_LIT:3> ] . prev_element = self . elements [ <NUM_LIT:1> ] <EOL> self . elements [ <NUM_LIT:2> ] . next_element = [ self . elements [ <NUM_LIT:4> ] ] <EOL> self . elements [ <NUM_LIT:3> ] . next_element = [ self . elements [ <NUM_LIT:4> ] ] <EOL> self . elements [ <NUM_LIT:4> ] . prev_element = self . elements [ <NUM_LIT:1> ] <EOL> self . elements [ <NUM_LIT:4> ] . next_element = [ self . elements [ <NUM_LIT:5> ] ] <EOL> self . elements [ <NUM_LIT:4> ] . parall_elem = [ self . elements [ <NUM_LIT:6> ] ] <EOL> self . elements [ <NUM_LIT:5> ] . prev_element = self . elements [ <NUM_LIT:4> ] <EOL> def test_cursor ( self ) : <EOL> cur = cursor . Cursor ( self . elements [ <NUM_LIT:5> ] ) <EOL> self . assertEqual ( cur . current ( ) , self . elements [ <NUM_LIT:0> ] ) <EOL> def test_iterating_first_case_cursor ( self ) : <EOL> cur = cursor . Cursor ( self . elements [ <NUM_LIT:0> ] ) <EOL> expected_result = [ self . elements [ <NUM_LIT:0> ] , self . elements [ <NUM_LIT:1> ] , <EOL> self . elements [ <NUM_LIT:4> ] , self . elements [ <NUM_LIT:6> ] , <EOL> self . elements [ <NUM_LIT:5> ] ] <EOL> expected_result . reverse ( ) <EOL> for c in cur : <EOL> self . assertEqual ( expected_result . pop ( ) , c ) <EOL> def test_iterating_second_case_cursor ( self ) : <EOL> self . elements [ <NUM_LIT:1> ] . num_element = <NUM_LIT:1> <EOL> cur = cursor . Cursor ( self . elements [ <NUM_LIT:0> ] ) <EOL> expected_result = [ self . elements [ <NUM_LIT:0> ] , self . elements [ <NUM_LIT:1> ] , <EOL> self . elements [ <NUM_LIT:2> ] , self . elements [ <NUM_LIT:4> ] , <EOL> self . elements [ <NUM_LIT:6> ] , <EOL> self . elements [ <NUM_LIT:5> ] ] <EOL> expected_result . reverse ( ) <EOL> for c in cur : <EOL> self . assertEqual ( expected_result . pop ( ) , c ) <EOL> def test_iterating_third_case_cursor ( self ) : <EOL> self . elements [ <NUM_LIT:1> ] . num_element = <NUM_LIT:2> <EOL> cur = cursor . Cursor ( self . elements [ <NUM_LIT:0> ] ) <EOL> expected_result = [ self . elements [ <NUM_LIT:0> ] , self . elements [ <NUM_LIT:1> ] , <EOL> self . elements [ <NUM_LIT:3> ] , self . elements [ <NUM_LIT:4> ] , <EOL> self . elements [ <NUM_LIT:6> ] , <EOL> self . elements [ <NUM_LIT:5> ] ] <EOL> expected_result . reverse ( ) <EOL> for c in cur : <EOL> self . assertEqual ( expected_result . pop ( ) , c ) <EOL> def test_iterating_fourth_case_cursor ( self ) : <EOL> self . elements [ <NUM_LIT:1> ] . num_element = <NUM_LIT:3> <EOL> cur = cursor . Cursor ( self . elements [ <NUM_LIT:0> ] ) <EOL> expected_result = [ self . elements [ <NUM_LIT:0> ] , self . elements [ <NUM_LIT:1> ] , <EOL> self . elements [ <NUM_LIT:4> ] , self . elements [ <NUM_LIT:6> ] , <EOL> self . elements [ <NUM_LIT:5> ] ] <EOL> expected_result . reverse ( ) <EOL> for c in cur : <EOL> self . assertEqual ( expected_result . pop ( ) , c ) </s>
