def test_raises_value_error_when_given_unsupported_form_type(self): class InvalidForm: pass with pytest.raises(ValueError) as exception_info: resolve_form({}, InvalidForm) expected_message = 'Unsupported form type: InvalidForm. Type must be subclass of pydantic.BaseModel' assert expected_message in str(exception_info.value)
def test_raises_form_validation_error_when_given_invalid_or_no_json( self, data): with pytest.raises(FormValidationError) as exception_info: resolve_form(data, DummyForm) exception = exception_info.value assert exception.message == 'Form could not be validated due to given json not existing or being valid' assert exception.schemas is not None assert len(exception.errors) == 1
def test_returns_resolved_form__when_given_valid_string( self, valid_form_json): resolved_dummy_form = resolve_form(valid_form_json, DummyForm) assert resolved_dummy_form is not None
def test_returns_resolved_form_when_given_valid_bytes( self, valid_form_bytes): resolved_dummy_form = resolve_form(valid_form_bytes, DummyForm) assert resolved_dummy_form is not None
def test_when_form_is_valid(self, dummy_form): resolved_dummy_form = resolve_form(dummy_form, DummyForm) assert resolved_dummy_form is not None