Updated sheerka.value() and added unit tests

This commit is contained in:
2019-12-21 16:15:54 +01:00
parent 41e0885486
commit 2474b08150
3 changed files with 14 additions and 27 deletions
+6 -3
View File
@@ -546,7 +546,7 @@ class Sheerka(Concept):
return from_db
# else return new Unknown concept
# Note that I don't call the new() method, as it use get() -> cyclic call
# Note that I don't call the new() method to prevent cyclic call
unknown_concept = Concept()
template = self.concepts_cache[str(BuiltinConcepts.UNKNOWN_CONCEPT)]
unknown_concept.update_from(template)
@@ -623,7 +623,7 @@ class Sheerka(Concept):
if self.isinstance(obj, BuiltinConcepts.RETURN_VALUE) and \
obj.status and \
self.isinstance(obj.value, BuiltinConcepts.USER_INPUT):
return obj.value.text
return obj.value.body
if not isinstance(obj, Concept):
return obj
@@ -632,7 +632,10 @@ class Sheerka(Concept):
return obj.get_value()
if obj.body is not None:
return obj.body
if (isinstance(obj.body, list) or isinstance(obj.body, set)) and len(obj.body) == 1:
return obj.body[0]
else:
return obj.body
return obj if allow_none_body else self.new(BuiltinConcepts.CANNOT_RESOLVE_VALUE_ERROR, body=obj)