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

Added coverage.py support

This commit is contained in:
Real-Gecko 2020-05-29 19:37:49 +06:00
parent 7103c52380
commit 10b6f88dbb
17 changed files with 23 additions and 58 deletions

2
.gitignore vendored
View file

@ -12,3 +12,5 @@ tags
dhcpd.*
webvirtcloud/settings.py
*migrations/*
.coverage
htmlcov

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,13 +0,0 @@
from django.contrib.auth.backends import RemoteUserBackend
from accounts.models import UserInstance, UserAttributes
from instances.models import Instance
class MyRemoteUserBackend(RemoteUserBackend):
#create_unknown_user = True
def configure_user(self, user):
#user.is_superuser = True
UserAttributes.configure_user(user)
return user

View file

@ -11,6 +11,7 @@
<h2 class="page-header">{{ title }}</h2>
</div>
</div>
{% bootstrap_messages %}
<div class="row">
<div class="thumbnail col-sm-10 col-sm-offset-1">
<form id="create-update" action="" method="post" class="form-horizontal">

View file

@ -9,29 +9,33 @@ from accounts.models import UserAttributes
class AdminTestCase(TestCase):
def setUp(self):
self.client.login(username='admin', password='admin')
# User.objects.create_user(username='test', password='test')
# def test_user(self):
# user = User.objects.get(username='test')
# self.assertEqual(user.id, 2)
def test_group_list(self):
response = self.client.get(reverse('admin:group_list'))
self.assertEqual(response.status_code, 200)
def test_groups(self):
response = self.client.get(reverse('admin:group_create'))
self.assertEqual(response.status_code, 200)
response = self.client.post(reverse('admin:group_create'), {'name': 'Test Group'})
self.assertRedirects(response, reverse('admin:group_list'))
group = Group.objects.get(name='Test Group')
self.assertEqual(group.id, 1)
response = self.client.get(reverse('admin:group_update', args=[1]))
self.assertEqual(response.status_code, 200)
response = self.client.post(reverse('admin:group_update', args=[1]), {'name': 'Updated Group Test'})
self.assertRedirects(response, reverse('admin:group_list'))
group = Group.objects.get(id=1)
self.assertEqual(group.name, 'Updated Group Test')
response = self.client.get(reverse('admin:group_delete', args=[1]))
self.assertEqual(response.status_code, 200)
response = self.client.post(reverse('admin:group_delete', args=[1]))
self.assertRedirects(response, reverse('admin:group_list'))
@ -43,6 +47,9 @@ class AdminTestCase(TestCase):
self.assertEqual(response.status_code, 200)
def test_users(self):
response = self.client.get(reverse('admin:user_create'))
self.assertEqual(response.status_code, 200)
response = self.client.post(
reverse('admin:user_create'),
{
@ -66,6 +73,9 @@ class AdminTestCase(TestCase):
self.assertEqual(ua.max_memory, 1024)
self.assertEqual(ua.max_disk_size, 4)
response = self.client.get(reverse('admin:user_update', args=[2]))
self.assertEqual(response.status_code, 200)
response = self.client.post(
reverse('admin:user_update', args=[2]),
{
@ -96,12 +106,15 @@ class AdminTestCase(TestCase):
user = User.objects.get(id=2)
self.assertTrue(user.is_active)
response = self.client.get(reverse('admin:user_delete', args=[2]))
self.assertEqual(response.status_code, 200)
response = self.client.post(reverse('admin:user_delete', args=[2]))
self.assertRedirects(response, reverse('admin:user_list'))
with self.assertRaises(ObjectDoesNotExist):
User.objects.get(id=2)
def test_user_logs(self):
def test_logs(self):
response = self.client.get(reverse('admin:logs'))
self.assertEqual(response.status_code, 200)

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +1,4 @@
coverage==5.1
Django==2.2.12
django-bootstrap3==12.1.0
django-fa==1.0.0

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,6 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.