<s> from django . test import TestCase <EOL> from django . db import connection <EOL> from models import Unmanaged1 , Unmanaged2 , Managed1 <EOL> from models import A01 , A02 , B01 , B02 , C01 , C02 <EOL> class SimpleTests ( TestCase ) : <EOL> def test_simple ( self ) : <EOL> """<STR_LIT>""" <EOL> a = A01 . objects . create ( f_a = "<STR_LIT:foo>" , f_b = <NUM_LIT> ) <EOL> B01 . objects . create ( fk_a = a , f_a = "<STR_LIT>" , f_b = <NUM_LIT> ) <EOL> c = C01 . objects . create ( f_a = "<STR_LIT>" , f_b = <NUM_LIT:1> ) <EOL> c . mm_a = [ a ] <EOL> a2 = A02 . objects . all ( ) [ <NUM_LIT:0> ] <EOL> self . assertTrue ( isinstance ( a2 , A02 ) ) <EOL> self . assertEqual ( a2 . f_a , "<STR_LIT:foo>" ) <EOL> b2 = B02 . objects . all ( ) [ <NUM_LIT:0> ] <EOL> self . assertTrue ( isinstance ( b2 , B02 ) ) <EOL> self . assertEqual ( b2 . f_a , "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( b2 . fk_a , A02 ) ) <EOL> self . assertEqual ( b2 . fk_a . f_a , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( list ( C02 . objects . filter ( f_a = None ) ) , [ ] ) <EOL> resp = list ( C02 . objects . filter ( mm_a = a . id ) ) <EOL> self . assertEqual ( len ( resp ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( isinstance ( resp [ <NUM_LIT:0> ] , C02 ) ) <EOL> self . assertEqual ( resp [ <NUM_LIT:0> ] . f_a , '<STR_LIT>' ) <EOL> class ManyToManyUnmanagedTests ( TestCase ) : <EOL> def test_many_to_many_between_unmanaged ( self ) : <EOL> """<STR_LIT>""" <EOL> table = Unmanaged2 . _meta . get_field ( '<STR_LIT>' ) . m2m_db_table ( ) <EOL> tables = connection . introspection . table_names ( ) <EOL> self . assert_ ( table not in tables , "<STR_LIT>" % table ) <EOL> def test_many_to_many_between_unmanaged_and_managed ( self ) : <EOL> """<STR_LIT>""" <EOL> table = Managed1 . _meta . get_field ( '<STR_LIT>' ) . m2m_db_table ( ) <EOL> tables = connection . introspection . table_names ( ) <EOL> self . assert_ ( table in tables , "<STR_LIT>" % table ) </s>
