cr-connect-workflow/tests/workflow/test_workflow_boolean_default.py
Dan 6f80d816cd My privous efforts didn't take into account the fact that we use dot notation in field names.
I've re-worked the workflow form endpoint, so that it only accepts the data that should be in the form, and ignores any other values that come back from the front end.  It seems Formly has some bugs that were introducing confusing information, and I want everything to behave consistently.
I had to re-work some of the tests, which were relying on an ability to set data through a form post without having a corresponding form to do so.
2021-03-14 12:20:39 -04:00

72 lines
2.0 KiB
Python

from tests.base_test import BaseTest
class TestBooleanDefault(BaseTest):
def do_test(self, yes_no):
workflow = self.create_workflow('boolean_default_value')
workflow_api = self.get_workflow_api(workflow)
set_default_task = workflow_api.next_task
result = self.complete_form(workflow_api, set_default_task, {'yes_no': yes_no})
return result
def test_boolean_true_string(self):
yes_no = 'True'
result = self.do_test(yes_no)
self.assertEqual(True, result.next_task.data['pick_one'])
def test_boolean_true_string_lower(self):
yes_no = 'true'
result = self.do_test(yes_no)
self.assertEqual(True, result.next_task.data['pick_one'])
def test_boolean_t_string(self):
yes_no = 'T'
result = self.do_test(yes_no)
self.assertEqual(True, result.next_task.data['pick_one'])
def test_boolean_t_string_lower(self):
yes_no = 't'
result = self.do_test(yes_no)
self.assertEqual(True, result.next_task.data['pick_one'])
def test_boolean_true(self):
yes_no = True
result = self.do_test(yes_no)
self.assertEqual(True, result.next_task.data['pick_one'])
def test_boolean_false_string(self):
yes_no = 'False'
result = self.do_test(yes_no)
self.assertEqual(False, result.next_task.data['pick_one'])
def test_boolean_false_string_lower(self):
yes_no = 'false'
result = self.do_test(yes_no)
self.assertEqual(False, result.next_task.data['pick_one'])
def test_boolean_f_string(self):
yes_no = 'F'
result = self.do_test(yes_no)
self.assertEqual(False, result.next_task.data['pick_one'])
def test_boolean_f_string_lower(self):
yes_no = 'f'
result = self.do_test(yes_no)
self.assertEqual(False, result.next_task.data['pick_one'])
def test_boolean_false(self):
yes_no = False
result = self.do_test(yes_no)
self.assertEqual(False, result.next_task.data['pick_one'])