diff --git a/crc/api/tools.py b/crc/api/tools.py index 74ed94cf..d3325540 100644 --- a/crc/api/tools.py +++ b/crc/api/tools.py @@ -72,7 +72,7 @@ def send_email(address): 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 there is a hide expression that is based on a previous value in the same form.""" try: diff --git a/tests/test_tools_api.py b/tests/test_tools_api.py index 7c7e1b3f..67cc963d 100644 --- a/tests/test_tools_api.py +++ b/tests/test_tools_api.py @@ -39,7 +39,7 @@ class TestStudyApi(BaseTest): self.assertIsNotNone(scripts[0]['description']) 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', data='{"expression": "x.y==2", "data": {"x":{"y":2}}}', follow_redirects=True, content_type='application/json', @@ -47,3 +47,15 @@ class TestStudyApi(BaseTest): self.assert_success(rv) response = json.loads(rv.get_data(as_text=True)) 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'])