Improve platform mocking
Patch out charmhelpers.osplatform.get_platform() and charmhelpers.core.host.lsb_release() globally in the unit tests to insulate the unit tests from the platform that the unit tests are being run on. Change-Id: Ifda8aa2675b4a756109254f62b9a600c42679cac
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
- jammy-antelope-ec_cinder-ceph
|
||||
- jammy-bobcat-ec_cinder-ceph:
|
||||
voting: false
|
||||
- lunar-antelope-ec_cinder-ceph:
|
||||
voting: false
|
||||
- mantic-bobcat-ec_cinder-ceph:
|
||||
voting: false
|
||||
vars:
|
||||
@@ -34,13 +32,6 @@
|
||||
- jammy-antelope-ec_cinder-ceph
|
||||
vars:
|
||||
tox_extra_args: '-- jammy-bobcat-ec'
|
||||
- job:
|
||||
name: lunar-antelope-ec_cinder-ceph
|
||||
parent: func-target
|
||||
dependencies:
|
||||
- jammy-antelope-ec_cinder-ceph
|
||||
vars:
|
||||
tox_extra_args: '-- lunar-antelope-ec'
|
||||
- job:
|
||||
name: mantic-bobcat-ec_cinder-ceph
|
||||
parent: func-target
|
||||
|
@@ -14,9 +14,7 @@ gate_bundles:
|
||||
dev_bundles:
|
||||
- jammy-bobcat-ec
|
||||
- jammy-bobcat
|
||||
- lunar-antelope-ec
|
||||
- mantic-bobcat-ec
|
||||
- lunar-antelope
|
||||
- mantic-bobcat
|
||||
|
||||
configure:
|
||||
@@ -42,7 +40,5 @@ tests_options:
|
||||
policyd:
|
||||
service: cinder
|
||||
force_deploy:
|
||||
- lunar-antelope
|
||||
- mantic-bobcat
|
||||
- lunar-antelope-ec
|
||||
- mantic-bobcat-ec
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
from unittest.mock import patch
|
||||
|
||||
_path = os.path.dirname(os.path.realpath(__file__))
|
||||
_actions = os.path.abspath(os.path.join(_path, '../actions'))
|
||||
@@ -31,3 +32,15 @@ _add_path(_actions)
|
||||
_add_path(_hooks)
|
||||
_add_path(_charmhelpers)
|
||||
_add_path(_unit_tests)
|
||||
|
||||
# Patch out lsb_release() and get_platform() as unit tests should be fully
|
||||
# insulated from the underlying platform. Unit tests assume that the system is
|
||||
# ubuntu jammy.
|
||||
patch(
|
||||
'charmhelpers.osplatform.get_platform', return_value='ubuntu'
|
||||
).start()
|
||||
patch(
|
||||
'charmhelpers.core.host.lsb_release',
|
||||
return_value={
|
||||
'DISTRIB_CODENAME': 'jammy'
|
||||
}).start()
|
||||
|
Reference in New Issue
Block a user