def test_add_reverse_domains(self):
        try:
            self.create_domain(name='192.168', ip_type='4').save()
        except __HOLE__, e:
            pass
        self.assertEqual(ValidationError, type(e))
        e = None
        rdx = self.create_domain(name='192', ip_type='4')
        rdx.save()
        rdy = self.create_domain(name='192.168', ip_type='4')
        rdy.save()
        try:
            self.create_domain(name='192.168', ip_type='4').save()
        except ValidationError, e:
            pass
        self.assertEqual(ValidationError, type(e))
        e = None

        self.create_domain(name='128', ip_type='4').save()
        rd0 = self.create_domain(name='128.193', ip_type='4')
        rd0.save()
        ip1 = self.add_ptr_ipv4('128.193.8.1')
        self.assertEqual(ip1.reverse_domain, rd0)
        ip2 = self.add_ptr_ipv4('128.193.8.2')
        self.assertEqual(ip2.reverse_domain, rd0)
        ip3 = self.add_ptr_ipv4('128.193.8.3')
        self.assertEqual(ip3.reverse_domain, rd0)
        ip4 = self.add_ptr_ipv4('128.193.8.4')
        self.assertEqual(ip4.reverse_domain, rd0)
        rd1 = self.create_domain(name='128.193.8', ip_type='4')
        rd1.save()
        ptr1 = PTR.objects.filter(ip_lower=ipaddr.IPv4Address(
            '128.193.8.1').__int__(), ip_type='4')[0]
        self.assertEqual(ptr1.reverse_domain, rd1)
        ptr2 = PTR.objects.filter(ip_lower=ipaddr.IPv4Address(
            '128.193.8.2').__int__(), ip_type='4')[0]
        self.assertEqual(ptr2.reverse_domain, rd1)
        ptr3 = PTR.objects.filter(ip_lower=ipaddr.IPv4Address(
            '128.193.8.3').__int__(), ip_type='4')[0]
        self.assertEqual(ptr3.reverse_domain, rd1)
        ptr4 = PTR.objects.filter(ip_lower=ipaddr.IPv4Address(
            '128.193.8.4').__int__(), ip_type='4')[0]
        self.assertEqual(ptr4.reverse_domain, rd1)
        rd1.delete()
        ptr1 = PTR.objects.filter(ip_lower=ipaddr.IPv4Address(
            '128.193.8.1').__int__(), ip_type='4')[0]
        self.assertEqual(ptr1.reverse_domain, rd0)
        ptr2 = PTR.objects.filter(ip_lower=ipaddr.IPv4Address(
            '128.193.8.2').__int__(), ip_type='4')[0]
        self.assertEqual(ptr2.reverse_domain, rd0)
        ptr3 = PTR.objects.filter(ip_lower=ipaddr.IPv4Address(
            '128.193.8.2').__int__(), ip_type='4')[0]
        self.assertEqual(ptr3.reverse_domain, rd0)
        ptr4 = PTR.objects.filter(ip_lower=ipaddr.IPv4Address(
            '128.193.8.3').__int__(), ip_type='4')[0]
        self.assertEqual(ptr4.reverse_domain, rd0)
dataset/ETHPy150Open rtucker-mozilla/mozilla_inventory/mozdns/domain/tests/reverse_tests.py/ReverseDomainTests.test_add_reverse_domains