def test_assert_not_wanted_errors_array_empty(self): assertions.assert_actual_list_not_subset( [ Error(code='INVALID', message=AnyValue('str'), field=AnyValue('str', permit_none=True)) ], [], )
def test_assert_not_wanted_errors_mismatch_field(self): assertions.assert_actual_list_not_subset( [ Error(code='FOO', message=AnyValue('str'), field=AnyValue('str', permit_none=True)), Error(code='BAR', message=AnyValue('str'), field='bar_field'), ], [ Error(code='BAR', message='Bar message', field=None), ], )
def test_assert_not_wanted_errors_mismatch_list(self): assertions.assert_actual_list_not_subset( [ Error(code='FOO', message=AnyValue('str'), field=AnyValue('str', permit_none=True)), # type: ignore Error(code='BAR', message=AnyValue('str'), field=AnyValue('str', permit_none=True)), # type: ignore ], [ Error(code='BAZ', message='Baz message', field=None), ], )
def test_assert_not_wanted_errors_match_list_with_field(self): with self.assertRaises(AssertionError): assertions.assert_actual_list_not_subset( [ Error(code='FOO', message=AnyValue('str'), field=AnyValue('str', permit_none=True)), Error(code='BAR', message=AnyValue('str'), field=AnyValue('str', permit_none=True)), ], [ Error(code='FOO', message='Foo message', field='foo_field'), ], )
def assert_test_case_action_results(self, action_name, action_case, test_case, test_fixture, action_response, job_response, msg=None, **kwargs): for instruction, expected in six.iteritems(action_case): if instruction.startswith('expects_') and instruction.endswith( '_error'): target = action_response if '_job_' in instruction: target = job_response errors = target.errors if target else [] try: if '_not_' in instruction: assert_actual_list_not_subset( expected, errors, 'NOT EXPECTED ERRORS: {}'.format(msg or '')) elif '_exact_' in instruction: assert_lists_match_any_order( expected, errors, 'EXPECTED EXACT ERRORS: {}'.format(msg or '')) else: assert_expected_list_subset_of_actual( expected, errors, 'EXPECTED ERRORS: {}'.format(msg or '')) except AssertionError as e: for error in errors: if error.code == 'SERVER_ERROR': raise type(e)( '{message}\n\nSERVER_ERROR: {detail}'.format( message=e.args[0], detail=error.message, ), ) raise