def test_missing_schema_field(self, client): """Tests failure when provided schema is missing a field from layout""" schema = Structure({ 'test_field1': Text(required=True), 'test_field2': Integer(required=True), }) layout = [{ 'title': 'Test Section 1', 'elements': [ { 'type': 'textbox', 'field': 'test_field1', 'label': 'Test Field #1', 'options': { 'multiline': True }, }, { 'type': 'textbox', 'field': 'test_field2', 'label': 'Test Field #2', }, { 'type': 'checkbox', 'field': 'test_field3', 'label': 'Test Field #3', }, ], }] with self.assertRaises(OperationError): WorkflowElement._verify_layout(layout, schema)
def test_missing_schema_field(self, client): """Tests failure when provided schema is missing a field from layout""" schema = Structure({ 'test_field1': Text(required=True), 'test_field2': Integer(required=True), }) layout = [{ 'title': 'Test Section 1', 'elements': [ { 'type': 'textbox', 'field': 'test_field1', 'label': 'Test Field #1', 'options': {'multiline': True}, }, { 'type': 'textbox', 'field': 'test_field2', 'label': 'Test Field #2', }, { 'type': 'checkbox', 'field': 'test_field3', 'label': 'Test Field #3', }, ], }] with self.assertRaises(OperationError): WorkflowElement._verify_layout(layout, schema)
def test_parse_valid_layout(self, client): """Tests verification of a valid layout""" schema = Structure({'test_field1': Text(required=True)}) layout = [{ 'title': 'Test Section 1', 'elements': [{ 'type': 'textbox', 'field': 'test_field1', 'label': 'Test Field #1', 'options': {'multiline': True}, }], }] WorkflowElement._verify_layout(layout, schema)
def test_parse_valid_layout(self, client): """Tests verification of a valid layout""" schema = Structure({'test_field1': Text(required=True)}) layout = [{ 'title': 'Test Section 1', 'elements': [{ 'type': 'textbox', 'field': 'test_field1', 'label': 'Test Field #1', 'options': { 'multiline': True }, }], }] WorkflowElement._verify_layout(layout, schema)
def instantiate(self, workflow): element = WorkflowElement.unserialize(workflow.specification) self.cache[workflow.id] = (workflow.modified, element) return element
def _verify_specification(cls, specification): if specification is None: return schema = WorkflowElement.unserialize(specification) schema.verify()