From d466c56a176a2250dd989df3ae176f829da1a1e6 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 26 Nov 2017 01:49:54 +0100 Subject: [PATCH] Correct skipIf conditions --- hosting/test_views.py | 30 +++++++++++------------------- opennebula_api/tests.py | 11 ++++++----- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/hosting/test_views.py b/hosting/test_views.py index 30d058ad..cc29183b 100644 --- a/hosting/test_views.py +++ b/hosting/test_views.py @@ -22,6 +22,12 @@ from .views import ( from utils.tests import BaseTestCase +@skipIf( + (settings.OPENNEBULA_DOMAIN is None or + settings.OPENNEBULA_DOMAIN == "test_domain"), + """OpenNebula details unavailable, so skipping + ProcessVMSelectionTestMixin""" +) class ProcessVMSelectionTestMixin(object): def url_resolve_to_view_correctly(self): @@ -29,6 +35,7 @@ class ProcessVMSelectionTestMixin(object): self.assertEqual(found.func.__name__, self.view.__name__) def test_get(self): + print( "Domain = " + settings.OPENNEBULA_DOMAIN) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) # self.assertEqual(self.view.get_context_data(), self.expected_context) @@ -42,11 +49,6 @@ class ProcessVMSelectionTestMixin(object): # status_code=302, target_status_code=200) -@skipIf( - settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is - "test_domain", - """OpenNebula details unavailable, so skipping DjangoHostingViewTest""" -) class DjangoHostingViewTest(TestCase, ProcessVMSelectionTestMixin): def setUp(self): @@ -67,11 +69,6 @@ class DjangoHostingViewTest(TestCase, ProcessVMSelectionTestMixin): } -@skipIf( - settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is - "test_domain", - """OpenNebula details unavailable, so skipping RailsHostingViewTest""" -) class RailsHostingViewTest(TestCase, ProcessVMSelectionTestMixin): def setUp(self): @@ -92,11 +89,6 @@ class RailsHostingViewTest(TestCase, ProcessVMSelectionTestMixin): } -@skipIf( - settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is - "test_domain", - """OpenNebula details unavailable, so skipping NodeJSHostingViewTest""" -) class NodeJSHostingViewTest(TestCase, ProcessVMSelectionTestMixin): def setUp(self): @@ -116,11 +108,11 @@ class NodeJSHostingViewTest(TestCase, ProcessVMSelectionTestMixin): # 'vm_types': VirtualMachineType.get_serialized_vm_types(), } - @skipIf( - settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is - "test_domain", - """OpenNebula details unavailable, so skipping HostingPricingViewTest""" + (settings.OPENNEBULA_DOMAIN is None or + settings.OPENNEBULA_DOMAIN == "test_domain"), + """OpenNebula details unavailable, so skipping + HostingPricingViewTest.test_get""" ) class HostingPricingViewTest(TestCase): diff --git a/opennebula_api/tests.py b/opennebula_api/tests.py index c521a7df..234e0c16 100644 --- a/opennebula_api/tests.py +++ b/opennebula_api/tests.py @@ -11,8 +11,8 @@ from utils.models import CustomUser @skipIf( - settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is - "test_domain", + settings.OPENNEBULA_DOMAIN is None or + settings.OPENNEBULA_DOMAIN == "test_domain", """OpenNebula details unavailable, so skipping OpenNebulaManagerTestCases""" ) @@ -129,8 +129,8 @@ class OpenNebulaManagerTestCases(TestCase): @skipIf( - settings.OPENNEBULA_DOMAIN is None or settings.OPENNEBULA_DOMAIN is - "test_domain", + settings.OPENNEBULA_DOMAIN is None or + settings.OPENNEBULA_DOMAIN == "test_domain", """OpenNebula details unavailable, so skipping VirtualMachineSerializerTestCase""" ) @@ -140,7 +140,8 @@ class VirtualMachineSerializerTestCase(TestCase): self.manager = OpenNebulaManager(email=None, password=None) def test_serializer_strips_of_public(self): - """ Test the serialized virtual machine object contains no 'public-'.""" + """ Test the serialized virtual machine object contains no + 'public-'.""" for vm in self.manager.get_vms(): serialized = VirtualMachineSerializer(vm)