Replace assertDictContainsSubset

assertDictContainsSubset was removed in Python 3.12 .

Change-Id: Ib3a972eeab0ffe7719d108db351be82a84c8226d
This commit is contained in:
Takashi Kajinami 2024-11-19 13:00:16 +09:00
parent 3be0254144
commit 17f775e1e0
3 changed files with 21 additions and 21 deletions

View File

@ -63,7 +63,7 @@ class TelemetryAlarmingAPIAdminTest(base.BaseAlarmingAdminTest):
alarm_actions=alarm_actions)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(self.rule, body['event_rule'])
self.assertLessEqual(self.rule.items(), body['event_rule'].items())
self.assertEqual(['test:', 'log:'], body['alarm_actions'])
# Verify not seen by non-admin
@ -84,7 +84,7 @@ class TelemetryAlarmingAPIAdminTest(base.BaseAlarmingAdminTest):
event_rule=self.rule)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(self.rule, body['event_rule'])
self.assertLessEqual(self.rule.items(), body['event_rule'].items())
# Verify initial state as non-admin
body = self.alarming_client.show_alarm(alarm_id)

View File

@ -51,9 +51,9 @@ class TelemetryAlarmingAPIGnocchiTest(base.BaseAlarmingTest):
)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(
rule,
body['gnocchi_aggregation_by_metrics_threshold_rule'])
self.assertLessEqual(
rule.items(),
body['gnocchi_aggregation_by_metrics_threshold_rule'].items())
# Update alarm with same rule and name
body = self.alarming_client.update_alarm(
@ -63,9 +63,9 @@ class TelemetryAlarmingAPIGnocchiTest(base.BaseAlarmingTest):
type='gnocchi_aggregation_by_metrics_threshold',
gnocchi_aggregation_by_metrics_threshold_rule=rule)
self.assertEqual(alarm_name, body['name'])
self.assertDictContainsSubset(
rule,
body['gnocchi_aggregation_by_metrics_threshold_rule'])
self.assertLessEqual(
rule.items(),
body['gnocchi_aggregation_by_metrics_threshold_rule'].items())
# Update alarm with new rule and new name
new_rule = {'metrics': ['41869681-5776-46d6-91ed-cccc43b6e4e3',
@ -81,9 +81,9 @@ class TelemetryAlarmingAPIGnocchiTest(base.BaseAlarmingTest):
type='gnocchi_aggregation_by_metrics_threshold',
gnocchi_aggregation_by_metrics_threshold_rule=new_rule)
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(
new_rule,
body['gnocchi_aggregation_by_metrics_threshold_rule'])
self.assertLessEqual(
new_rule.items(),
body['gnocchi_aggregation_by_metrics_threshold_rule'].items())
# Update severity
body = self.alarming_client.update_alarm(
@ -97,9 +97,9 @@ class TelemetryAlarmingAPIGnocchiTest(base.BaseAlarmingTest):
# Get and verify details of an alarm after update
body = self.alarming_client.show_alarm(alarm_id)
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(
new_rule,
body['gnocchi_aggregation_by_metrics_threshold_rule'])
self.assertLessEqual(
new_rule.items(),
body['gnocchi_aggregation_by_metrics_threshold_rule'].items())
self.assertEqual('low', body['severity'])
# Get history for the alarm and verify the same

View File

@ -61,7 +61,7 @@ class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
event_rule=self.rule)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(self.rule, body['event_rule'])
self.assertLessEqual(self.rule.items(), body['event_rule'].items())
# Update alarm with same rule and name
body = self.alarming_client.update_alarm(
@ -70,7 +70,7 @@ class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
name=alarm_name,
type='event')
self.assertEqual(alarm_name, body['name'])
self.assertDictContainsSubset(self.rule, body['event_rule'])
self.assertLessEqual(self.rule.items(), body['event_rule'].items())
# Update alarm with new rule and new name
new_rule = {
@ -88,7 +88,7 @@ class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
name=alarm_name_updated,
type='event')
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(new_rule, body['event_rule'])
self.assertLessEqual(new_rule.items(), body['event_rule'].items())
# Update severity
body = self.alarming_client.update_alarm(
@ -101,7 +101,7 @@ class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
# Get and verify details of an alarm after update
body = self.alarming_client.show_alarm(alarm_id)
self.assertEqual(alarm_name_updated, body['name'])
self.assertDictContainsSubset(new_rule, body['event_rule'])
self.assertLessEqual(new_rule.items(), body['event_rule'].items())
self.assertEqual('low', body['severity'])
# Get history for the alarm and verify the same
@ -138,7 +138,7 @@ class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
event_rule=self.rule)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(self.rule, body['event_rule'])
self.assertLessEqual(self.rule.items(), body['event_rule'].items())
self.assertFalse(body['enabled'])
# Query by enabled false and verify
@ -162,7 +162,7 @@ class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
event_rule=self.rule)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(self.rule, body['event_rule'])
self.assertLessEqual(self.rule.items(), body['event_rule'].items())
# Verify default
expected_defaults = {
@ -189,7 +189,7 @@ class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
event_rule=self.rule)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(self.rule, body['event_rule'])
self.assertLessEqual(self.rule.items(), body['event_rule'].items())
# Verify initial state
body = self.alarming_client.show_alarm(alarm_id)