package_availability_test.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import pytest
  2. from openshift_checks.package_availability import PackageAvailability
  3. @pytest.mark.parametrize('pkg_mgr,openshift_is_atomic,is_active', [
  4. ('yum', False, True),
  5. ('yum', True, False),
  6. ('dnf', True, False),
  7. ('dnf', False, False),
  8. ])
  9. def test_is_active(pkg_mgr, openshift_is_atomic, is_active):
  10. task_vars = dict(
  11. ansible_pkg_mgr=pkg_mgr,
  12. openshift_is_atomic=openshift_is_atomic,
  13. )
  14. assert PackageAvailability(None, task_vars).is_active() == is_active
  15. @pytest.mark.parametrize('task_vars,must_have_packages,must_not_have_packages', [
  16. (
  17. dict(openshift_service_type='origin'),
  18. set(),
  19. set(['openshift-master', 'openshift-node']),
  20. ),
  21. (
  22. dict(
  23. openshift_service_type='origin',
  24. group_names=['oo_masters_to_config'],
  25. ),
  26. set(['origin-master']),
  27. set(['origin-node']),
  28. ),
  29. (
  30. dict(
  31. openshift_service_type='atomic-openshift',
  32. group_names=['oo_nodes_to_config'],
  33. ),
  34. set(['atomic-openshift-node']),
  35. set(['atomic-openshift-master']),
  36. ),
  37. (
  38. dict(
  39. openshift_service_type='atomic-openshift',
  40. group_names=['oo_masters_to_config', 'oo_nodes_to_config'],
  41. ),
  42. set(['atomic-openshift-master', 'atomic-openshift-node']),
  43. set(),
  44. ),
  45. ])
  46. def test_package_availability(task_vars, must_have_packages, must_not_have_packages):
  47. return_value = {}
  48. def execute_module(module_name=None, module_args=None, *_):
  49. assert module_name == 'check_yum_update'
  50. assert 'packages' in module_args
  51. assert set(module_args['packages']).issuperset(must_have_packages)
  52. assert not set(module_args['packages']).intersection(must_not_have_packages)
  53. return {'foo': return_value}
  54. result = PackageAvailability(execute_module, task_vars).run()
  55. assert result['foo'] is return_value