I can also get concept by name
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from core.concept import Concept, ConceptParts
|
||||
from core.concept import Concept, ConceptParts, DEFINITION_TYPE_DEF
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name, properties, expected", [
|
||||
@@ -29,6 +29,25 @@ def test_i_can_compute_the_key(name, properties, expected):
|
||||
assert concept.key == expected
|
||||
|
||||
|
||||
def test_i_can_compute_the_key_when_from_definition():
|
||||
|
||||
# if definition is not defined, use the name
|
||||
concept = Concept()
|
||||
concept.metadata.name = "hello a"
|
||||
concept.metadata.props = [("a", None)]
|
||||
concept.init_key()
|
||||
assert concept.key == "hello __var__0"
|
||||
|
||||
# if definition is defined, use it
|
||||
concept = Concept()
|
||||
concept.metadata.name = "greetings"
|
||||
concept.metadata.definition = "hello a"
|
||||
concept.metadata.definition_type = DEFINITION_TYPE_DEF
|
||||
concept.metadata.props = [("a", None)]
|
||||
concept.init_key()
|
||||
assert concept.key == "hello __var__0"
|
||||
|
||||
|
||||
def test_key_does_not_use_variable_when_definition_is_set():
|
||||
concept = Concept("plus").def_prop('plus')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user