1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 15:15:22 +00:00

Some test for computes

This commit is contained in:
Real-Gecko 2020-05-29 14:00:51 +06:00
parent 83b1dde673
commit 7b0016c0b2
3 changed files with 118 additions and 29 deletions

View file

@ -1,8 +1,8 @@
from django.test import TestCase
from django.contrib.auth.models import User from django.contrib.auth.models import User
from .urls import urlpatterns
from django.shortcuts import reverse from django.shortcuts import reverse
from django.test import Client from django.test import Client, TestCase
from .urls import urlpatterns
class AdminTestCase(TestCase): class AdminTestCase(TestCase):

View file

@ -1,3 +1,83 @@
from django.shortcuts import reverse
from django.test import TestCase from django.test import TestCase
# Create your tests here. from .models import Compute
class ComputesTestCase(TestCase):
def setUp(self):
self.client.login(username='admin', password='admin')
Compute(
name='local',
hostname='localhost',
login='',
password='',
details='local',
type=4,
).save()
def test_index(self):
response = self.client.get(reverse('computes'))
self.assertEqual(response.status_code, 200)
def test_overview(self):
response = self.client.get(reverse('overview', args=[1]))
self.assertEqual(response.status_code, 200)
def test_graph(self):
response = self.client.get(reverse('compute_graph', args=[1]))
self.assertEqual(response.status_code, 200)
def test_instances(self):
response = self.client.get(reverse('instances', args=[1]))
self.assertEqual(response.status_code, 200)
def test_storages(self):
response = self.client.get(reverse('storages', args=[1]))
self.assertEqual(response.status_code, 200)
def test_default_storage_volumes(self):
response = self.client.get(reverse('volumes', kwargs={'compute_id': 1, 'pool': 'default'}))
self.assertEqual(response.status_code, 200)
def test_default_storage(self):
response = self.client.get(reverse('storage', kwargs={'compute_id': 1, 'pool': 'default'}))
self.assertEqual(response.status_code, 200)
def test_networks(self):
response = self.client.get(reverse('networks', args=[1]))
self.assertEqual(response.status_code, 200)
def test_default_network(self):
response = self.client.get(reverse('network', kwargs={'compute_id': 1, 'pool': 'default'}))
self.assertEqual(response.status_code, 200)
def test_interfaces(self):
response = self.client.get(reverse('interfaces', args=[1]))
self.assertEqual(response.status_code, 200)
# TODO: add test for single interface
def test_nwfilters(self):
response = self.client.get(reverse('nwfilters', args=[1]))
self.assertEqual(response.status_code, 200)
# TODO: add test for single nwfilter
def test_secrets(self):
response = self.client.get(reverse('secrets', args=[1]))
self.assertEqual(response.status_code, 200)
def test_create_instance_select_type(self):
response = self.client.get(reverse('create_instance_select_type', args=[1]))
self.assertEqual(response.status_code, 200)
# TODO: create_instance
def test_machines(self):
response = self.client.get(reverse('machines', kwargs={'compute_id': 1, 'arch': 'x86_64'}))
self.assertEqual(response.status_code, 200)
# TODO: get_compute_disk_buses
# TODO: domcaps

View file

