<s> from django . test import TestCase <EOL> from mozdns . domain . models import Domain <EOL> from mozdns . ptr . models import PTR <EOL> from mozdns . address_record . models import AddressRecord <EOL> from systems . models import System <EOL> from core . interface . static_intr . models import StaticInterface <EOL> from core . range . utils import start_end_filter , range_usage <EOL> class UsageTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> Domain . objects . get_or_create ( name = "<STR_LIT>" ) <EOL> self . domain , _ = Domain . objects . get_or_create ( name = "<STR_LIT>" ) <EOL> Domain . objects . get_or_create ( name = "<STR_LIT>" ) <EOL> Domain . objects . get_or_create ( name = "<STR_LIT>" ) <EOL> Domain . objects . get_or_create ( name = "<STR_LIT>" ) <EOL> def test0 ( self ) : <EOL> ip_start = "<STR_LIT>" <EOL> ip_end = "<STR_LIT>" <EOL> ptr = PTR ( name = "<STR_LIT>" , ip_str = "<STR_LIT>" , ip_type = '<STR_LIT:4>' ) <EOL> ptr . full_clean ( ) <EOL> ptr . save ( ) <EOL> istart , iend , ipf_q = start_end_filter ( ip_start , ip_end , '<STR_LIT:4>' ) <EOL> addrs = list ( AddressRecord . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> ptrs = list ( PTR . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> intrs = list ( StaticInterface . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( addrs ) <EOL> self . assertEqual ( ptr . pk , ptrs [ <NUM_LIT:0> ] . pk ) <EOL> self . assertFalse ( intrs ) <EOL> range_details = range_usage ( ip_start , ip_end , '<STR_LIT:4>' ) <EOL> self . assertEqual ( <NUM_LIT:9> , range_details [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , range_details [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( [ ( int ( istart ) + <NUM_LIT:0> , int ( istart ) + <NUM_LIT:4> ) , <EOL> ( int ( istart ) + <NUM_LIT:6> , int ( istart ) + <NUM_LIT:9> ) ] , <EOL> range_details [ '<STR_LIT>' ] ) <EOL> def test1 ( self ) : <EOL> ip_start = "<STR_LIT>" <EOL> ip_end = "<STR_LIT>" <EOL> ptr = PTR ( name = "<STR_LIT>" , ip_str = "<STR_LIT>" , ip_type = '<STR_LIT:4>' ) <EOL> ptr . full_clean ( ) <EOL> ptr . save ( ) <EOL> a = AddressRecord ( <EOL> label = "<STR_LIT:foo>" , domain = self . domain , ip_str = "<STR_LIT>" , ip_type = '<STR_LIT:4>' ) <EOL> a . full_clean ( ) <EOL> a . save ( ) <EOL> istart , iend , ipf_q = start_end_filter ( ip_start , ip_end , '<STR_LIT:4>' ) <EOL> addrs = list ( AddressRecord . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> ptrs = list ( PTR . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> intrs = list ( StaticInterface . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( a . pk , addrs [ <NUM_LIT:0> ] . pk ) <EOL> self . assertEqual ( ptr . pk , ptrs [ <NUM_LIT:0> ] . pk ) <EOL> self . assertFalse ( intrs ) <EOL> range_details = range_usage ( ip_start , ip_end , '<STR_LIT:4>' ) <EOL> self . assertEqual ( <NUM_LIT:8> , range_details [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:2> , range_details [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( [ ( int ( istart ) , int ( istart ) + <NUM_LIT:4> ) , <EOL> ( int ( istart ) + <NUM_LIT:7> , int ( istart ) + <NUM_LIT:9> ) ] , <EOL> range_details [ '<STR_LIT>' ] ) <EOL> def test2 ( self ) : <EOL> ip_start = "<STR_LIT>" <EOL> ip_end = "<STR_LIT>" <EOL> ptr = PTR ( name = "<STR_LIT>" , ip_str = "<STR_LIT>" , ip_type = '<STR_LIT:4>' ) <EOL> ptr . full_clean ( ) <EOL> ptr . save ( ) <EOL> a = AddressRecord ( label = "<STR_LIT:foo>" , domain = self . domain , ip_str = "<STR_LIT>" , <EOL> ip_type = '<STR_LIT:4>' ) <EOL> a . full_clean ( ) <EOL> a . save ( ) <EOL> s = System ( ) <EOL> s . save ( ) <EOL> intr = StaticInterface ( <EOL> label = "<STR_LIT:foo>" , domain = self . domain , ip_str = "<STR_LIT>" , <EOL> ip_type = '<STR_LIT:4>' , system = s , mac = "<STR_LIT>" ) <EOL> intr . full_clean ( ) <EOL> intr . save ( ) <EOL> istart , iend , ipf_q = start_end_filter ( ip_start , ip_end , '<STR_LIT:4>' ) <EOL> addrs = list ( AddressRecord . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> ptrs = list ( PTR . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> intrs = list ( StaticInterface . objects . filter ( ipf_q ) . <EOL> order_by ( '<STR_LIT>' ) . order_by ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( a . pk , addrs [ <NUM_LIT:0> ] . pk ) <EOL> self . assertEqual ( ptr . pk , ptrs [ <NUM_LIT:0> ] . pk ) <EOL> self . assertEqual ( intr . pk , intrs [ <NUM_LIT:0> ] . pk ) <EOL> range_details = range_usage ( ip_start , ip_end , '<STR_LIT:4>' ) <EOL> self . assertEqual ( <NUM_LIT> , range_details [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:2> , range_details [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( [ ( int ( istart ) + <NUM_LIT:0> , int ( istart ) + <NUM_LIT:2> ) , <EOL> ( int ( istart ) + <NUM_LIT:5> , int ( istart ) + <NUM_LIT> ) ] , <EOL> range_details [ '<STR_LIT>' ] ) </s>
