diff --git a/src/energenie/KVS.py b/src/energenie/KVS.py index f843890..4236a36 100644 --- a/src/energenie/KVS.py +++ b/src/energenie/KVS.py @@ -11,9 +11,10 @@ self.store = {} @unimplemented - def load(self, factory): + def load(self, create_cb): """Load the whole file into an in-memory cache""" - # The 'factory' is a place to go to turn device type names into actual class instances + # The 'callback' is called to process each record as it is read in. + # for the Registry, this is a way that it can create the class and also add receive routing pass #TODO # open file for read # for each line read @@ -115,7 +116,7 @@ # close file @unimplemented - def rewrite(self): + def write(self, filename=None): """Rewrite the whole in memory cache over the top of the external file""" # useful if you have updated the in memory copy only and want to completely regenerate pass #TODO diff --git a/src/energenie/KVS_test.py b/src/energenie/KVS_test.py index 1d190f7..1325561 100644 --- a/src/energenie/KVS_test.py +++ b/src/energenie/KVS_test.py @@ -5,27 +5,72 @@ import unittest from lifecycle import * - class TestKVSMemory(unittest.TestCase): - pass #TODO - # create blank - # add - # get - # delete - # get size - # get keys + @test_0 + def test_create_blank(self): + pass #TODO: create a blank registry not bound to a file + #init + + @test_0 + def test_add(self): + pass #TODO: add an object into the store + #setitem + + @test_0 + def test_change(self): + pass #TODO: if we change the value associated with a key, does it get updated? + #setitem + + @test_0 + def test_get(self): + pass #TODO: get an object by it's key name + #getitem + + @test_0 + def test_delete(self): + pass #TODO: delete an object by it's key name + #delitem + + @test_0 + def test_size(self): + pass #TODO: how big is the kvs + # size + + @test_0 + def test_keys(self): + pass #TODO: get all keys + # keys class TestKVSPersisted(unittest.TestCase): - pass #TODO - # persist non persisted KVS - # create from file and load - # add (does persistent version change) - # delete (does persistent version change) - # reload with IGN records - # reload with DEL records - # rewrite to a new file + @test_0 + def test_write(self): + pass #TODO: write an in memory kvs to a file + # write + + @test_0 + def test_load(self): + pass #TODO: load a blank kvs from an external file + # load + + @test_0 + def test_add(self): + pass #TODO: does persistent version change as well? + # setitem + + @test_0 + def test_delete(self): + pass #TODO: does persistent version get an IGN update? + # delitem + + @test_0 + def test_IGN(self): + pass #TODO: do IGN records get ignored? + + @test_0 + def test_DEL(self): + pass #TODO: do DEL records get processed? if __name__ == "__main__":