Enhanced complex concepts handling
This commit is contained in:
+48
-1
@@ -144,7 +144,7 @@ def test_i_can_get_a_builtin_concept_by_their_enum_or_the_string():
|
||||
assert sheerka.get(str(key)) is not None
|
||||
|
||||
|
||||
def test_i_can_get_new_concept():
|
||||
def test_i_can_get_a_newly_created_concept():
|
||||
sheerka = get_sheerka()
|
||||
concept = get_default_concept()
|
||||
|
||||
@@ -324,6 +324,21 @@ def test_i_can_instantiate_a_concept():
|
||||
assert new.props["b"].value == "value"
|
||||
|
||||
|
||||
def test_i_can_instantiate_with_the_name_and_the_id():
|
||||
sheerka = get_sheerka()
|
||||
sheerka.create_new_concept(get_context(sheerka), Concept("foo", body="foo1"))
|
||||
sheerka.create_new_concept(get_context(sheerka), Concept("foo", body="foo2"))
|
||||
|
||||
concepts = sheerka.new("foo")
|
||||
assert len(concepts) == 2
|
||||
|
||||
foo1 = sheerka.new(("foo", "1001"))
|
||||
assert foo1.body == "foo1"
|
||||
|
||||
foo2 = sheerka.new(("foo", "1002"))
|
||||
assert foo2.body == "foo2"
|
||||
|
||||
|
||||
def test_instances_are_different_when_asking_for_new():
|
||||
sheerka = get_sheerka()
|
||||
concept = get_default_concept()
|
||||
@@ -357,6 +372,38 @@ def test_i_cannot_instantiate_an_unknown_concept():
|
||||
assert new.body == "fake_concept"
|
||||
|
||||
|
||||
def test_i_cannot_instantiate_with_invalid_id():
|
||||
sheerka = get_sheerka()
|
||||
sheerka.create_new_concept(get_context(sheerka), Concept("foo", body="foo1"))
|
||||
sheerka.create_new_concept(get_context(sheerka), Concept("foo", body="foo2"))
|
||||
|
||||
new = sheerka.new(("foo", "invalid_id"))
|
||||
|
||||
assert sheerka.isinstance(new, BuiltinConcepts.UNKNOWN_CONCEPT)
|
||||
assert new.body == "foo"
|
||||
|
||||
|
||||
def test_i_cannot_instantiate_with_invalid_key():
|
||||
sheerka = get_sheerka()
|
||||
sheerka.create_new_concept(get_context(sheerka), Concept("foo", body="foo1"))
|
||||
sheerka.create_new_concept(get_context(sheerka), Concept("foo", body="foo2"))
|
||||
|
||||
new = sheerka.new(("invalid_key", "1001"))
|
||||
|
||||
assert sheerka.isinstance(new, BuiltinConcepts.UNKNOWN_CONCEPT)
|
||||
assert new.body == "invalid_key"
|
||||
|
||||
|
||||
def test_concept_id_is_irrelevant_when_only_one_concept():
|
||||
sheerka = get_sheerka()
|
||||
sheerka.create_new_concept(get_context(sheerka), Concept("foo", body="foo1"))
|
||||
|
||||
new = sheerka.new(("foo", "invalid_id"))
|
||||
|
||||
assert sheerka.isinstance(new, "foo")
|
||||
assert new.body == "foo1"
|
||||
|
||||
|
||||
def test_i_cannot_instantiate_when_properties_are_not_recognized():
|
||||
sheerka = get_sheerka()
|
||||
concept = get_default_concept()
|
||||
|
||||
Reference in New Issue
Block a user