mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-23 22:55:23 +00:00
Added coverage.py support
This commit is contained in:
parent
7103c52380
commit
10b6f88dbb
17 changed files with 23 additions and 58 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -12,3 +12,5 @@ tags
|
|||
dhcpd.*
|
||||
webvirtcloud/settings.py
|
||||
*migrations/*
|
||||
.coverage
|
||||
htmlcov
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -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
|
||||
|
|
@ -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">
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +1,4 @@
|
|||
coverage==5.1
|
||||
Django==2.2.12
|
||||
django-bootstrap3==12.1.0
|
||||
django-fa==1.0.0
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,6 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
Loading…
Reference in a new issue