<s> from django . db . models import F , Q <EOL> from django . test import TransactionTestCase <EOL> from tests . common . support . models import TestModel <EOL> class PrimaryKeyQueriesTestCase ( TransactionTestCase ) : <EOL> def setUp ( self ) : <EOL> TestModel . objects . create ( id = <NUM_LIT:1> ) <EOL> TestModel . objects . create ( id = <NUM_LIT:2> ) <EOL> TestModel . objects . create ( id = <NUM_LIT:3> ) <EOL> TestModel . objects . create ( id = <NUM_LIT:4> ) <EOL> def test_can_fetch_a_record_equal_to_1 ( self ) : <EOL> expected = TestModel . objects . get ( pk = <NUM_LIT:1> ) <EOL> actual = TestModel . objects . get ( TestModel . pk == <NUM_LIT:1> ) <EOL> self . assertEqual ( actual , expected ) <EOL> def test_pk_is_1_when_fetching_a_record_with_pk_that_is_equal_to_1 ( self ) : <EOL> expected = <NUM_LIT:1> <EOL> actual = TestModel . objects . get ( TestModel . pk == <NUM_LIT:1> ) . pk <EOL> self . assertEqual ( actual , expected ) <EOL> def test_can_fetch_records_greater_than_1 ( self ) : <EOL> expected = TestModel . objects . filter ( pk__gt = <NUM_LIT:1> ) <EOL> actual = TestModel . objects . filter ( TestModel . pk > <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( actual ) , list ( expected ) ) <EOL> def test_can_fetch_records_lower_than_2 ( self ) : <EOL> expected = TestModel . objects . filter ( pk__lt = <NUM_LIT:2> ) <EOL> actual = TestModel . objects . filter ( TestModel . pk < <NUM_LIT:2> ) <EOL> self . assertEqual ( list ( actual ) , list ( expected ) ) <EOL> def test_can_fetch_records_greater_or_equal_to_bar_plus_one ( self ) : <EOL> expected = TestModel . objects . filter ( pk__gte = F ( '<STR_LIT:bar>' ) + <NUM_LIT:1> ) <EOL> actual = TestModel . objects . filter ( TestModel . pk >= TestModel . bar + <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( actual ) , list ( expected ) ) <EOL> def test_can_fetch_records_with_pk_greater_than_one_and_bar_equal_to_one ( self ) : <EOL> expected = TestModel . objects . filter ( pk__gt = <NUM_LIT:1> , bar = <NUM_LIT:1> ) <EOL> actual = TestModel . objects . filter ( ( TestModel . pk > <NUM_LIT:1> ) & ( TestModel . bar == <NUM_LIT:1> ) ) <EOL> self . assertEqual ( list ( actual ) , list ( expected ) ) <EOL> def test_can_fetch_records_with_pk_greater_than_one_or_bar_equal_to_one ( self ) : <EOL> expected = TestModel . objects . filter ( Q ( pk__gt = <NUM_LIT:1> ) | Q ( bar = <NUM_LIT:1> ) ) <EOL> actual = TestModel . objects . filter ( ( TestModel . pk > <NUM_LIT:1> ) | ( TestModel . bar == <NUM_LIT:1> ) ) <EOL> self . assertEqual ( list ( actual ) , list ( expected ) ) </s>
