From 714849fb490b104dca62e8ac1d9c01533afd92af Mon Sep 17 00:00:00 2001 From: Modulos Date: Tue, 9 May 2017 17:15:12 +0200 Subject: [PATCH] Fix test_model_can_create_user --- opennebula_api/models.py | 4 ++++ opennebula_api/tests.py | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/opennebula_api/models.py b/opennebula_api/models.py index 83273767..53fbb6c5 100644 --- a/opennebula_api/models.py +++ b/opennebula_api/models.py @@ -68,3 +68,7 @@ class OpenNebulaManager(): opennebula_user = self.oneadmin_client.call(oca.User.METHODS['allocate'], email, password, 'core') return opennebula_user + def _get_user_pool(self): + user_pool = oca.UserPool(self.oneadmin_client) + user_pool.info() + return user_pool diff --git a/opennebula_api/tests.py b/opennebula_api/tests.py index ab70854f..95d9d08d 100644 --- a/opennebula_api/tests.py +++ b/opennebula_api/tests.py @@ -1,5 +1,5 @@ from django.test import TestCase -from .models import VirtualMachine +from .models import VirtualMachine, VirtualMachineTemplate, OpenNebulaManager class OpenNebulaManagerTestCases(TestCase): """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): """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, password=self.password, 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) @@ -69,7 +69,7 @@ class VirtualMachineTestCase(TestCase): """Define the test client and other test variables.""" self.manager = OpenNebulaManager(email=None, password=None, create_user=False) 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.virtualmachine = VirtualMachine(opennebula_id=self.opennebula_id,