<s> """<STR_LIT>""" <EOL> from django . test import TestCase <EOL> from django . db . models import DO_NOTHING <EOL> from salesforce import fields , models <EOL> from salesforce . testrunner . example . models import ( Contact , Opportunity , <EOL> OpportunityContactRole , ChargentOrder ) <EOL> from salesforce . backend . subselect import TestSubSelectSearch <EOL> import salesforce <EOL> class EasyCharField ( models . CharField ) : <EOL> def __init__ ( self , max_length = <NUM_LIT:255> , null = True , default = '<STR_LIT>' , ** kwargs ) : <EOL> return super ( EasyCharField , self ) . __init__ ( max_length = max_length , null = null , default = default , ** kwargs ) <EOL> class EasyForeignKey ( models . ForeignKey ) : <EOL> def __init__ ( self , othermodel , on_delete = DO_NOTHING , ** kwargs ) : <EOL> return super ( EasyForeignKey , self ) . __init__ ( othermodel , on_delete = on_delete , ** kwargs ) <EOL> class TestField ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_primary_key ( self ) : <EOL> """<STR_LIT>""" <EOL> class Ab ( models . SalesforceModel ) : <EOL> pass <EOL> self . assertTrue ( isinstance ( fields . SF_PK , str ) ) <EOL> self . assertTrue ( hasattr ( Ab ( ) , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( Ab ( ) , fields . SF_PK ) ) <EOL> def test_auto_db_column ( self ) : <EOL> """<STR_LIT>""" <EOL> class Aa ( models . SalesforceModel ) : <EOL> pass <EOL> class Dest ( models . SalesforceModel ) : <EOL> pass <EOL> def test ( field , expect_attname , expect_column ) : <EOL> "<STR_LIT>" <EOL> field . contribute_to_class ( Dest , field . name ) <EOL> self . assertEqual ( field . get_attname_column ( ) , ( expect_attname , expect_column ) ) <EOL> test ( EasyCharField ( name = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyCharField ( name = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyCharField ( name = '<STR_LIT>' , custom = True ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyCharField ( name = '<STR_LIT>' , custom = True , db_column = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyCharField ( name = '<STR_LIT>' , custom = True ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyCharField ( name = '<STR_LIT>' , custom = True ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyForeignKey ( Aa , name = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyForeignKey ( Aa , name = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyForeignKey ( Aa , name = '<STR_LIT>' , db_column = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyForeignKey ( Aa , name = '<STR_LIT>' , db_column = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyForeignKey ( Aa , name = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyForeignKey ( Aa , name = '<STR_LIT>' ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyForeignKey ( Aa , name = '<STR_LIT>' , custom = True ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> test ( EasyForeignKey ( Aa , name = '<STR_LIT>' , custom = True ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class TestQueryCompiler ( TestCase ) : <EOL> def test_namespaces_auto ( self ) : <EOL> """<STR_LIT>""" <EOL> tested_field = ChargentOrder . _meta . get_field ( '<STR_LIT>' ) <EOL> self . assertEqual ( tested_field . sf_custom , True ) <EOL> self . assertEqual ( tested_field . column , '<STR_LIT>' ) <EOL> def test_subquery_condition ( self ) : <EOL> """<STR_LIT>""" <EOL> qs = OpportunityContactRole . objects . filter ( role = '<STR_LIT:abc>' , <EOL> opportunity__in = Opportunity . objects . filter ( stage = '<STR_LIT>' ) ) <EOL> sql , params = qs . query . get_compiler ( '<STR_LIT>' ) . as_sql ( ) <EOL> self . assertRegexpMatches ( sql , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> self . assertRegexpMatches ( sql , '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertRegexpMatches ( sql , '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertRegexpMatches ( sql , '<STR_LIT>' ) <EOL> def test_none_method_queryset ( self ) : <EOL> """<STR_LIT>""" <EOL> request_count_0 = salesforce . backend . query . request_count <EOL> self . assertEqual ( tuple ( Contact . objects . none ( ) ) , ( ) ) <EOL> self . assertEqual ( tuple ( Contact . objects . all ( ) . none ( ) . all ( ) ) , ( ) ) <EOL> self . assertTrue ( '<STR_LIT>' in repr ( Contact . objects . none ( ) ) ) <EOL> self . assertEqual ( salesforce . backend . query . request_count , request_count_0 , <EOL> "<STR_LIT>" ) <EOL> class TestTopologyCompiler ( TestCase ) : <EOL> def assertTopo ( self , alias_map_items , expected ) : <EOL> compiler = Contact . objects . none ( ) . query . get_compiler ( '<STR_LIT>' ) <EOL> ret = compiler . query_topology ( alias_map_items ) <EOL> self . assertEqual ( ret , expected ) <EOL> def test_topology_compiler ( self ) : <EOL> self . assertTopo ( [ ( None , '<STR_LIT>' , None , '<STR_LIT>' ) ] , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertTopo ( [ ( None , '<STR_LIT>' , None , '<STR_LIT>' ) ] , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertTopo ( [ ( None , '<STR_LIT:C>' , None , '<STR_LIT:C>' ) , ( '<STR_LIT:C>' , '<STR_LIT:P>' , ( ( '<STR_LIT>' , '<STR_LIT>' ) , ) , '<STR_LIT:P>' ) ] , { '<STR_LIT:C>' : '<STR_LIT:C>' , '<STR_LIT:P>' : '<STR_LIT>' } ) <EOL> def test_normal2custom ( self ) : <EOL> self . assertTopo ( [ ( '<STR_LIT:C>' , '<STR_LIT>' , ( ( '<STR_LIT>' , '<STR_LIT>' ) , ) , '<STR_LIT>' ) , ( None , '<STR_LIT:C>' , ( ( None , None ) , ) , '<STR_LIT:C>' ) ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:C>' : '<STR_LIT:C>' } ) <EOL> def test_custom2normal ( self ) : <EOL> self . assertTopo ( [ ( None , '<STR_LIT>' , None , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT:P>' , ( ( '<STR_LIT>' , '<STR_LIT>' ) , ) , '<STR_LIT:P>' ) ] , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:P>' : '<STR_LIT>' } ) <EOL> def test_many2many ( self ) : <EOL> alias_map_items = [ <EOL> ( None , '<STR_LIT:A>' , None , '<STR_LIT:A>' ) , <EOL> ( '<STR_LIT:A>' , '<STR_LIT:C>' , ( ( '<STR_LIT>' , '<STR_LIT>' ) , ) , '<STR_LIT:C>' ) , <EOL> ( '<STR_LIT:C>' , '<STR_LIT:B>' , ( ( '<STR_LIT>' , '<STR_LIT>' ) , ) , '<STR_LIT:B>' ) ] <EOL> self . assertTopo ( alias_map_items , { '<STR_LIT:C>' : '<STR_LIT:C>' , '<STR_LIT:A>' : '<STR_LIT>' , '<STR_LIT:B>' : '<STR_LIT>' } ) </s>
