Fix an inconsistency in category-refresh for empty string, related to #2236
This commit is contained in:
parent
b7b2872f43
commit
126dd135cb
3 changed files with 48 additions and 7 deletions
|
|
@ -96,7 +96,7 @@ def create_object(
|
|||
location itself or during unittests.
|
||||
attributes (list): Tuples on the form (key, value) or (key, value, category),
|
||||
(key, value, lockstring) or (key, value, lockstring, default_access).
|
||||
to set as Attributes on the new object.
|
||||
to set as Attributes on the new object.
|
||||
nattributes (list): Non-persistent tuples on the form (key, value). Note that
|
||||
adding this rarely makes sense since this data will not survive a reload.
|
||||
|
||||
|
|
@ -229,8 +229,9 @@ def create_script(
|
|||
report_to (Object): The object to return error messages to.
|
||||
desc (str): Optional description of script
|
||||
tags (list): List of tags or tuples (tag, category).
|
||||
attributes (list): List if tuples (key, value) or (key, value, category)
|
||||
(key, value, lockstring) or (key, value, lockstring, default_access).
|
||||
attributes (list): List of tuples `(key, value)`, `(key, value, category)`,
|
||||
`(key, value, category, lockstring)` or
|
||||
`(key, value, category, lockstring, default_access)`.
|
||||
|
||||
Returns:
|
||||
script (obj): An instance of the script created
|
||||
|
|
|
|||
|
|
@ -78,6 +78,45 @@ class TestCreateScript(EvenniaTest):
|
|||
assert script.key == "test_script"
|
||||
script.stop()
|
||||
|
||||
def test_attr_creation_func(self):
|
||||
"""
|
||||
Test of assigning attributes during creation
|
||||
|
||||
"""
|
||||
attrvalue = {'test1': 1, 'test2': 'boo'}
|
||||
|
||||
# creation-function direct call
|
||||
script = create.create_script(
|
||||
key='script_broken',
|
||||
attributes=[
|
||||
('testname', attrvalue, '')
|
||||
]
|
||||
)
|
||||
self.assertTrue(script)
|
||||
self.assertEqual(script.db.testname, None) # since the category is '' and not None
|
||||
self.assertEqual(script.attributes.get("testname", category=''), attrvalue)
|
||||
script.stop()
|
||||
|
||||
def test_attr_method_creation_malformed(self):
|
||||
"""
|
||||
Adding the wrong type for one attribute-tuple element
|
||||
|
||||
"""
|
||||
attrvalue = {'test1': 1, 'test2': 'boo'}
|
||||
|
||||
# method-based creation
|
||||
script, err = DefaultScript.create(
|
||||
'scripttest2',
|
||||
attributes=[
|
||||
# test of wrong syntax - last element should be bool
|
||||
('testname', attrvalue, None, '', '')
|
||||
]
|
||||
)
|
||||
self.assertFalse(err)
|
||||
self.assertTrue(script)
|
||||
self.assertEqual(script.db.testname, attrvalue)
|
||||
script.stop()
|
||||
|
||||
|
||||
class TestCreateHelpEntry(TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue