summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodolfo Carvalho <rhcarvalho@gmail.com>2017-02-18 03:34:44 +0100
committerRodolfo Carvalho <rhcarvalho@gmail.com>2017-02-20 17:13:52 +0100
commit8c0c5384341fb0a0ab70b4770c44a799178c90af (patch)
tree1ef6e5e585f4cce23f40868c70048201d97b7373
parent7887248c3b3af3733622d53e89af5afacad72e67 (diff)
downloadopenshift-8c0c5384341fb0a0ab70b4770c44a799178c90af.tar.gz
openshift-8c0c5384341fb0a0ab70b4770c44a799178c90af.tar.bz2
openshift-8c0c5384341fb0a0ab70b4770c44a799178c90af.tar.xz
openshift-8c0c5384341fb0a0ab70b4770c44a799178c90af.zip
Reorganize tests and helper functions logically
This is intented to make it easier to read tests top-down. The test methods in both files are sorted somehow logically, and in the same order in both files, to help visualizing the similarities between them with diff tools.
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py130
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py128
2 files changed, 129 insertions, 129 deletions
diff --git a/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py b/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
index ec1120bd5..a33c183f6 100644
--- a/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
+++ b/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
@@ -96,6 +96,56 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
}
}
+ def test_openshift_version(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ release = release + '.1'
+ yield self.check_defaults_version, release, deployment_type, default_predicates, regions_enabled
+
+ def check_defaults_version(self, version, deployment_type, default_predicates,
+ regions_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift_version'] = version
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts,
+ regions_enabled=regions_enabled)
+ if regions_enabled:
+ assert_equal(results, default_predicates + [REGION_PREDICATE])
+ else:
+ assert_equal(results, default_predicates)
+
+ def test_release_defaults(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_release, release, deployment_type, default_predicates, regions_enabled
+
+ def test_v_release_defaults(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_release, 'v' + release, deployment_type, default_predicates, regions_enabled
+
+ def test_trunc_openshift_release(self):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ release = release + '.1'
+ yield self.check_defaults_release, release, deployment_type, default_predicates, False
+
+ def check_defaults_release(self, release, deployment_type, default_predicates,
+ regions_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift_release'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts,
+ regions_enabled=regions_enabled)
+ if regions_enabled:
+ assert_equal(results, default_predicates + [REGION_PREDICATE])
+ else:
+ assert_equal(results, default_predicates)
+
+ def test_short_version_defaults(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_short_version, release, deployment_type, default_predicates, regions_enabled
+
def check_defaults_short_version(self, short_version, deployment_type, default_predicates,
regions_enabled):
facts = copy.deepcopy(self.default_facts)
@@ -108,6 +158,11 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
else:
assert_equal(results, default_predicates)
+ def test_short_version_kwarg(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_short_version_kwarg, release, deployment_type, default_predicates, regions_enabled
+
def check_defaults_short_version_kwarg(self, short_version, deployment_type, default_predicates,
regions_enabled):
facts = copy.deepcopy(self.default_facts)
@@ -120,6 +175,11 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
else:
assert_equal(results, default_predicates)
+ def test_deployment_type_kwarg(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_deployment_type_kwarg, release, deployment_type, default_predicates, regions_enabled
+
def check_defaults_deployment_type_kwarg(self, short_version, deployment_type,
default_predicates, regions_enabled):
facts = copy.deepcopy(self.default_facts)
@@ -132,6 +192,11 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
else:
assert_equal(results, default_predicates)
+ def test_only_kwargs(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_only_kwargs, release, deployment_type, default_predicates, regions_enabled
+
def check_defaults_only_kwargs(self, short_version, deployment_type,
default_predicates, regions_enabled):
facts = copy.deepcopy(self.default_facts)
@@ -143,68 +208,3 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
assert_equal(results, default_predicates + [REGION_PREDICATE])
else:
assert_equal(results, default_predicates)
-
- def check_defaults_release(self, release, deployment_type, default_predicates,
- regions_enabled):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift_release'] = release
- facts['openshift']['common']['deployment_type'] = deployment_type
- results = self.lookup.run(None, variables=facts,
- regions_enabled=regions_enabled)
- if regions_enabled:
- assert_equal(results, default_predicates + [REGION_PREDICATE])
- else:
- assert_equal(results, default_predicates)
-
- def check_defaults_version(self, version, deployment_type, default_predicates,
- regions_enabled):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift_version'] = version
- facts['openshift']['common']['deployment_type'] = deployment_type
- results = self.lookup.run(None, variables=facts,
- regions_enabled=regions_enabled)
- if regions_enabled:
- assert_equal(results, default_predicates + [REGION_PREDICATE])
- else:
- assert_equal(results, default_predicates)
-
- def test_openshift_version(self):
- for regions_enabled in (True, False):
- for release, deployment_type, default_predicates in TEST_VARS:
- release = release + '.1'
- yield self.check_defaults_version, release, deployment_type, default_predicates, regions_enabled
-
- def test_v_release_defaults(self):
- for regions_enabled in (True, False):
- for release, deployment_type, default_predicates in TEST_VARS:
- yield self.check_defaults_release, 'v' + release, deployment_type, default_predicates, regions_enabled
-
- def test_release_defaults(self):
- for regions_enabled in (True, False):
- for release, deployment_type, default_predicates in TEST_VARS:
- yield self.check_defaults_release, release, deployment_type, default_predicates, regions_enabled
-
- def test_short_version_defaults(self):
- for regions_enabled in (True, False):
- for release, deployment_type, default_predicates in TEST_VARS:
- yield self.check_defaults_short_version, release, deployment_type, default_predicates, regions_enabled
-
- def test_short_version_kwarg(self):
- for regions_enabled in (True, False):
- for release, deployment_type, default_predicates in TEST_VARS:
- yield self.check_defaults_short_version_kwarg, release, deployment_type, default_predicates, regions_enabled
-
- def test_only_kwargs(self):
- for regions_enabled in (True, False):
- for release, deployment_type, default_predicates in TEST_VARS:
- yield self.check_defaults_only_kwargs, release, deployment_type, default_predicates, regions_enabled
-
- def test_deployment_type_kwarg(self):
- for regions_enabled in (True, False):
- for release, deployment_type, default_predicates in TEST_VARS:
- yield self.check_defaults_deployment_type_kwarg, release, deployment_type, default_predicates, regions_enabled
-
- def test_trunc_openshift_release(self):
- for release, deployment_type, default_predicates in TEST_VARS:
- release = release + '.1'
- yield self.check_defaults_release, release, deployment_type, default_predicates, False
diff --git a/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py b/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
index 974cc1d0c..326af3e13 100644
--- a/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
+++ b/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
@@ -84,6 +84,55 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
}
}
+ def test_openshift_version(self):
+ for zones_enabled in (True, False):
+ for release, deployment_type, default_priorities in TEST_VARS:
+ release = release + '.1'
+ yield self.check_defaults_version, release, deployment_type, default_priorities, zones_enabled
+
+ def check_defaults_version(self, release, deployment_type, default_priorities,
+ zones_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift_version'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts, zones_enabled=zones_enabled)
+ if zones_enabled:
+ assert_equal(results, default_priorities + [ZONE_PRIORITY])
+ else:
+ assert_equal(results, default_priorities)
+
+ def test_release_defaults(self):
+ for zones_enabled in (True, False):
+ for release, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_release, release, deployment_type, default_priorities, zones_enabled
+
+ def test_v_release_defaults(self):
+ for zones_enabled in (True, False):
+ for release, deployment_type, default_priorities in TEST_VARS:
+ release = 'v' + release
+ yield self.check_defaults_release, release, deployment_type, default_priorities, zones_enabled
+
+ def test_trunc_openshift_release(self):
+ for release, deployment_type, default_priorities in TEST_VARS:
+ release = release + '.1'
+ yield self.check_defaults_release, release, deployment_type, default_priorities, False
+
+ def check_defaults_release(self, release, deployment_type, default_priorities,
+ zones_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift_release'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts, zones_enabled=zones_enabled)
+ if zones_enabled:
+ assert_equal(results, default_priorities + [ZONE_PRIORITY])
+ else:
+ assert_equal(results, default_priorities)
+
+ def test_short_version_defaults(self):
+ for zones_enabled in (True, False):
+ for short_version, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_short_version, short_version, deployment_type, default_priorities, zones_enabled
+
def check_defaults_short_version(self, release, deployment_type,
default_priorities, zones_enabled):
facts = copy.deepcopy(self.default_facts)
@@ -95,6 +144,11 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
else:
assert_equal(results, default_priorities)
+ def test_release_kwarg(self):
+ for zones_enabled in (True, False):
+ for short_version, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_short_version_kwarg, short_version, deployment_type, default_priorities, zones_enabled
+
def check_defaults_short_version_kwarg(self, release, deployment_type,
default_priorities, zones_enabled):
facts = copy.deepcopy(self.default_facts)
@@ -107,6 +161,11 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
else:
assert_equal(results, default_priorities)
+ def test_deployment_type_kwarg(self):
+ for zones_enabled in (True, False):
+ for short_version, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_deployment_type_kwarg, short_version, deployment_type, default_priorities, zones_enabled
+
def check_defaults_deployment_type_kwarg(self, release, deployment_type,
default_priorities, zones_enabled):
facts = copy.deepcopy(self.default_facts)
@@ -119,6 +178,11 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
else:
assert_equal(results, default_priorities)
+ def test_only_kwargs(self):
+ for zones_enabled in (True, False):
+ for short_version, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_only_kwargs, short_version, deployment_type, default_priorities, zones_enabled
+
def check_defaults_only_kwargs(self, release, deployment_type,
default_priorities, zones_enabled):
facts = copy.deepcopy(self.default_facts)
@@ -130,67 +194,3 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
assert_equal(results, default_priorities + [ZONE_PRIORITY])
else:
assert_equal(results, default_priorities)
-
- def check_defaults_release(self, release, deployment_type, default_priorities,
- zones_enabled):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift_release'] = release
- facts['openshift']['common']['deployment_type'] = deployment_type
- results = self.lookup.run(None, variables=facts, zones_enabled=zones_enabled)
- if zones_enabled:
- assert_equal(results, default_priorities + [ZONE_PRIORITY])
- else:
- assert_equal(results, default_priorities)
-
- def check_defaults_version(self, release, deployment_type, default_priorities,
- zones_enabled):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift_version'] = release
- facts['openshift']['common']['deployment_type'] = deployment_type
- results = self.lookup.run(None, variables=facts, zones_enabled=zones_enabled)
- if zones_enabled:
- assert_equal(results, default_priorities + [ZONE_PRIORITY])
- else:
- assert_equal(results, default_priorities)
-
- def test_openshift_version(self):
- for zones_enabled in (True, False):
- for release, deployment_type, default_priorities in TEST_VARS:
- release = release + '.1'
- yield self.check_defaults_version, release, deployment_type, default_priorities, zones_enabled
-
- def test_v_release_defaults(self):
- for zones_enabled in (True, False):
- for release, deployment_type, default_priorities in TEST_VARS:
- release = 'v' + release
- yield self.check_defaults_release, release, deployment_type, default_priorities, zones_enabled
-
- def test_release_defaults(self):
- for zones_enabled in (True, False):
- for release, deployment_type, default_priorities in TEST_VARS:
- yield self.check_defaults_release, release, deployment_type, default_priorities, zones_enabled
-
- def test_short_version_defaults(self):
- for zones_enabled in (True, False):
- for short_version, deployment_type, default_priorities in TEST_VARS:
- yield self.check_defaults_short_version, short_version, deployment_type, default_priorities, zones_enabled
-
- def test_only_kwargs(self):
- for zones_enabled in (True, False):
- for short_version, deployment_type, default_priorities in TEST_VARS:
- yield self.check_defaults_only_kwargs, short_version, deployment_type, default_priorities, zones_enabled
-
- def test_deployment_type_kwarg(self):
- for zones_enabled in (True, False):
- for short_version, deployment_type, default_priorities in TEST_VARS:
- yield self.check_defaults_deployment_type_kwarg, short_version, deployment_type, default_priorities, zones_enabled
-
- def test_release_kwarg(self):
- for zones_enabled in (True, False):
- for short_version, deployment_type, default_priorities in TEST_VARS:
- yield self.check_defaults_short_version_kwarg, short_version, deployment_type, default_priorities, zones_enabled
-
- def test_trunc_openshift_release(self):
- for release, deployment_type, default_priorities in TEST_VARS:
- release = release + '.1'
- yield self.check_defaults_release, release, deployment_type, default_priorities, False