Esempio n. 1
0
    def setUpTestData(cls):

        providers = (
            Provider(name="Provider 1", slug="provider-1"),
            Provider(name="Provider 2", slug="provider-2"),
        )
        Provider.objects.bulk_create(providers)

        ProviderNetwork.objects.bulk_create([
            ProviderNetwork(name="Provider Network 1",
                            slug="provider-network-1",
                            provider=providers[0]),
            ProviderNetwork(name="Provider Network 2",
                            slug="provider-network-2",
                            provider=providers[0]),
            ProviderNetwork(name="Provider Network 3",
                            slug="provider-network-3",
                            provider=providers[0]),
            ProviderNetwork(name="Provider Network 8", provider=providers[0]),
        ])

        tags = cls.create_tags("Alpha", "Bravo", "Charlie")

        cls.form_data = {
            "name": "ProviderNetwork X",
            "slug": "provider-network-x",
            "provider": providers[1].pk,
            "description": "A new ProviderNetwork",
            "comments": "Longer description goes here",
            "tags": [t.pk for t in tags],
        }

        cls.csv_data = (
            "name,slug,provider,description",
            "Provider Network 4,provider-network-4,Provider 1,Foo",
            "Provider Network 5,provider-network-5,Provider 1,Bar",
            "Provider Network 6,provider-network-6,Provider 1,Baz",
            "Provider Network 7,,Provider 1,Baz",
        )

        cls.bulk_edit_data = {
            "provider": providers[1].pk,
            "description": "New description",
            "comments": "New comments",
        }

        cls.slug_test_object = "Provider Network 8"
        cls.slug_source = "name"
Esempio n. 2
0
    def setUpTestData(cls):
        providers = (
            Provider(name="Provider 1", slug="provider-1"),
            Provider(name="Provider 2", slug="provider-2"),
        )
        Provider.objects.bulk_create(providers)

        provider_networks = (
            ProviderNetwork(name="Provider Network 1",
                            slug="provider-network-1",
                            provider=providers[0]),
            ProviderNetwork(name="Provider Network 2",
                            slug="provider-network-2",
                            provider=providers[0]),
            ProviderNetwork(name="Provider Network 3",
                            slug="provider-network-3",
                            provider=providers[0]),
        )
        ProviderNetwork.objects.bulk_create(provider_networks)

        cls.create_data = [
            {
                "name": "Provider Network 4",
                "slug": "provider-network-4",
                "provider": providers[0].pk,
            },
            {
                "name": "Provider Network 5",
                "slug": "provider-network-5",
                "provider": providers[0].pk,
            },
            {
                "name": "Provider Network 6",
                "slug": "provider-network-6",
                "provider": providers[0].pk,
            },
        ]

        cls.bulk_update_data = {
            "provider": providers[1].pk,
            "description": "New description",
        }
Esempio n. 3
0
    def setUpTestData(cls):

        providers = (
            Provider(name="Provider 1", slug="provider-1"),
            Provider(name="Provider 2", slug="provider-2"),
            Provider(name="Provider 3", slug="provider-3"),
        )
        Provider.objects.bulk_create(providers)

        provider_networks = (
            ProviderNetwork(name="Provider Network 1",
                            slug="provider-network-1",
                            provider=providers[0]),
            ProviderNetwork(name="Provider Network 2",
                            slug="provider-network-2",
                            provider=providers[1]),
            ProviderNetwork(name="Provider Network 3",
                            slug="provider-network-3",
                            provider=providers[2]),
        )
        ProviderNetwork.objects.bulk_create(provider_networks)
