Skip to content
Snippets Groups Projects
Commit 005d161f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

don't add appointment link to existing appointments

parent 636a9416
No related branches found
No related tags found
1 merge request!244Redcap sync
Pipeline #25383 passed
# coding=utf-8
import codecs
import csv
import datetime
import logging
import sys
import traceback
import codecs
import pytz
from django.conf import settings
......@@ -100,9 +100,9 @@ class TnsCsvVisitImportReader:
else:
appointment = Appointment.objects.create(visit=visit, length=60, datetime_when=date,
location=location)
if self.appointment_type is not None:
AppointmentTypeLink.objects.create(appointment_id=appointment.id,
appointment_type=self.appointment_type)
if self.appointment_type is not None:
AppointmentTypeLink.objects.create(appointment_id=appointment.id,
appointment_type=self.appointment_type)
self.processed_count += 1
except:
self.problematic_count += 1
......
......@@ -6,7 +6,7 @@ import logging
from django.test import TestCase
from web.tests.functions import create_study_subject
from web.importer import Exporter
from web.importer import SubjectExporter
from web.models import Subject, StudySubject, Study, Provenance
from web.models.constants import GLOBAL_STUDY_ID
......@@ -21,7 +21,7 @@ class TestExporter(TestCase):
def test_export_not_excluded(self):
create_study_subject()
exporter = Exporter(filename="empty.csv")
exporter = SubjectExporter(filename="empty.csv")
exporter.execute()
self.assertEqual(0, exporter.exported_count)
......@@ -32,7 +32,7 @@ class TestExporter(TestCase):
subject.excluded=True
subject.save()
exporter = Exporter(filename="empty.csv")
exporter = SubjectExporter(filename="empty.csv")
exporter.execute()
self.assertEqual(1, exporter.exported_count)
......
......@@ -6,7 +6,7 @@ import tempfile
from django.conf import settings
from django.test import TestCase
from web.importer import ExporterCronJob
from web.importer import SubjectExporterCronJob
logger = logging.getLogger(__name__)
from django.core import mail
......@@ -24,7 +24,7 @@ class TestCronJobExporter(TestCase):
def test_import_without_configuration(self):
CronJobLog.objects.all().delete()
job = ExporterCronJob()
job = SubjectExporterCronJob()
status = job.do()
......@@ -37,7 +37,7 @@ class TestCronJobExporter(TestCase):
setattr(settings, "DAILY_SUBJECT_EXPORT_FILE", tmp)
CronJobLog.objects.all().delete()
job = ExporterCronJob()
job = SubjectExporterCronJob()
status = job.do()
......
......@@ -151,6 +151,16 @@ class TestTnsCsvVisitReader(TestCase):
self.assertEquals(3, self.get_warnings_count())
def test_dont_add_links_for_existing_appointments(self):
filename = get_resource_path('tns_vouchers_import.csv')
TnsCsvVisitImportReader().load_data(filename)
links = AppointmentTypeLink.objects.all().count()
TnsCsvVisitImportReader().load_data(filename)
self.assertEquals(links, AppointmentTypeLink.objects.all().count())
self.assertEquals(0, self.get_warnings_count())
def get_warnings_count(self):
if "WARNING" in self.warning_counter.level2count:
return self.warning_counter.level2count["WARNING"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment