Skip to content
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

Weight taking the height value for a CSV upload #360

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/npda/forms/visit_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def clean_height(self):
return data

def clean_weight(self):
data = self.cleaned_data["height"]
data = self.cleaned_data["weight"]
if data is not None:
if data < 1:
raise ValidationError(
Expand Down
25 changes: 25 additions & 0 deletions project/npda/tests/form_tests/test_visit_form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest

from project.npda.forms.visit_form import VisitForm
from project.npda.tests.factories.patient_factory import PatientFactory

# https://github.com/rcpch/national-paediatric-diabetes-audit/issues/359
@pytest.mark.django_db
def test_height_and_weight_set_correctly():
patient = PatientFactory()

form = VisitForm(
data={
"height": "60",
"weight": "50",
},
initial = {
"patient": patient
}
)

# Not passing all the data so it will have errors, just trigger the cleaners
form.is_valid()

assert form.cleaned_data["height"] == 60
assert form.cleaned_data["weight"] == 50