1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import pytest
- from openshift_checks.package_availability import PackageAvailability
- @pytest.mark.parametrize('pkg_mgr,is_containerized,is_active', [
- ('yum', False, True),
- ('yum', True, False),
- ('dnf', True, False),
- ('dnf', False, False),
- ])
- def test_is_active(pkg_mgr, is_containerized, is_active):
- task_vars = dict(
- ansible_pkg_mgr=pkg_mgr,
- openshift=dict(common=dict(is_containerized=is_containerized)),
- )
- assert PackageAvailability(None, task_vars).is_active() == is_active
- @pytest.mark.parametrize('task_vars,must_have_packages,must_not_have_packages', [
- (
- dict(openshift_service_type='origin'),
- set(),
- set(['openshift-master', 'openshift-node']),
- ),
- (
- dict(
- openshift_service_type='origin',
- group_names=['oo_masters_to_config'],
- ),
- set(['origin-master']),
- set(['origin-node']),
- ),
- (
- dict(
- openshift_service_type='atomic-openshift',
- group_names=['oo_nodes_to_config'],
- ),
- set(['atomic-openshift-node']),
- set(['atomic-openshift-master']),
- ),
- (
- dict(
- openshift_service_type='atomic-openshift',
- group_names=['oo_masters_to_config', 'oo_nodes_to_config'],
- ),
- set(['atomic-openshift-master', 'atomic-openshift-node']),
- set(),
- ),
- ])
- def test_package_availability(task_vars, must_have_packages, must_not_have_packages):
- return_value = {}
- def execute_module(module_name=None, module_args=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 {'foo': return_value}
- result = PackageAvailability(execute_module, task_vars).run()
- assert result['foo'] is return_value
|