@ -1,32 +1,41 @@
from django.urls import path, re_path
from storages.views import storages, storage, get_volumes
from networks.views import networks, network
from secrets.views import secrets from secrets.views import secrets
from django.urls import path
from . import views
from create.views import create_instance, create_instance_select_type from create.views import create_instance, create_instance_select_type
from interfaces.views import interfaces, interface
from computes.views import overview, compute_graph, computes, get_compute_disk_buses, get_compute_machine_types, get_dom_capabilities
from instances.views import instances from instances.views import instances
from interfaces.views import interface, interfaces
from networks.views import network, networks
from nwfilters.views import nwfilter, nwfilters from nwfilters.views import nwfilter, nwfilters
from storages.views import get_volumes, storage, storages
urlpatterns = [ urlpatterns = [
path('', computes, name='computes'), path('', views.computes, name='computes'),
re_path(r'^(?P<compute_id>[0-9]+)/$', overview, name='overview'), path('<int:compute_id>/', views.overview, name='overview'),
re_path(r'^(?P<compute_id>[0-9]+)/statistics$', compute_graph, name='compute_graph'), path('<int:compute_id>/statistics/', views.compute_graph, name='compute_graph'),
re_path(r'^(?P<compute_id>[0-9]+)/instances/$', instances, name='instances'), path('<int:compute_id>/instances/', instances, name='instances'),
re_path(r'^(?P<compute_id>[0-9]+)/storages/$', storages, name='storages'), path('<int:compute_id>/storages/', storages, name='storages'),
re_path(r'^(?P<compute_id>[0-9]+)/storage/(?P<pool>[\w\-\.\/]+)/volumes$', get_volumes, name='volumes'), path('<int:compute_id>/storage/<str:pool>/volumes/', get_volumes, name='volumes'),
re_path(r'^(?P<compute_id>[0-9]+)/storage/(?P<pool>[\w\-\.\/]+)/$', storage, name='storage'), path('<int:compute_id>/storage/<str:pool>/', storage, name='storage'),
re_path(r'^(?P<compute_id>[0-9]+)/networks/$', networks, name='networks'), path('<int:compute_id>/networks/', networks, name='networks'),
re_path(r'^(?P<compute_id>[0-9]+)/network/(?P<pool>[\w\-\.]+)/$', network, name='network'), path('<int:compute_id>/network/<str:pool>/', network, name='network'),
re_path(r'^(?P<compute_id>[0-9]+)/interfaces/$', interfaces, name='interfaces'), path('<int:compute_id>/interfaces/', interfaces, name='interfaces'),
re_path(r'^(?P<compute_id>[0-9]+)/interface/(?P<iface>[\w\-\.\:]+)/$', interface, name='interface'), path('<int:compute_id>/interface/<str:iface>/', interface, name='interface'),
re_path(r'^(?P<compute_id>[0-9]+)/nwfilters/$', nwfilters, name='nwfilters'), path('<int:compute_id>/nwfilters/', nwfilters, name='nwfilters'),
re_path(r'^(?P<compute_id>[0-9]+)/nwfilter/(?P<nwfltr>[\w\-\.\:]+)/$', nwfilter, name='nwfilter'), path('<int:compute_id>/nwfilter/<str:nwfltr>/', nwfilter, name='nwfilter'),
re_path(r'^(?P<compute_id>[0-9]+)/secrets/$', secrets, name='secrets'), path('<int:compute_id>/secrets/', secrets, name='secrets'),
re_path(r'^(?P<compute_id>[0-9]+)/create/$', create_instance_select_type, name='create_instance_select_type'), path('<int:compute_id>/create/', create_instance_select_type, name='create_instance_select_type'),
re_path(r'^(?P<compute_id>[0-9]+)/create/archs/(?P<arch>[\w\-\.\/]+)/machines/(?P<machine>[\w\-\.\/]+)$', create_instance, name='create_instance'), path('<int:compute_id>/create/archs/<str:arch>/machines/<str:machine>/', create_instance, name='create_instance'),
re_path(r'^(?P<compute_id>[0-9]+)/archs/(?P<arch>[\w\-\.\/]+)/machines$', get_compute_machine_types, name='machines'), path('<int:compute_id>/archs/<str:arch>/machines/', views.get_compute_machine_types, name='machines'),
re_path(r'^(?P<compute_id>[0-9]+)/archs/(?P<arch>[\w\-\.\/]+)/machines/(?P<machine>[\w\-\.\/]+)/disks/(?P<disk>[\w\-\.\/]+)/buses$', get_compute_disk_buses, name='buses'), path(
re_path(r'^(?P<compute_id>[0-9]+)/archs/(?P<arch>[\w\-\.\/]+)/machines/(?P<machine>[\w\-\.\/]+)/capabilities$', get_dom_capabilities, name='domcaps'), '<int:compute_id>/archs/<str:arch>/machines/<str:machine>/disks/<str:disk>/buses/',
views.get_compute_disk_buses,
name='buses',
),
path(
'<int:compute_id>/archs/<str:arch>/machines/<str:machine>/capabilities/',
views.get_dom_capabilities,
name='domcaps',
),
] ]