Fix test_model_can_create_user
This commit is contained in:
parent
78294cb6a3
commit
714849fb49
2 changed files with 8 additions and 4 deletions
|
@ -68,3 +68,7 @@ class OpenNebulaManager():
|
||||||
opennebula_user = self.oneadmin_client.call(oca.User.METHODS['allocate'], email,
|
opennebula_user = self.oneadmin_client.call(oca.User.METHODS['allocate'], email,
|
||||||
password, 'core')
|
password, 'core')
|
||||||
return opennebula_user
|
return opennebula_user
|
||||||
|
def _get_user_pool(self):
|
||||||
|
user_pool = oca.UserPool(self.oneadmin_client)
|
||||||
|
user_pool.info()
|
||||||
|
return user_pool
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from .models import VirtualMachine
|
from .models import VirtualMachine, VirtualMachineTemplate, OpenNebulaManager
|
||||||
|
|
||||||
class OpenNebulaManagerTestCases(TestCase):
|
class OpenNebulaManagerTestCases(TestCase):
|
||||||
"""This class defines the test suite for the opennebula manager model."""
|
"""This class defines the test suite for the opennebula manager model."""
|
||||||
|
@ -22,11 +22,11 @@ class OpenNebulaManagerTestCases(TestCase):
|
||||||
|
|
||||||
def test_model_can_create_user(self):
|
def test_model_can_create_user(self):
|
||||||
"""Test the opennebula manager model can create a new user."""
|
"""Test the opennebula manager model can create a new user."""
|
||||||
old_count = self.manager._get_user_pool().count()
|
old_count = len(self.manager._get_user_pool())
|
||||||
self.manager = OpenNebulaManager(email=self.email,
|
self.manager = OpenNebulaManager(email=self.email,
|
||||||
password=self.password,
|
password=self.password,
|
||||||
create_user=True)
|
create_user=True)
|
||||||
new_count = self.manager._get_user_pool().count()
|
new_count = len(self.manager._get_user_pool())
|
||||||
self.assertNotEqual(old_count, new_count)
|
self.assertNotEqual(old_count, new_count)
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class VirtualMachineTestCase(TestCase):
|
||||||
"""Define the test client and other test variables."""
|
"""Define the test client and other test variables."""
|
||||||
self.manager = OpenNebulaManager(email=None, password=None, create_user=False)
|
self.manager = OpenNebulaManager(email=None, password=None, create_user=False)
|
||||||
self.template = VirtualMachineTemplate.objects.first()
|
self.template = VirtualMachineTemplate.objects.first()
|
||||||
self.template_id self.template.opennebula_id()
|
self.template_id = self.template.opennebula_id()
|
||||||
self.opennebula_id = self.manager.create_virtualmachine(template_id=self.template_id)
|
self.opennebula_id = self.manager.create_virtualmachine(template_id=self.template_id)
|
||||||
|
|
||||||
self.virtualmachine = VirtualMachine(opennebula_id=self.opennebula_id,
|
self.virtualmachine = VirtualMachine(opennebula_id=self.opennebula_id,
|
||||||
|
|
Loading…
Reference in a new issue