Updated sheerka.value() and added unit tests
This commit is contained in:
+6
-3
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user