def test_dup(self): Site(full_name='foo.bar.baz.bri').save() obj_count = Site.objects.count() self.assertRaises(ValidationError, Site(full_name='foo.bar.baz.bri').save) self.assertEqual(obj_count, Site.objects.count())
def test_bad_names(self): obj_count = Site.objects.count() self.assertRaises(ValidationError, Site(full_name='foo.').save) self.assertEqual(obj_count, Site.objects.count()) self.assertRaises(ValidationError, Site(full_name='.').save) self.assertEqual(obj_count, Site.objects.count()) self.assertRaises(ValidationError, Site(full_name='foo.bar.').save) self.assertEqual(obj_count, Site.objects.count()) self.assertRaises(ValidationError, Site(full_name='foo.bar.').save) self.assertEqual(obj_count, Site.objects.count()) self.assertRaises(ValidationError, Site(full_name='woo..foo.baz').save) self.assertEqual(obj_count, Site.objects.count())
def create_domains(self): private = View(name="private") private.save() public = View(name="public") public.save() d0 = create_fake_zone("dc.mozilla.com", suffix="") s = d0.soa d = Domain(name='vlan.dc.mozilla.com') d.save() d.soa = s d.save() Domain(name='arpa').save() Domain(name='in-addr.arpa').save() # Create Reverse Domains d = create_fake_zone("10.in-addr.arpa", suffix="") d = create_fake_zone("66.in-addr.arpa", suffix="") vlan = Vlan(name='vlan', number=99) vlan.save() site = Site(name='dc') site.save() network = Network(network_str="10.0.0.0/8", ip_type='4') network2 = Network(network_str="66.66.66.0/24", ip_type='4') network2.update_network() network2.save() network.vlan = vlan network.site = site network.update_network() network.save() r = Range( start_str='10.99.99.1', end_str='10.99.99.254', network=network,) r.clean() r.save() r = Range( start_str='66.66.66.1', end_str='66.66.66.254', network=network2,) r.clean() r.save()
def create_domains(self): private = View(name="private") private.save() public = View(name="public") public.save() Domain(name='com').save() Domain(name='mozilla.com').save() Domain(name='dc.mozilla.com').save() Domain(name='vlan.dc.mozilla.com').save() Domain(name='arpa').save() Domain(name='in-addr.arpa').save() Domain(name='10.in-addr.arpa').save() Domain(name='66.in-addr.arpa').save() vlan = Vlan(name='vlan', number=99) vlan.save() site = Site(name='dc') site.save() network = Network(network_str="10.0.0.0/8", ip_type='4') network2 = Network(network_str="66.66.66.0/24", ip_type='4') network2.update_network() network2.save() network.vlan = vlan network.site = site network.update_network() network.save() r = Range( start_str='10.99.99.1', end_str='10.99.99.254', network=network,) r.clean() r.save() r = Range( start_str='66.66.66.1', end_str='66.66.66.254', network=network2,) r.clean() r.save()
class Meta: always_return_data = True queryset = Site.objects.all() fields = Site.get_api_fields() authorization = Authorization() allowed_methods = allowed_methods