From e6c834152fbc09ab3f0786c2d615a28c559b05a1 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 7 Dec 2020 11:06:52 +0100 Subject: [PATCH] test if create dummy script is executed without issues --- .gitlab-ci.yml | 8 ++++++++ smash/db_scripts/create_dummy_data.py | 14 +++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa60a1b1..b69183fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,6 +64,14 @@ test_python_latest: - coverage run --source web manage.py test -v3 - coverage report -m --omit="*/test*,*/migrations*,*debug_utils*" +test_create_dummy_script: + <<: *test_definition + script: + - cp "local_settings_ci_sqlite.py" "smash/smash/local_settings.py" + - cd smash + - python manage.py makemigrations web && python manage.py migrate + - python db_scripts/create_dummy_data.py + build_debian: image: debian stage: build diff --git a/smash/db_scripts/create_dummy_data.py b/smash/db_scripts/create_dummy_data.py index dfcb4fff..dadf16b1 100644 --- a/smash/db_scripts/create_dummy_data.py +++ b/smash/db_scripts/create_dummy_data.py @@ -435,6 +435,7 @@ class smashProvider(BaseProvider): virus_iga_1 = choice(["Borderline", "Positive", "Negative"], 1, p=[0.02, 0.03, 0.95])[0] virus_igg_1 = choice(["Borderline", "Positive", "Negative"], 1, p=[0.02, 0.03, 0.95])[0] if virus_test_1_result is None: + virus_test_1_collection_date = '' virus_test_1_updated = fake.date_between(start_date='-30d', end_date='-4d') elif virus_test_1_result == "Inconclusive": virus_test_1_updated = fake.date_between(start_date='-30d', end_date='-4d') @@ -447,14 +448,13 @@ class smashProvider(BaseProvider): virus_test_1_collection_date = fake.date_between(start_date='-30d', end_date='-4d') study_subject, _ = StudySubject.objects.update_or_create(nd_number=nd_number, subject=subject, - virus_test_1_result=virus_test_1_result, - virus_test_1_updated=virus_test_1_updated, - virus_test_1_collection_date=virus_test_1_collection_date, - virus_test_1_iga_status=virus_iga_1, - virus_test_1_igg_status=virus_igg_1, defaults={'default_location': default_location, 'type': type, 'screening_number': screening_number, 'study': study}) - + study_subject.set_custom_field_value('Visit 0 RT-PCR update date', virus_test_1_updated) + study_subject.set_custom_field_value('Virus 0 RT-PCR', virus_test_1_result) + study_subject.set_custom_field_value('Visit 0 RT-PCR collection date', virus_test_1_collection_date) + study_subject.set_custom_field_value('Visit 0 IgA Status', virus_iga_1) + study_subject.set_custom_field_value('Visit 0 IgG Status', virus_igg_1) self.alreadyCreatedStudySubjects.append(study_subject) return study_subject @@ -608,7 +608,7 @@ class smashProvider(BaseProvider): defaults = {'first_name': first_name, 'last_name': last_name, 'email': email, 'unit': unit, 'specialization': specialization, 'phone_number': phone_number, 'user': user} - + worker, _ = Worker.objects.update_or_create(first_name=first_name, last_name=last_name, defaults=defaults) -- GitLab