Esempio n. 4
0
    def setUpTestData(cls):

        sites = (
            Site.objects.create(name="Site 1", slug="site-1"),
            Site.objects.create(name="Site 2", slug="site-2"),
            Site.objects.create(name="Site 3", slug="site-3"),
        )
        manufacturer = Manufacturer.objects.create(name="Test Manufacturer 1",
                                                   slug="test-manufacturer-1")
        devicetype = DeviceType.objects.create(
            manufacturer=manufacturer,
            model="Test Device Type 1",
            slug="test-device-type-1",
        )
        devicerole = DeviceRole.objects.create(name="Test Device Role 1",
                                               slug="test-device-role-1",
                                               color="ff0000")
        device_status = Status.objects.get_for_model(Device).get(slug="active")
        device1 = Device.objects.create(
            device_type=devicetype,
            device_role=devicerole,
            name="TestDevice1",
            site=sites[0],
            status=device_status,
        )
        device2 = Device.objects.create(
            device_type=devicetype,
            device_role=devicerole,
            name="TestDevice2",
            site=sites[1],
            status=device_status,
        )
        interface1 = Interface.objects.create(device=device1, name="eth0")
        interface2 = Interface.objects.create(device=device2, name="eth0")

        circuit_types = (CircuitType.objects.create(name="Circuit Type 1",
                                                    slug="circuit-type-1"), )

        providers = (
            Provider.objects.create(name="Provider 1", slug="provider-1"),
            Provider.objects.create(name="Provider 2", slug="provider-2"),
        )

        provider_networks = (
            ProviderNetwork(name="Provider Network 1",
                            slug="provider-network-1",
                            provider=providers[1]),
            ProviderNetwork(name="Provider Network 2",
                            slug="provider-network-2",
                            provider=providers[1]),
            ProviderNetwork(name="Provider Network 3",
                            slug="provider-network-3",
                            provider=providers[1]),
        )
        ProviderNetwork.objects.bulk_create(provider_networks)

        circuits = (
            Circuit(provider=providers[0],
                    type=circuit_types[0],
                    cid="Circuit 1"),
            Circuit(provider=providers[0],
                    type=circuit_types[0],
                    cid="Circuit 2"),
            Circuit(provider=providers[0],
                    type=circuit_types[0],
                    cid="Circuit 3"),
            Circuit(provider=providers[0],
                    type=circuit_types[0],
                    cid="Circuit 4"),
            Circuit(provider=providers[0],
                    type=circuit_types[0],
                    cid="Circuit 5"),
            Circuit(provider=providers[0],
                    type=circuit_types[0],
                    cid="Circuit 6"),
        )

        Circuit.objects.bulk_create(circuits)

        circuit_terminations = (
            CircuitTermination.objects.create(
                circuit=circuits[0],
                site=sites[0],
                term_side="A",
                port_speed=1000,
                upstream_speed=1000,
                xconnect_id="ABC",
            ),
            CircuitTermination.objects.create(
                circuit=circuits[0],
                site=sites[1],
                term_side="Z",
                port_speed=1000,
                upstream_speed=1000,
                xconnect_id="DEF",
            ),
            CircuitTermination.objects.create(
                circuit=circuits[1],
                site=sites[1],
                term_side="A",
                port_speed=2000,
                upstream_speed=2000,
                xconnect_id="GHI",
            ),
            CircuitTermination.objects.create(
                circuit=circuits[1],
                site=sites[2],
                term_side="Z",
                port_speed=2000,
                upstream_speed=2000,
                xconnect_id="JKL",
            ),
            CircuitTermination.objects.create(
                circuit=circuits[2],
                site=sites[2],
                term_side="A",
                port_speed=3000,
                upstream_speed=3000,
                xconnect_id="MNO",
            ),
            CircuitTermination.objects.create(
                circuit=circuits[2],
                site=sites[0],
                term_side="Z",
                port_speed=3000,
                upstream_speed=3000,
                xconnect_id="PQR",
            ),
            CircuitTermination.objects.create(
                circuit=circuits[3],
                provider_network=provider_networks[0],
                term_side="A"),
            CircuitTermination.objects.create(
                circuit=circuits[4],
                provider_network=provider_networks[1],
                term_side="A"),
            CircuitTermination.objects.create(
                circuit=circuits[5],
                provider_network=provider_networks[2],
                term_side="A"),
        )

        cable_statuses = Status.objects.get_for_model(Cable)
        status_connected = cable_statuses.get(slug="connected")

        Cable.objects.create(
            termination_a=circuit_terminations[0],
            termination_b=interface1,
            status=status_connected,
        )
        Cable.objects.create(
            termination_a=circuit_terminations[1],
            termination_b=interface2,
            status=status_connected,
        )
