add initial osusers unit tests
This commit is contained in:
parent
e8285518a3
commit
b9dd34d527
4 changed files with 97 additions and 27 deletions
0
gnuviechadmin/osusers/tests/__init__.py
Normal file
0
gnuviechadmin/osusers/tests/__init__.py
Normal file
54
gnuviechadmin/osusers/tests/test_models.py
Normal file
54
gnuviechadmin/osusers/tests/test_models.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from osusers.models import (
|
||||
CANNOT_USE_PRIMARY_GROUP_AS_ADDITIONAL,
|
||||
AdditionalGroup,
|
||||
Group,
|
||||
Shadow,
|
||||
User,
|
||||
)
|
||||
|
||||
|
||||
class AdditionalGroupTest(TestCase):
|
||||
@override_settings(
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
CELERY_CACHE_BACKEND='memory',
|
||||
BROKER_BACKEND='memory'
|
||||
)
|
||||
def test_clean_primary_group(self):
|
||||
group1 = Group.objects.create(groupname='test1', gid=1000)
|
||||
user = User.objects.create(
|
||||
username='test', uid=1000, group=group1,
|
||||
homedir='/home/test', shell='/bin/bash')
|
||||
testsubj = AdditionalGroup(user=user, group=group1)
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
testsubj.clean()
|
||||
self.assertEqual(
|
||||
cm.exception.message, CANNOT_USE_PRIMARY_GROUP_AS_ADDITIONAL)
|
||||
|
||||
@override_settings(
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
CELERY_CACHE_BACKEND='memory',
|
||||
BROKER_BACKEND='memory'
|
||||
)
|
||||
def test_clean_other_group(self):
|
||||
group1 = Group(groupname='test1', gid=1000)
|
||||
group2 = Group(groupname='test2', gid=1001)
|
||||
user = User(username='test', uid=1000, group=group1,
|
||||
homedir='/home/test', shell='/bin/bash')
|
||||
testsubj = AdditionalGroup(user=user, group=group2)
|
||||
testsubj.clean()
|
||||
|
||||
|
||||
class GroupTest(TestCase):
|
||||
pass
|
||||
|
||||
|
||||
class ShadowTest(TestCase):
|
||||
pass
|
||||
|
||||
|
||||
class UserTest(TestCase):
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue