Пример #1
0
    def test_ADD_factory(self):
        #NOTE: This is an under the bonnet test of parsing an ADD record from the file
        obj = {"type": "TV", "id": 1234}
        kvs = KVS(self.KVS_FILENAME)
        kvs.ADD("tv1", obj, create_fn=FACTORY.get)

        # expected result: object described as a kvp becomes a configured object instance in store
        print(kvs.store)
Пример #2
0
    def test_ADD_nofactory(self):
        #NOTE: This is an under the bonnet test of parsing an ADD record from the file

        # No factory callback provided, use ADD parse action
        obj = {"type": "MIHO005", "id": 1234}
        kvs = KVS(self.KVS_FILENAME)
        kvs.ADD("tv1", obj)

        # expected result: object described as a kvp becomes a kvp in the store if no factory callback
        print(kvs.store)
Пример #3
0
    def test_DEL(self):
        #NOTE: This is an under the bonnet test of parsing a DEL record from 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)