Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Change mock repository to use strings as the sql implementation does
Browse files Browse the repository at this point in the history
  • Loading branch information
Donnype committed Jan 11, 2023
1 parent b3fc80b commit 37bf547
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions boefjes/katalogus/storage/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ def get_all(self, organisation_id: str, plugin_id: str) -> Dict[str, str]:
return {k.split(".", maxsplit=1)[1]: v for k, v in self._data[organisation_id].items() if plugin_id in k}

def create(self, key: str, value: str, organisation_id: str, plugin_id: str) -> None:
self._data[organisation_id][f"{plugin_id}.{key}"] = value
self._data[organisation_id][f"{plugin_id}.{key}"] = str(value)

def update_by_key(self, key: str, value: str, organisation_id: str, plugin_id: str) -> None:
self._data[organisation_id][f"{plugin_id}.{key}"] = value
self._data[organisation_id][f"{plugin_id}.{key}"] = str(value)

def delete_by_key(self, key: str, organisation_id: str, plugin_id: str) -> None:
del self._data[organisation_id][f"{plugin_id}.{key}"]
Expand Down
7 changes: 7 additions & 0 deletions boefjes/katalogus/tests/test_plugin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,12 @@ def test_adding_integer_settings_with_faulty_value_given_constraints(self):

self.assertIn("'24' is not of type 'integer'", ctx.exception.message)

self.service.settings_storage.update_by_key("api_key", 24, self.organisation, plugin_id) # not multiple of 10

with self.assertRaises(SettingsNotConformingToSchema) as ctx:
self.service.update_by_id("test-repo-2", plugin_id, self.organisation, True)

self.assertIn("'24' is not of type 'integer'", ctx.exception.message)

plugin = self.service.by_plugin_id(plugin_id, self.organisation)
self.assertFalse(plugin.enabled)

0 comments on commit 37bf547

Please sign in to comment.