Esempio n. 5
0
    def setUpTestData(cls):

        regions = (
            Region.objects.create(name="Test Region 1", slug="test-region-1"),
            Region.objects.create(name="Test Region 2", slug="test-region-2"),
            Region.objects.create(name="Test Region 3", slug="test-region-3"),
        )

        sites = (
            Site.objects.create(name="Test Site 1",
                                slug="test-site-1",
                                region=regions[0]),
            Site.objects.create(name="Test Site 2",
                                slug="test-site-2",
                                region=regions[1]),
            Site.objects.create(name="Test Site 3",
                                slug="test-site-3",
                                region=regions[2]),
        )

        tenant_groups = (
            TenantGroup.objects.create(name="Tenant group 1",
                                       slug="tenant-group-1"),
            TenantGroup.objects.create(name="Tenant group 2",
                                       slug="tenant-group-2"),
            TenantGroup.objects.create(name="Tenant group 3",
                                       slug="tenant-group-3"),
        )

        tenants = (
            Tenant.objects.create(name="Tenant 1",
                                  slug="tenant-1",
                                  group=tenant_groups[0]),
            Tenant.objects.create(name="Tenant 2",
                                  slug="tenant-2",
                                  group=tenant_groups[1]),
            Tenant.objects.create(name="Tenant 3",
                                  slug="tenant-3",
                                  group=tenant_groups[2]),
        )

        circuit_types = (
            CircuitType.objects.create(name="Test Circuit Type 1",
                                       slug="test-circuit-type-1"),
            CircuitType.objects.create(name="Test Circuit Type 2",
                                       slug="test-circuit-type-2"),
        )

        providers = (
            Provider.objects.create(name="Provider 1", slug="provider-1"),
            Provider.objects.create(name="Provider 2", slug="provider-2"),
        )

        provider_network = (
            ProviderNetwork(name="Provider Network 1",
                            slug="provider-network-1",
                            provider=providers[1]),
            ProviderNetwork(name="Provider Network 2",
                            slug="provider-network-2",
                            provider=providers[1]),
            ProviderNetwork(name="Provider Network 3",
                            slug="provider-network-3",
                            provider=providers[1]),
        )
        ProviderNetwork.objects.bulk_create(provider_network)

        circ_statuses = Status.objects.get_for_model(Circuit)
        circ_status_map = {s.slug: s for s in circ_statuses.all()}

        circuits = (
            Circuit.objects.create(
                provider=providers[0],
                tenant=tenants[0],
                type=circuit_types[0],
                cid="Test Circuit 1",
                install_date="2020-01-01",
                commit_rate=1000,
                status=circ_status_map["active"],
            ),
            Circuit.objects.create(
                provider=providers[0],
                tenant=tenants[0],
                type=circuit_types[0],
                cid="Test Circuit 2",
                install_date="2020-01-02",
                commit_rate=2000,
                status=circ_status_map["active"],
            ),
            Circuit.objects.create(
                provider=providers[0],
                tenant=tenants[1],
                type=circuit_types[0],
                cid="Test Circuit 3",
                install_date="2020-01-03",
                commit_rate=3000,
                status=circ_status_map["planned"],
            ),
            Circuit.objects.create(
                provider=providers[1],
                tenant=tenants[1],
                type=circuit_types[1],
                cid="Test Circuit 4",
                install_date="2020-01-04",
                commit_rate=4000,
                status=circ_status_map["planned"],
            ),
            Circuit.objects.create(
                provider=providers[1],
                tenant=tenants[2],
                type=circuit_types[1],
                cid="Test Circuit 5",
                install_date="2020-01-05",
                commit_rate=5000,
                status=circ_status_map["offline"],
            ),
            Circuit.objects.create(
                provider=providers[1],
                tenant=tenants[2],
                type=circuit_types[1],
                cid="Test Circuit 6",
                install_date="2020-01-06",
                commit_rate=6000,
                status=circ_status_map["offline"],
            ),
        )

        CircuitTermination.objects.create(circuit=circuits[0],
                                          site=sites[0],
                                          term_side="A")
        CircuitTermination.objects.create(circuit=circuits[1],
                                          site=sites[1],
                                          term_side="A")
        CircuitTermination.objects.create(circuit=circuits[2],
                                          site=sites[2],
                                          term_side="A")
        CircuitTermination.objects.create(circuit=circuits[3],
                                          provider_network=provider_network[0],
                                          term_side="A")
        CircuitTermination.objects.create(circuit=circuits[4],
                                          provider_network=provider_network[1],
                                          term_side="A")
        CircuitTermination.objects.create(circuit=circuits[5],
                                          provider_network=provider_network[2],
                                          term_side="A")