Refactored Concept class for better separation of metadata, compiled and values
This commit is contained in:
@@ -6,6 +6,14 @@ from parsers.ExactConceptParser import ExactConceptParser
|
||||
from sdp.sheerkaDataProvider import Event
|
||||
|
||||
|
||||
def metadata_prop(concept, prop_name):
|
||||
for name, value in concept.metadata.props:
|
||||
if name == prop_name:
|
||||
return value
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def test_i_can_compute_combinations():
|
||||
parser = ExactConceptParser()
|
||||
res = parser.combinations(["foo", "bar", "baz"])
|
||||
@@ -58,7 +66,7 @@ def test_i_can_recognize_concepts_defined_several_times():
|
||||
|
||||
assert results[0].status
|
||||
assert results[0].value.value.name == "hello a"
|
||||
assert results[0].value.value.props["a"].value == "world"
|
||||
assert metadata_prop(results[0].value.value, "a") == "world"
|
||||
|
||||
assert results[1].status
|
||||
assert results[1].value.value.name == "hello world"
|
||||
@@ -75,8 +83,8 @@ def test_i_can_recognize_a_concept_with_variables():
|
||||
assert results[0].status
|
||||
concept_found = results[0].value.value
|
||||
assert concept_found.key == concept.key
|
||||
assert concept_found.props["a"].value == "10"
|
||||
assert concept_found.props["b"].value == "5"
|
||||
assert metadata_prop(concept_found, "a") == "10"
|
||||
assert metadata_prop(concept_found, "b") == "5"
|
||||
|
||||
|
||||
def test_i_can_recognize_a_concept_with_duplicate_variables():
|
||||
@@ -90,8 +98,8 @@ def test_i_can_recognize_a_concept_with_duplicate_variables():
|
||||
assert results[0].status
|
||||
concept_found = results[0].value.value
|
||||
assert concept_found.key == concept.key
|
||||
assert concept_found.props["a"].value == "10"
|
||||
assert concept_found.props["b"].value == "5"
|
||||
assert metadata_prop(concept_found, "a") == "10"
|
||||
assert metadata_prop(concept_found, "b") == "5"
|
||||
|
||||
|
||||
def test_i_can_manage_unknown_concept():
|
||||
@@ -138,6 +146,6 @@ def get_concept(name, variables):
|
||||
c = Concept(name=name)
|
||||
if variables:
|
||||
for v in variables:
|
||||
c.props[v] = Property(v, None)
|
||||
c.def_prop(v)
|
||||
c.init_key()
|
||||
return c
|
||||
|
||||
Reference in New Issue
Block a user