Adds a test for string manipulation
This commit is contained in:
parent
4dc98a6b6b
commit
182e375fdc
|
@ -72,7 +72,7 @@ def send_email(address):
|
||||||
|
|
||||||
|
|
||||||
def evaluate_python_expression(body):
|
def evaluate_python_expression(body):
|
||||||
"""Evaluate the given python expression, returning it's result. This is useful if the
|
"""Evaluate the given python expression, returning its result. This is useful if the
|
||||||
front end application needs to do real-time processing on task data. If for instance
|
front end application needs to do real-time processing on task data. If for instance
|
||||||
there is a hide expression that is based on a previous value in the same form."""
|
there is a hide expression that is based on a previous value in the same form."""
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -39,7 +39,7 @@ class TestStudyApi(BaseTest):
|
||||||
self.assertIsNotNone(scripts[0]['description'])
|
self.assertIsNotNone(scripts[0]['description'])
|
||||||
|
|
||||||
def test_eval_hide_expression(self):
|
def test_eval_hide_expression(self):
|
||||||
"""Assures we can use python to process a hide expression fron the front end"""
|
"""Assures we can use python to process a hide expression from the front end"""
|
||||||
rv = self.app.put('/v1.0/eval',
|
rv = self.app.put('/v1.0/eval',
|
||||||
data='{"expression": "x.y==2", "data": {"x":{"y":2}}}', follow_redirects=True,
|
data='{"expression": "x.y==2", "data": {"x":{"y":2}}}', follow_redirects=True,
|
||||||
content_type='application/json',
|
content_type='application/json',
|
||||||
|
@ -47,3 +47,15 @@ class TestStudyApi(BaseTest):
|
||||||
self.assert_success(rv)
|
self.assert_success(rv)
|
||||||
response = json.loads(rv.get_data(as_text=True))
|
response = json.loads(rv.get_data(as_text=True))
|
||||||
self.assertEqual(True, response['result'])
|
self.assertEqual(True, response['result'])
|
||||||
|
|
||||||
|
def test_eval_expression_with_strings(self):
|
||||||
|
"""Assures we can use python to process a value expression from the front end"""
|
||||||
|
rv = self.app.put('/v1.0/eval',
|
||||||
|
data='{"expression": "\'Hello, \' + user.first_name + \' \' + user.last_name + \'!!!\'", '
|
||||||
|
'"data": {"user":{"first_name": "Trillian", "last_name": "Astra"}}}',
|
||||||
|
follow_redirects=True,
|
||||||
|
content_type='application/json',
|
||||||
|
headers=self.logged_in_headers())
|
||||||
|
self.assert_success(rv)
|
||||||
|
response = json.loads(rv.get_data(as_text=True))
|
||||||
|
self.assertEqual('Hello, Trillian Astra!!!', response['result'])
|
||||||
|
|
Loading…
Reference in New Issue