diff --git a/src/energenie/KVS.py b/src/energenie/KVS.py index 9be72fc..4b9746b 100644 --- a/src/energenie/KVS.py +++ b/src/energenie/KVS.py @@ -81,7 +81,6 @@ # store kvp or class instance appropriately self.store[key] = obj - @unimplemented def IGN(self, key, obj=None, factory=None): """Ignore the whole record""" # The IGN command is the same length as ADD, allowing a seek/write to change any @@ -89,14 +88,12 @@ # so that the record is deleted. pass # There is nothing to do with this command - @unimplemented def DEL(self, key, obj=None, factory=None): """Delete the key from the store""" # The DEL command deletes the rec from the store. # This is useful to build temporary objects and delete them later. # There is no need to write this to the file copy, we're processing the file - pass #TODO - # find key in object store, delete it + del self.store[key] def __getitem__(self, key): return self.store[key] diff --git a/src/energenie/KVS_test.py b/src/energenie/KVS_test.py index 9254068..508993b 100644 --- a/src/energenie/KVS_test.py +++ b/src/energenie/KVS_test.py @@ -194,7 +194,7 @@ # expected result: object described as a kvp becomes a kvp in the store if no factory callback print(kvs.store) - @test_1 + @test_0 def test_ADD_factory(self): #NOTE: This is an under the bonnet test of parsing an ADD record from the file obj = { @@ -212,8 +212,6 @@ kvs.ADD("tv1", obj, FACTORY) - #TODO all non type args need to be passed as the kwargs to the factory.get - # expected result: object described as a kvp becomes a configured object instance in store print(kvs.store) @@ -221,15 +219,42 @@ @test_0 def test_IGN(self): #NOTE: This is an under the bonnet test of parsing an IGN record from the file - pass #TODO: do IGN records get ignored when parsing the file? - # expected result: no change to the in memory data structures + obj = { + "type": "TV", + "id": 1234 + } + kvs = KVS(self.KVS_FILENAME) + kvs.IGN("tv1", obj) - @test_0 + # expected result: no change to the in memory data structures + print(kvs.store) + + #---- HERE ---- + + @test_1 def test_DEL(self): #NOTE: This is an under the bonnet test of parsing a DEL record from the file - pass #TODO: do DEL records get processed when parsing the file? + + #NOTE: This is an under the bonnet test of parsing an IGN record from the file + obj = { + "type": "TV", + "id": 1234 + } + kvs = KVS(self.KVS_FILENAME) + kvs.ADD("tv1", obj) + kvs.DEL("tv1", obj) + # expected result: record is deleted from in memory store + print(kvs.store) + + + try: + kvs.DEL("tv1", obj) + self.fail("Did not get expected KeyError") + except KeyError: + pass # expected # expected result: error if it was not in the store in the first place + print(kvs.store) @test_0 def test_load_process(self):