def test_template_req_false(self): items = {"template": "{{ payload.groupCode == 'BROKER' }}"} requirement = TemplateRequirement(items) params = {"payload": {"groupCode": "BROKER1"}} user = PicklableMock() user.parametrizer = PicklableMock() user.parametrizer.collect = Mock(return_value=params) self.assertFalse(requirement.check(None, user))
def test_template_req_true(self): items = { "template": "{{ payload.message.strip() in payload.murexIds }}" } requirement = TemplateRequirement(items) params = {"payload": { "groupCode": "BROKER", "murexIds": ["AAA", "BBB"], "message": " BBB " }} user = Mock() user.parametrizer = Mock() user.parametrizer.collect = Mock(return_value=params) self.assertTrue(requirement.check(None, user))
def test_template_req_raise(self): items = {"template": "{{ payload.groupCode }}"} requirement = TemplateRequirement(items) params = {"payload": {"groupCode": "BROKER1"}} user = PicklableMock() user.parametrizer = PicklableMock() user.parametrizer.collect = Mock(return_value=params) self.assertRaises(TypeError, requirement.check, None, user)