-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional patient validators and tests #277
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Use reusable not in the future validator - Reusable Postcode field to clean both postcode and gp_practice_postcode - Move validation that only needs one field to specific cleaners (clean_date_of_birth etc) - Structured ValidationErrors following Django best practice - Call self.add_error in clean function to ensure all errors are recorded, not just one
mbarton
commented
Sep 18, 2024
# We don't want to call remote services in unit tests | ||
@pytest.fixture(autouse=True) | ||
def mock_remote_calls(): | ||
with patch("project.npda.forms.patient_form.validate_postcode", Mock(return_value=True)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried reducing the nesting here with an ExitStack but it didn't work. There's probably a way to do it but it's not that bad and wrapped up in a fixture anyway
Makes it work with both form and CSV upload. CSV upload can't call PatientForm.save() as it will throw if it has any validation errors. During CSV upload we want to store data even if it is invalid.
At the moment it's just the model field name
postcodes.io returns the normalised postcode with a space in it which we need for the NHS spine lookup
mbarton
force-pushed
the
mbarton/validation-tests-only
branch
from
September 19, 2024 14:13
af8701a
to
9b94dcb
Compare
…date_postcode It's easier to read in the form with spaces
This was referenced Sep 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
to_python
on a subclass of field if they normalise the data (eg remove spaces from postcode)clean_XXXX
if they only validate a single fieldclean
if they need to validate a field using the values from others (eg diagnosis date not before dob)RequestException
when wrapping remote network validatorsThis PR adds a couple of behaviour changes: