summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorRodolfo Carvalho <rhcarvalho@gmail.com>2017-02-18 04:25:32 +0100
committerRodolfo Carvalho <rhcarvalho@gmail.com>2017-02-20 17:13:52 +0100
commit95f11aa9410c8db4794b51932931e6ee3da46402 (patch)
tree44738bd6e8a69000743fad7205823fe522994cde /roles
parentc008153397d5a34a21301cb5dabb6fe27df2fe47 (diff)
downloadopenshift-95f11aa9410c8db4794b51932931e6ee3da46402.tar.gz
openshift-95f11aa9410c8db4794b51932931e6ee3da46402.tar.bz2
openshift-95f11aa9410c8db4794b51932931e6ee3da46402.tar.xz
openshift-95f11aa9410c8db4794b51932931e6ee3da46402.zip
Make tests run with either nosetests or pytest
And remove explicit dependencies on nose, replacing with pytest. The former is the way forward, for it is a better maintained test library, and a transitive dependency of `molecule`, the test framework we're using to add integration tests to this repo (work in progress).
Diffstat (limited to 'roles')
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py65
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py11
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py11
3 files changed, 42 insertions, 45 deletions
diff --git a/roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py b/roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py
index ec6c7ae4a..e8da1e04a 100644
--- a/roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py
+++ b/roles/openshift_master_facts/test/openshift_master_facts_bad_input_tests.py
@@ -3,7 +3,7 @@ import os
import sys
from ansible.errors import AnsibleError
-from nose.tools import raises
+import pytest
sys.path.insert(1, os.path.join(os.path.dirname(__file__), os.pardir, "lookup_plugins"))
@@ -11,48 +11,47 @@ from openshift_master_facts_default_predicates import LookupModule # noqa: E402
class TestOpenShiftMasterFactsBadInput(object):
- def setUp(self):
- self.lookup = LookupModule()
- self.default_facts = {
- 'openshift': {
- 'common': {}
- }
+ lookup = LookupModule()
+ default_facts = {
+ 'openshift': {
+ 'common': {}
}
+ }
- @raises(AnsibleError)
def test_missing_openshift_facts(self):
- facts = {}
- self.lookup.run(None, variables=facts)
+ with pytest.raises(AnsibleError):
+ facts = {}
+ self.lookup.run(None, variables=facts)
- @raises(AnsibleError)
def test_missing_deployment_type(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '10.10'
- self.lookup.run(None, variables=facts)
+ with pytest.raises(AnsibleError):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '10.10'
+ self.lookup.run(None, variables=facts)
- @raises(AnsibleError)
def test_missing_short_version_and_missing_openshift_release(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['deployment_type'] = 'origin'
- self.lookup.run(None, variables=facts)
+ with pytest.raises(AnsibleError):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['deployment_type'] = 'origin'
+ self.lookup.run(None, variables=facts)
- @raises(AnsibleError)
def test_unknown_deployment_types(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '1.1'
- facts['openshift']['common']['deployment_type'] = 'bogus'
- self.lookup.run(None, variables=facts)
+ with pytest.raises(AnsibleError):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '1.1'
+ facts['openshift']['common']['deployment_type'] = 'bogus'
+ self.lookup.run(None, variables=facts)
- @raises(AnsibleError)
def test_unknown_origin_version(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '0.1'
- facts['openshift']['common']['deployment_type'] = 'origin'
- self.lookup.run(None, variables=facts)
+ with pytest.raises(AnsibleError):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '0.1'
+ facts['openshift']['common']['deployment_type'] = 'origin'
+ self.lookup.run(None, variables=facts)
- @raises(AnsibleError)
def test_unknown_ocp_version(self):
- facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '0.1'
- facts['openshift']['common']['deployment_type'] = 'openshift-enterprise'
- self.lookup.run(None, variables=facts)
+ with pytest.raises(AnsibleError):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '0.1'
+ facts['openshift']['common']['deployment_type'] = 'openshift-enterprise'
+ self.lookup.run(None, variables=facts)
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 855f42273..51547ce7e 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
@@ -86,13 +86,12 @@ TEST_VARS = [
class TestOpenShiftMasterFactsDefaultPredicates(object):
- def setUp(self):
- self.lookup = LookupModule()
- self.default_facts = {
- 'openshift': {
- 'common': {}
- }
+ lookup = LookupModule()
+ default_facts = {
+ 'openshift': {
+ 'common': {}
}
+ }
def test_openshift_version(self):
for regions_enabled in (True, 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 d27a48ede..4fb900b98 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
@@ -74,13 +74,12 @@ TEST_VARS = [
class TestOpenShiftMasterFactsDefaultPredicates(object):
- def setUp(self):
- self.lookup = LookupModule()
- self.default_facts = {
- 'openshift': {
- 'common': {}
- }
+ lookup = LookupModule()
+ default_facts = {
+ 'openshift': {
+ 'common': {}
}
+ }
def test_openshift_version(self):
for zones_enabled in (True, False):