trivial: Fix error message for non-matching policy checks
This patch set ensures that the sets of the expected and actual policies are dumped out for any failed policy check that happens automatically within control tests. This is to make policy mismatch errors a little easier to debug: For example, if expected is ['foo', 'bar'] and actual is ['foo', 'foo', 'bar', 'baz'] it means that the expected should be changed to ['foo', bar', 'baz'] but this is not immediately apparent without taking the set of each list. Change-Id: I3178e323ac780b2c3c81f7d9ba72aa6b171338f1
This commit is contained in:
parent
d170177426
commit
64c460e685
@ -106,8 +106,9 @@ class RealPolicyFixture(fixtures.Fixture):
|
||||
"""Validate that the expected and actual policies are equivalent.
|
||||
Otherwise an ``AssertionError`` is raised.
|
||||
"""
|
||||
if not (set(self.expected_policy_actions) ==
|
||||
set(self.actual_policy_actions)):
|
||||
expected_policies = set(self.expected_policy_actions)
|
||||
actual_policies = set(self.actual_policy_actions)
|
||||
if expected_policies != actual_policies:
|
||||
error_msg = (
|
||||
'The expected policy actions passed to '
|
||||
'`self.policy.set_rules` do not match the policy actions '
|
||||
@ -115,8 +116,8 @@ class RealPolicyFixture(fixtures.Fixture):
|
||||
'policies %s should be equal to set of actual policies: %s. '
|
||||
'There is either a bug with the test or with policy '
|
||||
'enforcement in the controller.' % (
|
||||
self.expected_policy_actions,
|
||||
self.actual_policy_actions)
|
||||
expected_policies,
|
||||
actual_policies)
|
||||
)
|
||||
raise AssertionError(error_msg)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user