account_auditor: fix warning string

The warning string should refer to account not container.

Also, add the account name to the warning string.

Change-Id: I6e7058eb9f5ed4298b5055d46dafb66d24ec5d09
This commit is contained in:
Alistair Coles 2022-11-16 18:20:33 +00:00
parent 26c86c0e41
commit 983622d512
2 changed files with 7 additions and 5 deletions

View File

@ -41,6 +41,7 @@ class AccountAuditor(DatabaseAuditor):
if policy_totals[key] == info[key]:
continue
return InvalidAccountInfo(
'The total %(key)s for the container (%(total)s) does not '
'match the sum of %(key)s across policies (%(sum)s)'
% {'key': key, 'total': info[key], 'sum': policy_totals[key]})
'The total %(key)s for the account %(account)s (%(total)s) '
'does not match the sum of %(key)s across policies (%(sum)s)'
% {'key': key, 'account': info.get('account'),
'total': info[key], 'sum': policy_totals[key]})

View File

@ -125,8 +125,9 @@ class TestAuditorRealBroker(unittest.TestCase):
self.assertEqual(len(error_lines), 1)
error_message = error_lines[0]
self.assertIn(broker.db_file, error_message)
self.assertIn('container_count', error_message)
self.assertIn('does not match', error_message)
self.assertIn(
'The total container_count for the account a (3) does not match '
'the sum of container_count across policies (2)', error_message)
self.assertEqual(test_auditor.logger.get_increment_counts(),
{'failures': 1})