Refactored sheerka execution flow + Enhanced log management
This commit is contained in:
@@ -22,6 +22,11 @@ def read_json_file(sdp, file_name):
|
||||
|
||||
|
||||
class ObjWithKey:
|
||||
"""
|
||||
Object where the key can be resolved using get_key()
|
||||
Not suitable for Json dump as there is no to_dict() method
|
||||
"""
|
||||
|
||||
def __init__(self, a, b):
|
||||
self.a = a
|
||||
self.b = b
|
||||
@@ -39,6 +44,11 @@ class ObjWithKey:
|
||||
|
||||
|
||||
class ObjSetKey:
|
||||
"""
|
||||
Object where the key can be be automatically set thanks to set_key()
|
||||
Not suitable for Json dump as there is no to_dict() method
|
||||
"""
|
||||
|
||||
def __init__(self, value, key=None):
|
||||
self.value = value
|
||||
self.key = key
|
||||
@@ -56,6 +66,11 @@ class ObjSetKey:
|
||||
|
||||
|
||||
class ObjNoKey:
|
||||
"""
|
||||
Object with no key, they won't be ordered
|
||||
Not suitable for Json dump as there is no to_dict() method
|
||||
"""
|
||||
|
||||
def __init__(self, a, b):
|
||||
self.a = a
|
||||
self.b = b
|
||||
@@ -73,6 +88,11 @@ class ObjNoKey:
|
||||
|
||||
|
||||
class ObjDumpJson:
|
||||
"""
|
||||
Object where the key can be resolved using get_key()
|
||||
that can be used to dump as Json
|
||||
"""
|
||||
|
||||
def __init__(self, key=None, value=None):
|
||||
self.key = key
|
||||
self.value = value
|
||||
@@ -104,6 +124,12 @@ class ObjDumpJson:
|
||||
|
||||
|
||||
class ObjWithDigestNoKey:
|
||||
"""
|
||||
Object that can compute its digest.
|
||||
It can be used to test objects sharing the same entry (but that are different)
|
||||
Not suitable for Json dump as there is no to_dict() method
|
||||
"""
|
||||
|
||||
def __init__(self, a, b):
|
||||
self.a = a
|
||||
self.b = b
|
||||
@@ -124,6 +150,12 @@ class ObjWithDigestNoKey:
|
||||
|
||||
|
||||
class ObjWithDigestWithKey:
|
||||
"""
|
||||
Object with a key that can compute its digest.
|
||||
It can be used to test objects sharing the same key (but that are different)
|
||||
Not suitable for Json dump as there is no to_dict() method
|
||||
"""
|
||||
|
||||
def __init__(self, a, b):
|
||||
self.a = a
|
||||
self.b = b
|
||||
@@ -908,6 +940,62 @@ def test_i_can_list_when_one_element(root):
|
||||
assert list(result) == ["foo"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("root", [
|
||||
".sheerka",
|
||||
"mem://"
|
||||
])
|
||||
def test_i_can_list_when_multiple_entries_under_the_same_key(root):
|
||||
sdp = SheerkaDataProvider(root)
|
||||
sdp.add(evt_digest, "entry", ObjWithKey("a", "b"))
|
||||
sdp.add(evt_digest, "entry", ObjWithKey("a", "c"))
|
||||
|
||||
result = sdp.list("entry")
|
||||
assert list(result) == [[ObjWithKey("a", "b"), ObjWithKey("a", "c")]]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("root", [
|
||||
".sheerka",
|
||||
"mem://"
|
||||
])
|
||||
def test_i_can_list_when_multiple_entries_under_the_same_key_when_reference(root):
|
||||
sdp = SheerkaDataProvider(root)
|
||||
sdp.serializer.register(PickleSerializer(lambda obj: isinstance(obj, ObjWithKey)))
|
||||
|
||||
sdp.add(evt_digest, "entry", ObjWithKey("a", "b"), use_ref=True)
|
||||
sdp.add(evt_digest, "entry", ObjWithKey("a", "c"), use_ref=True)
|
||||
|
||||
result = sdp.list("entry")
|
||||
assert list(result) == [[ObjWithKey("a", "b"), ObjWithKey("a", "c")]]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("root", [
|
||||
".sheerka",
|
||||
"mem://"
|
||||
])
|
||||
def test_i_can_list_when_multiple_entries_under_the_same_entry(root):
|
||||
sdp = SheerkaDataProvider(root)
|
||||
sdp.add(evt_digest, "entry", ObjNoKey("a", "b"))
|
||||
sdp.add(evt_digest, "entry", ObjNoKey("a", "c"))
|
||||
|
||||
result = sdp.list("entry")
|
||||
assert list(result) == [ObjNoKey("a", "b"), ObjNoKey("a", "c")]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("root", [
|
||||
".sheerka",
|
||||
"mem://"
|
||||
])
|
||||
def test_i_can_list_when_multiple_entries_under_the_same_entry_when_reference(root):
|
||||
sdp = SheerkaDataProvider(root)
|
||||
sdp.serializer.register(PickleSerializer(lambda obj: isinstance(obj, ObjNoKey)))
|
||||
|
||||
sdp.add(evt_digest, "entry", ObjNoKey("a", "b"), use_ref=True)
|
||||
sdp.add(evt_digest, "entry", ObjNoKey("a", "c"), use_ref=True)
|
||||
|
||||
result = sdp.list("entry")
|
||||
assert list(result) == [ObjNoKey("a", "b"), ObjNoKey("a", "c")]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("root", [
|
||||
".sheerka",
|
||||
"mem://"
|
||||
|
||||
Reference in New Issue
Block a user