Use super for SimpleDatabase operations

Closes https://github.com/decentral1se/xbotlib/issues/5.
This commit is contained in:
Luke Murphy 2021-02-02 22:05:56 +01:00
parent 5526ad5313
commit a81fa1af54
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 9 additions and 2 deletions

View File

@ -101,3 +101,10 @@ def test_config(config):
assert config.serve
assert config.storage == "file"
assert config.output == "."
def test_simple_message_delete(tmp_db_path):
db = SimpleDatabase(tmp_db_path, log)
db["foo"] = "bar"
del db["foo"]
assert "foo" not in db

View File

@ -59,12 +59,12 @@ class SimpleDatabase(dict):
def __setitem__(self, key, val):
"""Write data to the database."""
dict.__setitem__(self, key, val)
super().__setitem__(key, val)
self._dumps()
def __delitem__(self, key):
"""Remove data from the database."""
dict.__delitem__(key)
super().__delitem__(key)
self._dumps()
def update(self, *args, **kwargs):