if element not in universe.contents:
message = "The \"" + element + "\" element does not exist."
else:
- universe.contents[element].set(facet, value)
- message = ("You have successfully (re)set the \"" + facet
- + "\" facet of element \"" + element
- + "\". Try \"show element " +
- element + "\" for verification.")
+ try:
+ universe.contents[element].set(facet, value)
+ except ValueError:
+ message = ("Value \"%s\" of type \"%s\" cannot be coerced "
+ "to the correct datatype for facet \"%s\"." %
+ (value, type(value), facet))
+ else:
+ message = ("You have successfully (re)set the \"" + facet
+ + "\" facet of element \"" + element
+ + "\". Try \"show element " +
+ element + "\" for verification.")
actor.send(message)
"[0-9]+\. The matching lines\r\nfrom [0-9]+ to [0-9]+ are:", ""),
)
+test_invalid_loglevel = (
+ (2, "> ", "set account:admin loglevel two"),
+ (2, "Value \"two\" of type \"<class 'str'>\" cannot be coerced .*> ", ""),
+)
+
test_log_no_errors = (
(2, "> ", "show log 7"),
(2, "None of the [0-9]+ lines in memory matches your request\.", ""),
(test_show_element, "show element"),
(test_show_log, "show log"),
(test_custom_loglevel, "show log"),
+ (test_invalid_loglevel, "invalid loglevel"),
(test_log_no_errors, "no errors logged"),
)