1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-27 16:45:22 +00:00
webvirtcloud/computes/tests.py

160 lines
5.1 KiB
Python
Raw Normal View History

from django.core.exceptions import ObjectDoesNotExist
2020-05-29 08:00:51 +00:00
from django.shortcuts import reverse
2015-02-27 08:53:51 +00:00
from django.test import TestCase
2020-05-29 08:00:51 +00:00
from .models import Compute
class ComputesTestCase(TestCase):
def setUp(self):
2022-11-02 05:54:35 +00:00
self.client.login(username="admin", password="admin")
2020-05-29 08:00:51 +00:00
Compute(
2022-11-02 05:54:35 +00:00
name="local",
hostname="localhost",
login="",
password="",
details="local",
2020-05-29 08:00:51 +00:00
type=4,
).save()
def test_index(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("computes"))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
def test_create_update_delete(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("add_socket_host"))
self.assertEqual(response.status_code, 200)
response = self.client.post(
2022-11-02 05:54:35 +00:00
reverse("add_socket_host"),
{
2022-11-02 05:54:35 +00:00
"name": "l1",
"details": "Created",
"hostname": "localhost",
"type": 4,
},
)
2022-11-02 05:54:35 +00:00
self.assertRedirects(response, reverse("computes"))
compute = Compute.objects.get(pk=2)
2022-11-02 05:54:35 +00:00
self.assertEqual(compute.name, "l1")
self.assertEqual(compute.details, "Created")
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("compute_update", args=[2]))
self.assertEqual(response.status_code, 200)
response = self.client.post(
2022-11-02 05:54:35 +00:00
reverse("compute_update", args=[2]),
{
2022-11-02 05:54:35 +00:00
"name": "l2",
"details": "Updated",
"hostname": "localhost",
"type": 4,
},
)
2022-11-02 05:54:35 +00:00
self.assertRedirects(response, reverse("computes"))
compute = Compute.objects.get(pk=2)
2022-11-02 05:54:35 +00:00
self.assertEqual(compute.name, "l2")
self.assertEqual(compute.details, "Updated")
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("compute_delete", args=[2]))
self.assertEqual(response.status_code, 200)
2022-11-02 05:54:35 +00:00
response = self.client.post(reverse("compute_delete", args=[2]))
self.assertRedirects(response, reverse("computes"))
with self.assertRaises(ObjectDoesNotExist):
Compute.objects.get(id=2)
2020-05-29 08:00:51 +00:00
def test_overview(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("overview", args=[1]))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
def test_graph(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("compute_graph", args=[1]))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
def test_instances(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("instances", args=[1]))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
def test_storages(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("storages", args=[1]))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
2020-07-13 09:33:09 +00:00
def test_storage(self):
pass
2020-05-29 08:00:51 +00:00
def test_default_storage_volumes(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(
reverse("volumes", kwargs={"compute_id": 1, "pool": "default"})
)
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
def test_default_storage(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(
reverse("storage", kwargs={"compute_id": 1, "pool": "default"})
)
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
def test_networks(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("networks", args=[1]))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
def test_default_network(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(
reverse("network", kwargs={"compute_id": 1, "pool": "default"})
)
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
def test_interfaces(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("interfaces", args=[1]))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
# TODO: add test for single interface
def test_nwfilters(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("nwfilters", args=[1]))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
# TODO: add test for single nwfilter
def test_secrets(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(reverse("virtsecrets", args=[1]))
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
2020-07-13 09:33:09 +00:00
# def test_create_instance_select_type(self):
# response = self.client.get(reverse('create_instance_select_type', args=[1]))
# self.assertEqual(response.status_code, 200)
2020-05-29 08:00:51 +00:00
# TODO: create_instance
def test_machines(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(
reverse("machines", kwargs={"compute_id": 1, "arch": "x86_64"})
)
2020-05-29 08:00:51 +00:00
self.assertEqual(response.status_code, 200)
2020-06-16 05:04:09 +00:00
def test_compute_disk_buses(self):
response = self.client.get(
2022-11-02 05:54:35 +00:00
reverse(
"buses",
kwargs={
"compute_id": 1,
"arch": "x86_64",
"machine": "pc",
"disk": "disk",
},
)
)
2020-06-16 05:04:09 +00:00
self.assertEqual(response.status_code, 200)
2020-05-29 08:00:51 +00:00
2020-06-16 05:04:09 +00:00
def test_dom_capabilities(self):
2022-11-02 05:54:35 +00:00
response = self.client.get(
reverse(
"domcaps", kwargs={"compute_id": 1, "arch": "x86_64", "machine": "pc"}
)
)
2020-06-16 05:04:09 +00:00
self.assertEqual(response.status_code, 200)