<s> from django . test import TestCase <EOL> from core . registration . static . models import StaticReg <EOL> from systems . tests . utils import create_fake_host <EOL> from mozdns . domain . models import Domain <EOL> from mozdns . address_record . models import AddressRecord <EOL> from mozdns . view . models import View <EOL> from mozdns . ip . utils import ip_to_domain_name <EOL> class DeleteStaticStaticRegTests ( TestCase ) : <EOL> def create_domain ( self , name , ip_type = None , delegated = False ) : <EOL> if ip_type is None : <EOL> ip_type = '<STR_LIT:4>' <EOL> if name in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> pass <EOL> else : <EOL> name = ip_to_domain_name ( name , ip_type = ip_type ) <EOL> d = Domain ( name = name , delegated = delegated ) <EOL> d . clean ( ) <EOL> self . assertTrue ( d . is_reverse ) <EOL> return d <EOL> def setUp ( self ) : <EOL> self . arpa = self . create_domain ( name = '<STR_LIT>' ) <EOL> self . arpa . save ( ) <EOL> self . i_arpa = self . create_domain ( name = '<STR_LIT>' ) <EOL> self . i_arpa . save ( ) <EOL> self . c = Domain ( name = "<STR_LIT>" ) <EOL> self . c . save ( ) <EOL> self . f_c = Domain ( name = "<STR_LIT>" ) <EOL> self . f_c . save ( ) <EOL> self . r1 = self . create_domain ( name = "<STR_LIT>" ) <EOL> self . r1 . save ( ) <EOL> self . n = create_fake_host ( hostname = "<STR_LIT>" ) <EOL> self . n . clean ( ) <EOL> self . n . save ( ) <EOL> View . objects . get_or_create ( name = "<STR_LIT>" ) <EOL> def do_add ( self , label , domain , ip_str , system , ip_type = '<STR_LIT:4>' ) : <EOL> r = StaticReg ( <EOL> label = label , domain = domain , ip_str = ip_str , <EOL> ip_type = ip_type , system = system <EOL> ) <EOL> r . clean ( ) <EOL> r . save ( ) <EOL> return r <EOL> def do_delete ( self , r ) : <EOL> ip_str = r . ip_str <EOL> fqdn = r . fqdn <EOL> r . delete ( ) <EOL> self . assertFalse ( <EOL> AddressRecord . objects . filter ( ip_str = ip_str , fqdn = fqdn ) ) <EOL> def test1_delete_basic ( self ) : <EOL> label = "<STR_LIT:foo>" <EOL> domain = self . f_c <EOL> ip_str = "<STR_LIT>" <EOL> system = create_fake_host ( hostname = "<STR_LIT:foo>" ) <EOL> system . save ( ) <EOL> kwargs = { <EOL> '<STR_LIT:label>' : label , '<STR_LIT>' : domain , '<STR_LIT>' : ip_str , <EOL> '<STR_LIT>' : system } <EOL> self . do_add ( ** kwargs ) <EOL> self . assertTrue ( StaticReg . objects . filter ( ** kwargs ) ) <EOL> system . delete ( ) <EOL> self . assertFalse ( StaticReg . objects . filter ( ** kwargs ) ) </s>
