Skip to content

Commit

Permalink
Merge pull request #290 from dirksammel/fix_auditor_components
Browse files Browse the repository at this point in the history
AUDITOR plugin: fix for config without components
  • Loading branch information
giffels authored Mar 14, 2023
2 parents a55ab6a + bec7410 commit 799757e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tardis/plugins/auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ def __init__(self):
self._resources[site.name][machine_type][resource] = getattr(
config, site.name
).MachineMetaData[machine_type][resource]
self._components[site.name][machine_type][resource] = getattr(
config_auditor.components, machine_type
).get(resource, {})
try:
self._components[site.name][machine_type][resource] = getattr(
config_auditor.components, machine_type
).get(resource, {})
except AttributeError:
continue

self._user = getattr(config_auditor, "user", "tardis")
self._group = getattr(config_auditor, "group", "tardis")
Expand Down
5 changes: 5 additions & 0 deletions tests/plugins_t/test_auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ def test_construct_record(self):
self.assertEqual(len(record.components[1].scores), 1)
self.assertEqual(record.components[1].scores[0].name, "BLUBB")
self.assertEqual(record.components[1].scores[0].value, 1.4)

def test_missing_components(self):
del self.config.Plugins.Auditor.components
plugin = Auditor()
self.assertEqual(plugin._components, {"testsite": {"test_machine_type": {}}})

0 comments on commit 799757e

Please sign in to comment.