def setUpTestData(cls): vlan_groups = ( VLANGroup(name='VLAN Group 1', slug='vlan-group-1'), VLANGroup(name='VLAN Group 2', slug='vlan-group-2'), ) VLANGroup.objects.bulk_create(vlan_groups) vlans = ( VLAN(name='VLAN 1', vid=1, group=vlan_groups[0]), VLAN(name='VLAN 2', vid=2, group=vlan_groups[0]), VLAN(name='VLAN 3', vid=3, group=vlan_groups[0]), ) VLAN.objects.bulk_create(vlans) cls.create_data = [ { 'vid': 4, 'name': 'VLAN 4', 'group': vlan_groups[1].pk, }, { 'vid': 5, 'name': 'VLAN 5', 'group': vlan_groups[1].pk, }, { 'vid': 6, 'name': 'VLAN 6', 'group': vlan_groups[1].pk, }, ]
def setUpTestData(cls): regions = ( Region(name='Test Region 1', slug='test-region-1'), Region(name='Test Region 2', slug='test-region-2'), Region(name='Test Region 3', slug='test-region-3'), ) # Can't use bulk_create for models with MPTT fields for r in regions: r.save() sites = ( Site(name='Test Site 1', slug='test-site-1', region=regions[0]), Site(name='Test Site 2', slug='test-site-2', region=regions[1]), Site(name='Test Site 3', slug='test-site-3', region=regions[2]), ) Site.objects.bulk_create(sites) vlan_groups = ( VLANGroup(name='VLAN Group 1', slug='vlan-group-1', site=sites[0]), VLANGroup(name='VLAN Group 2', slug='vlan-group-2', site=sites[1]), VLANGroup(name='VLAN Group 3', slug='vlan-group-3', site=sites[2]), VLANGroup(name='VLAN Group 4', slug='vlan-group-4', site=None), ) VLANGroup.objects.bulk_create(vlan_groups)
def setUpTestData(cls): sites = ( Site(name='Site 1', slug='site-1'), Site(name='Site 2', slug='site-2'), ) Site.objects.bulk_create(sites) VLANGroup.objects.bulk_create([ VLANGroup(name='VLAN Group 1', slug='vlan-group-1', scope=sites[0]), VLANGroup(name='VLAN Group 2', slug='vlan-group-2', scope=sites[0]), VLANGroup(name='VLAN Group 3', slug='vlan-group-3', scope=sites[0]), ]) cls.form_data = { 'name': 'VLAN Group X', 'slug': 'vlan-group-x', 'description': 'A new VLAN group', } cls.csv_data = ( "name,slug,description", "VLAN Group 4,vlan-group-4,Fourth VLAN group", "VLAN Group 5,vlan-group-5,Fifth VLAN group", "VLAN Group 6,vlan-group-6,Sixth VLAN group", ) cls.bulk_edit_data = { 'description': 'New description', }
def setUpTestData(cls): vlan_groups = ( VLANGroup(name='VLAN Group 1', slug='vlan-group-1'), VLANGroup(name='VLAN Group 2', slug='vlan-group-2'), VLANGroup(name='VLAN Group 3', slug='vlan-group-3'), ) VLANGroup.objects.bulk_create(vlan_groups)
def setUpTestData(cls): regions = ( Region(name='Test Region 1', slug='test-region-1'), Region(name='Test Region 2', slug='test-region-2'), Region(name='Test Region 3', slug='test-region-3'), ) # Can't use bulk_create for models with MPTT fields for r in regions: r.save() sites = ( Site(name='Test Site 1', slug='test-site-1', region=regions[0]), Site(name='Test Site 2', slug='test-site-2', region=regions[1]), Site(name='Test Site 3', slug='test-site-3', region=regions[2]), ) Site.objects.bulk_create(sites) roles = ( Role(name='Role 1', slug='role-1'), Role(name='Role 2', slug='role-2'), Role(name='Role 3', slug='role-3'), ) Role.objects.bulk_create(roles) groups = ( VLANGroup(name='VLAN Group 1', slug='vlan-group-1', site=sites[0]), VLANGroup(name='VLAN Group 2', slug='vlan-group-2', site=sites[1]), VLANGroup(name='VLAN Group 3', slug='vlan-group-3', site=None), ) VLANGroup.objects.bulk_create(groups) tenant_groups = ( TenantGroup(name='Tenant group 1', slug='tenant-group-1'), TenantGroup(name='Tenant group 2', slug='tenant-group-2'), TenantGroup(name='Tenant group 3', slug='tenant-group-3'), ) for tenantgroup in tenant_groups: tenantgroup.save() tenants = ( Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]), Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[1]), Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[2]), ) Tenant.objects.bulk_create(tenants) vlans = ( VLAN(vid=101, name='VLAN 101', site=sites[0], group=groups[0], role=roles[0], tenant=tenants[0], status=VLANStatusChoices.STATUS_ACTIVE), VLAN(vid=102, name='VLAN 102', site=sites[0], group=groups[0], role=roles[0], tenant=tenants[0], status=VLANStatusChoices.STATUS_ACTIVE), VLAN(vid=201, name='VLAN 201', site=sites[1], group=groups[1], role=roles[1], tenant=tenants[1], status=VLANStatusChoices.STATUS_DEPRECATED), VLAN(vid=202, name='VLAN 202', site=sites[1], group=groups[1], role=roles[1], tenant=tenants[1], status=VLANStatusChoices.STATUS_DEPRECATED), VLAN(vid=301, name='VLAN 301', site=sites[2], group=groups[2], role=roles[2], tenant=tenants[2], status=VLANStatusChoices.STATUS_RESERVED), VLAN(vid=302, name='VLAN 302', site=sites[2], group=groups[2], role=roles[2], tenant=tenants[2], status=VLANStatusChoices.STATUS_RESERVED), ) VLAN.objects.bulk_create(vlans)
def mutate_and_get_payload(cls, input, context, info): site = input.get('site') temp = VLANGroup() if not_none(site): temp.site = Site.objects.get(pk=from_global_id(site)[1]) fields = ['name', 'slug'] return NewVLANGroup(vlan_group=set_and_save(fields, input, temp))
def setUpTestData(cls): sites = ( Site(name='Site 1', slug='site-1'), Site(name='Site 2', slug='site-2'), ) Site.objects.bulk_create(sites) vlangroups = ( VLANGroup(name='VLAN Group 1', slug='vlan-group-1', site=sites[0]), VLANGroup(name='VLAN Group 2', slug='vlan-group-2', site=sites[1]), ) VLANGroup.objects.bulk_create(vlangroups) roles = ( Role(name='Role 1', slug='role-1'), Role(name='Role 2', slug='role-2'), ) Role.objects.bulk_create(roles) VLAN.objects.bulk_create([ VLAN(group=vlangroups[0], vid=101, name='VLAN101', site=sites[0], role=roles[0]), VLAN(group=vlangroups[0], vid=102, name='VLAN102', site=sites[0], role=roles[0]), VLAN(group=vlangroups[0], vid=103, name='VLAN103', site=sites[0], role=roles[0]), ]) cls.form_data = { 'site': sites[1].pk, 'group': vlangroups[1].pk, 'vid': 999, 'name': 'VLAN999', 'tenant': None, 'status': VLANStatusChoices.STATUS_RESERVED, 'role': roles[1].pk, 'description': 'A new VLAN', 'tags': 'Alpha,Bravo,Charlie', } cls.csv_data = ( "vid,name,status", "104,VLAN104,Active", "105,VLAN105,Active", "106,VLAN106,Active", ) cls.bulk_edit_data = { 'site': sites[1].pk, 'group': vlangroups[1].pk, 'tenant': None, 'status': VLANStatusChoices.STATUS_RESERVED, 'role': roles[1].pk, 'description': 'New description', }
def setUp(self): self.client = Client() vlangroup = VLANGroup(name='VLAN Group 1', slug='vlan-group-1') vlangroup.save() VLAN.objects.bulk_create([ VLAN(group=vlangroup, vid=101, name='VLAN101'), VLAN(group=vlangroup, vid=102, name='VLAN102'), VLAN(group=vlangroup, vid=103, name='VLAN103'), ])
def setUp(self): user = create_test_user(permissions=['ipam.view_vlan']) self.client = Client() self.client.force_login(user) vlangroup = VLANGroup(name='VLAN Group 1', slug='vlan-group-1') vlangroup.save() VLAN.objects.bulk_create([ VLAN(group=vlangroup, vid=101, name='VLAN101'), VLAN(group=vlangroup, vid=102, name='VLAN102'), VLAN(group=vlangroup, vid=103, name='VLAN103'), ])
def setUp(self): user = create_test_user(permissions=['ipam.view_vlangroup']) self.client = Client() self.client.force_login(user) site = Site(name='Site 1', slug='site-1') site.save() VLANGroup.objects.bulk_create([ VLANGroup(name='VLAN Group 1', slug='vlan-group-1', site=site), VLANGroup(name='VLAN Group 2', slug='vlan-group-2', site=site), VLANGroup(name='VLAN Group 3', slug='vlan-group-3', site=site), ])
def setUpTestData(cls): site = Site.objects.create(name='Site 1', slug='site-1') VLANGroup.objects.bulk_create([ VLANGroup(name='VLAN Group 1', slug='vlan-group-1', site=site), VLANGroup(name='VLAN Group 2', slug='vlan-group-2', site=site), VLANGroup(name='VLAN Group 3', slug='vlan-group-3', site=site), ]) cls.form_data = { 'name': 'VLAN Group X', 'slug': 'vlan-group-x', 'site': site.pk, } cls.csv_data = ( "name,slug", "VLAN Group 4,vlan-group-4", "VLAN Group 5,vlan-group-5", "VLAN Group 6,vlan-group-6", )