<s> from hvad . test_utils . testcase import HvadTestCase <EOL> from hvad . test_utils . project . app . models import ConcreteAB , ConcreteABProxy <EOL> from hvad . test_utils . fixtures import ConcreteABFixture <EOL> from hvad . test_utils . data import NORMAL , CONCRETEAB <EOL> from django . utils import translation <EOL> class AbstractTests ( HvadTestCase , ConcreteABFixture ) : <EOL> normal_count = <NUM_LIT:2> <EOL> concreteab_count = <NUM_LIT:2> <EOL> def test_filter_and_iter ( self ) : <EOL> with translation . override ( '<STR_LIT>' ) : <EOL> with self . assertNumQueries ( <NUM_LIT:1> ) : <EOL> qs = ( ConcreteAB . objects . language ( ) <EOL> . filter ( shared_field_a__startswith = '<STR_LIT>' ) <EOL> . order_by ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( len ( qs ) , <NUM_LIT:2> ) <EOL> with self . assertNumQueries ( <NUM_LIT:0> ) : <EOL> self . assertEqual ( [ obj . shared_field_b_id for obj in qs ] , <EOL> [ self . normal_id [ CONCRETEAB [ <NUM_LIT:1> ] . shared_field_b ] , <EOL> self . normal_id [ CONCRETEAB [ <NUM_LIT:2> ] . shared_field_b ] ] ) <EOL> self . assertEqual ( [ obj . shared_field_ab for obj in qs ] , <EOL> [ CONCRETEAB [ <NUM_LIT:1> ] . shared_field_ab , <EOL> CONCRETEAB [ <NUM_LIT:2> ] . shared_field_ab ] ) <EOL> self . assertEqual ( [ obj . translated_field_b for obj in qs ] , <EOL> [ CONCRETEAB [ <NUM_LIT:1> ] . translated_field_b [ '<STR_LIT>' ] , <EOL> CONCRETEAB [ <NUM_LIT:2> ] . translated_field_b [ '<STR_LIT>' ] ] ) <EOL> self . assertEqual ( [ obj . translated_field_ab for obj in qs ] , <EOL> [ CONCRETEAB [ <NUM_LIT:1> ] . translated_field_ab [ '<STR_LIT>' ] , <EOL> CONCRETEAB [ <NUM_LIT:2> ] . translated_field_ab [ '<STR_LIT>' ] ] ) <EOL> with self . assertNumQueries ( <NUM_LIT:2> ) : <EOL> self . assertEqual ( [ obj . translated_field_a . pk for obj in qs ] , <EOL> [ self . normal_id [ CONCRETEAB [ <NUM_LIT:1> ] . translated_field_a [ '<STR_LIT>' ] ] , <EOL> self . normal_id [ CONCRETEAB [ <NUM_LIT:2> ] . translated_field_a [ '<STR_LIT>' ] ] ] ) <EOL> qs = qs . all ( ) <EOL> with translation . override ( '<STR_LIT>' ) : <EOL> with self . assertNumQueries ( <NUM_LIT:1> ) : <EOL> self . assertEqual ( len ( qs ) , <NUM_LIT:2> ) <EOL> with self . assertNumQueries ( <NUM_LIT:0> ) : <EOL> self . assertEqual ( [ obj . translated_field_b for obj in qs ] , <EOL> [ CONCRETEAB [ <NUM_LIT:1> ] . translated_field_b [ '<STR_LIT>' ] , <EOL> CONCRETEAB [ <NUM_LIT:2> ] . translated_field_b [ '<STR_LIT>' ] ] ) <EOL> self . assertEqual ( [ obj . translated_field_ab for obj in qs ] , <EOL> [ CONCRETEAB [ <NUM_LIT:1> ] . translated_field_ab [ '<STR_LIT>' ] , <EOL> CONCRETEAB [ <NUM_LIT:2> ] . translated_field_ab [ '<STR_LIT>' ] ] ) <EOL> with self . assertNumQueries ( <NUM_LIT:2> ) : <EOL> self . assertEqual ( [ obj . translated_field_a . pk for obj in qs ] , <EOL> [ self . normal_id [ CONCRETEAB [ <NUM_LIT:1> ] . translated_field_a [ '<STR_LIT>' ] ] , <EOL> self . normal_id [ CONCRETEAB [ <NUM_LIT:2> ] . translated_field_a [ '<STR_LIT>' ] ] ] ) <EOL> def test_select_related ( self ) : <EOL> with translation . override ( '<STR_LIT>' ) : <EOL> qs = ( ConcreteAB . objects . language ( ) <EOL> . select_related ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> . filter ( shared_field_ab = CONCRETEAB [ <NUM_LIT:2> ] . shared_field_ab ) ) <EOL> with self . assertNumQueries ( <NUM_LIT:1> ) : <EOL> self . assertEqual ( qs . count ( ) , <NUM_LIT:1> ) <EOL> with self . assertNumQueries ( <NUM_LIT:1> ) : <EOL> self . assertEqual ( len ( qs ) , <NUM_LIT:1> ) <EOL> obj = qs [ <NUM_LIT:0> ] <EOL> with self . assertNumQueries ( <NUM_LIT:0> ) : <EOL> self . assertEqual ( obj . shared_field_b . translated_field , <EOL> NORMAL [ CONCRETEAB [ <NUM_LIT:2> ] . shared_field_b ] . translated_field [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( obj . translated_field_a . translated_field , <EOL> NORMAL [ CONCRETEAB [ <NUM_LIT:2> ] . translated_field_a [ '<STR_LIT>' ] ] . translated_field [ '<STR_LIT>' ] ) <EOL> def test_proxy ( self ) : <EOL> obj = ( ConcreteABProxy . objects . language ( '<STR_LIT>' ) <EOL> . get ( shared_field_a = CONCRETEAB [ <NUM_LIT:1> ] . shared_field_a ) ) <EOL> self . assertTrue ( isinstance ( obj , ConcreteABProxy ) ) <EOL> self . assertTrue ( str ( obj ) . startswith ( '<STR_LIT>' ) ) </s>
