Пример #1
0
    def test_device_ipaddress(self):
        device = mommy.make(Device)
        ip = IpAddress(address="127.0.0.1")
        ip.save()
        devices = Device.objects.all()
        device = devices[0]
        url = reverse("device-ipaddress", kwargs={"pk": device.pk})
        resp = self.client.post(url, {
            "ipaddresses": [ip.pk],
            "device": device.pk
        })
        self.assertEqual(resp.status_code, 302)
        deviceurl = reverse("device-detail", kwargs={"pk": device.pk})
        resp = self.client.get(deviceurl)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(len(resp.context["device"].ipaddress_set.all()), 1)

        url = reverse("device-ipaddress-remove",
                      kwargs={
                          "pk": device.pk,
                          "ipaddress": ip.pk
                      })
        resp = self.client.post(url)
        self.assertEqual(resp.status_code, 302)
        resp = self.client.get(deviceurl)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(len(resp.context["device"].ipaddress_set.all()), 0)
Пример #2
0
 def test_device_detail(self):
     device = mommy.make(Device)
     devices = Device.objects.all()
     device = devices[0]
     ip = IpAddress(address="127.0.0.1")
     ip.save()
     url = reverse("device-detail", kwargs={"pk": device.pk})
     resp = self.client.get(url)
     self.assertEqual(resp.status_code, 200)
Пример #3
0
 def test_device_detail(self):
     device = mommy.make(Device)
     devices = Device.objects.all()
     device = devices[0]
     ip = IpAddress(address="127.0.0.1")
     ip.save()
     url = reverse("device-detail", kwargs={"pk": device.pk})
     resp = self.client.get(url)
     self.assertEqual(resp.status_code, 200)
Пример #4
0
    def test_device_ipaddress(self):
        device = mommy.make(Device)
        ip = IpAddress(address="127.0.0.1")
        ip.save()
        devices = Device.objects.all()
        device = devices[0]
        url = reverse("device-ipaddress", kwargs={"pk": device.pk})
        resp = self.client.post(url, {"ipaddresses": [ip.pk], "device": device.pk})
        self.assertEqual(resp.status_code, 302)
        deviceurl = reverse("device-detail", kwargs={"pk": device.pk})
        resp = self.client.get(deviceurl)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(len(resp.context["device"].ipaddress_set.all()), 1)

        url = reverse("device-ipaddress-remove", kwargs={"pk": device.pk, "ipaddress": ip.pk})
        resp = self.client.post(url)
        self.assertEqual(resp.status_code, 302)
        resp = self.client.get(deviceurl)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(len(resp.context["device"].ipaddress_set.all()), 0)