better test
This commit is contained in:
parent
0735d8a8ac
commit
6a459ab114
2 changed files with 15 additions and 4 deletions
|
|
@ -30,10 +30,17 @@ class StringFunctions:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def capitalize(string: String) -> String:
|
def capitalize(string: String) -> String:
|
||||||
"""
|
"""
|
||||||
Capitalize all words in the String.
|
Capitalize the first character in the string.
|
||||||
"""
|
"""
|
||||||
return String(string.value.capitalize())
|
return String(string.value.capitalize())
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def titlecase(string: String) -> String:
|
||||||
|
"""
|
||||||
|
Capitalize each word in the string.
|
||||||
|
"""
|
||||||
|
return String(string.value.title())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def replace(
|
def replace(
|
||||||
string: String, old: String, new: String, count: Optional[Integer] = None
|
string: String, old: String, new: String, count: Optional[Integer] = None
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ class TestScript:
|
||||||
).resolve(unresolvable={"bb"}) == {"aa": String("a")}
|
).resolve(unresolvable={"bb"}) == {"aa": String("a")}
|
||||||
|
|
||||||
def test_partial_update_script(self):
|
def test_partial_update_script(self):
|
||||||
|
# to be resolved later
|
||||||
|
entry_map = ResolvedMap({String("title"): String("the title")})
|
||||||
|
|
||||||
script = Script(
|
script = Script(
|
||||||
{
|
{
|
||||||
"entry": "{%throw('entry has not been populated yet')}",
|
"entry": "{%throw('entry has not been populated yet')}",
|
||||||
|
|
@ -44,13 +47,14 @@ class TestScript:
|
||||||
|
|
||||||
script.add(
|
script.add(
|
||||||
{
|
{
|
||||||
|
"new_variable_titlecase": "{%titlecase(new_variable_upper)}",
|
||||||
"new_variable": "{resolved_override} {title}",
|
"new_variable": "{resolved_override} {title}",
|
||||||
"new_variable_upper": "{%upper(new_variable)}",
|
"new_variable_upper": "{%upper(new_variable)}",
|
||||||
}
|
}
|
||||||
).resolve(
|
).resolve(resolved={"entry": entry_map}, update=True)
|
||||||
resolved={"entry": ResolvedMap({String("title"): String("the title")})}, update=True
|
|
||||||
)
|
|
||||||
|
|
||||||
assert script.get("title") == String("the title")
|
assert script.get("title") == String("the title")
|
||||||
assert script.get("new_variable") == String("hi mom the title")
|
assert script.get("new_variable") == String("hi mom the title")
|
||||||
assert script.get("new_variable_upper") == String("HI MOM THE TITLE")
|
assert script.get("new_variable_upper") == String("HI MOM THE TITLE")
|
||||||
|
assert script.get("new_variable_titlecase") == String("Hi Mom The Title")
|
||||||
|
assert script.get("entry") == entry_map
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue