예제 #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
파일: tests.py 프로젝트: MPIB/Lagerregal
 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
파일: tests.py 프로젝트: MPIB/Lagerregal
    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)