diff options
author | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-03-24 22:09:00 +0100 |
---|---|---|
committer | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-03-28 11:54:52 +0200 |
commit | a39620a07602db95d0d59702a9a5466b270a2be8 (patch) | |
tree | e1d56f1132ecaf89bf691c91bd3cc8fbb79be7fb | |
parent | 209810c9905c0ebf89b1e03ccb8593f78a6e5396 (diff) | |
download | openshift-a39620a07602db95d0d59702a9a5466b270a2be8.tar.gz openshift-a39620a07602db95d0d59702a9a5466b270a2be8.tar.bz2 openshift-a39620a07602db95d0d59702a9a5466b270a2be8.tar.xz openshift-a39620a07602db95d0d59702a9a5466b270a2be8.zip |
Add unit tests for package_availability.py
-rw-r--r-- | roles/openshift_health_checker/test/package_availability_test.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/roles/openshift_health_checker/test/package_availability_test.py b/roles/openshift_health_checker/test/package_availability_test.py new file mode 100644 index 000000000..25385339a --- /dev/null +++ b/roles/openshift_health_checker/test/package_availability_test.py @@ -0,0 +1,49 @@ +import pytest + +from openshift_checks.package_availability import PackageAvailability + + +@pytest.mark.parametrize('task_vars,must_have_packages,must_not_have_packages', [ + ( + dict(openshift=dict(common=dict(service_type='openshift'))), + set(), + set(['openshift-master', 'openshift-node']), + ), + ( + dict( + openshift=dict(common=dict(service_type='origin')), + group_names=['masters'], + ), + set(['origin-master']), + set(['origin-node']), + ), + ( + dict( + openshift=dict(common=dict(service_type='atomic-openshift')), + group_names=['nodes'], + ), + set(['atomic-openshift-node']), + set(['atomic-openshift-master']), + ), + ( + dict( + openshift=dict(common=dict(service_type='atomic-openshift')), + group_names=['masters', 'nodes'], + ), + set(['atomic-openshift-master', 'atomic-openshift-node']), + set(), + ), +]) +def test_package_availability(task_vars, must_have_packages, must_not_have_packages): + return_value = object() + + def execute_module(module_name=None, module_args=None, tmp=None, task_vars=None): + assert module_name == 'check_yum_update' + assert 'packages' in module_args + assert set(module_args['packages']).issuperset(must_have_packages) + assert not set(module_args['packages']).intersection(must_not_have_packages) + return return_value + + check = PackageAvailability(execute_module=execute_module) + result = check.run(tmp=None, task_vars=task_vars) + assert result is return_value |