Fix unit tests.
The type `bool` is incorrect, it should be `boolean` instead, also now the `ops` package does a more strict check of the type of the values passed via update_config() so this change replaces 'True' with True, and 'False' with False. Change-Id: I2fcbfb4f3cebd0819ca1d79a6cbec378a9dedc00
This commit is contained in:
parent
35237c71f4
commit
cf182d849d
@ -36,7 +36,7 @@ class OpenStackTestPlugin1(ops_openstack.core.OSBaseCharm):
|
|||||||
super().register_status_check(self.plugin1_status_check)
|
super().register_status_check(self.plugin1_status_check)
|
||||||
|
|
||||||
def plugin1_status_check(self):
|
def plugin1_status_check(self):
|
||||||
if self.model.config.get('plugin1-check-fail', 'False') == 'True':
|
if self.model.config.get('plugin1-check-fail', False):
|
||||||
return BlockedStatus(
|
return BlockedStatus(
|
||||||
'Plugin1 Custom check failed')
|
'Plugin1 Custom check failed')
|
||||||
else:
|
else:
|
||||||
@ -50,7 +50,7 @@ class OpenStackTestPlugin2(ops_openstack.core.OSBaseCharm):
|
|||||||
super().register_status_check(self.plugin2_status_check)
|
super().register_status_check(self.plugin2_status_check)
|
||||||
|
|
||||||
def plugin2_status_check(self):
|
def plugin2_status_check(self):
|
||||||
if self.model.config.get('plugin2-check-fail', 'False') == 'True':
|
if self.model.config.get('plugin2-check-fail', False):
|
||||||
return BlockedStatus(
|
return BlockedStatus(
|
||||||
'Plugin2 Custom check failed')
|
'Plugin2 Custom check failed')
|
||||||
else:
|
else:
|
||||||
@ -72,7 +72,7 @@ class OpenStackTestAPICharm(OpenStackTestPlugin1,
|
|||||||
super().register_status_check(self.custom_status_check)
|
super().register_status_check(self.custom_status_check)
|
||||||
|
|
||||||
def custom_status_check(self):
|
def custom_status_check(self):
|
||||||
if self.model.config.get('custom-check-fail', 'False') == 'True':
|
if self.model.config.get('custom-check-fail', False):
|
||||||
return MaintenanceStatus('Custom check failed')
|
return MaintenanceStatus('Custom check failed')
|
||||||
else:
|
else:
|
||||||
return ActiveStatus()
|
return ActiveStatus()
|
||||||
@ -140,15 +140,15 @@ class TestOSBaseCharm(CharmTestCase):
|
|||||||
default:
|
default:
|
||||||
description: a key
|
description: a key
|
||||||
custom-check-fail:
|
custom-check-fail:
|
||||||
type: bool
|
type: boolean
|
||||||
default: False
|
default: False
|
||||||
description: a failure to report in the unit status
|
description: a failure to report in the unit status
|
||||||
plugin1-check-fail:
|
plugin1-check-fail:
|
||||||
type: bool
|
type: boolean
|
||||||
default: False
|
default: False
|
||||||
description: another failure to report
|
description: another failure to report
|
||||||
plugin2-check-fail:
|
plugin2-check-fail:
|
||||||
type: bool
|
type: boolean
|
||||||
default: False
|
default: False
|
||||||
description: yet another failure to report
|
description: yet another failure to report
|
||||||
''')
|
''')
|
||||||
@ -202,7 +202,7 @@ class TestOSBaseCharm(CharmTestCase):
|
|||||||
self.os_utils.ows_check_services_running.return_value = (None, None)
|
self.os_utils.ows_check_services_running.return_value = (None, None)
|
||||||
self.harness.update_config(
|
self.harness.update_config(
|
||||||
key_values={
|
key_values={
|
||||||
'custom-check-fail': 'True'})
|
'custom-check-fail': True})
|
||||||
self.harness.add_relation('shared-db', 'mysql')
|
self.harness.add_relation('shared-db', 'mysql')
|
||||||
self.harness.begin()
|
self.harness.begin()
|
||||||
self.harness.charm._stored.is_started = True
|
self.harness.charm._stored.is_started = True
|
||||||
@ -266,8 +266,8 @@ class TestOSBaseCharm(CharmTestCase):
|
|||||||
self.os_utils.ows_check_services_running.return_value = (None, None)
|
self.os_utils.ows_check_services_running.return_value = (None, None)
|
||||||
self.harness.update_config(
|
self.harness.update_config(
|
||||||
key_values={
|
key_values={
|
||||||
'plugin1-check-fail': 'True',
|
'plugin1-check-fail': True,
|
||||||
'plugin2-check-fail': 'False'})
|
'plugin2-check-fail': False})
|
||||||
self.harness.add_relation('shared-db', 'mysql')
|
self.harness.add_relation('shared-db', 'mysql')
|
||||||
self.harness.begin()
|
self.harness.begin()
|
||||||
self.harness.charm._stored.is_started = True
|
self.harness.charm._stored.is_started = True
|
||||||
@ -280,8 +280,8 @@ class TestOSBaseCharm(CharmTestCase):
|
|||||||
BlockedStatus)
|
BlockedStatus)
|
||||||
self.harness.update_config(
|
self.harness.update_config(
|
||||||
key_values={
|
key_values={
|
||||||
'plugin1-check-fail': 'False',
|
'plugin1-check-fail': False,
|
||||||
'plugin2-check-fail': 'True'})
|
'plugin2-check-fail': True})
|
||||||
self.harness.charm.on.update_status.emit()
|
self.harness.charm.on.update_status.emit()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.harness.charm.unit.status.message,
|
self.harness.charm.unit.status.message,
|
||||||
|
Loading…
Reference in New Issue
Block a user