def test_encrypted_to_csv_from_qs(self): CrfEncrypted.objects.create(subject_visit=self.subject_visit, encrypted1="encrypted1") model_exporter = CsvModelExporter( queryset=CrfEncrypted.objects.all(), add_columns_for="subject_visit", export_folder=self.path, ) model_exporter.to_csv()
def test_encrypted_to_csv_from_model(self): CrfEncrypted.objects.create(subject_visit=self.subject_visit, encrypted1="encrypted1") model_exporter = CsvModelExporter( model="edc_export.CrfEncrypted", add_columns_for="subject_visit", export_folder=self.path, ) model_exporter.to_csv()
def test_records_to_csv_from_model(self): model_exporter = CsvModelExporter( model="edc_export.crf", sort_by=["subject_identifier", "visit_code"], export_folder=self.path, ) exported = model_exporter.to_csv() with open(exported.path, "r") as f: csv_reader = csv.DictReader(f, delimiter="|") rows = [row for row in enumerate(csv_reader)] self.assertEqual(len(rows), 4) for i, appointment in enumerate(Appointment.objects.all().order_by( "subject_identifier", "visit_code")): self.assertEqual(rows[i][1].get("subject_identifier"), appointment.subject_identifier) self.assertEqual(rows[i][1].get("visit_code"), appointment.visit_code)
def test_records_to_csv_from_qs(self): model_exporter = CsvModelExporter(queryset=Crf.objects.all(), export_folder=self.path) model_exporter.to_csv()