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

tests should be perfomed in a clear manner

parent b066e200
No related branches found
No related tags found
1 merge request!231Resolve "auto-import of subject data"
Pipeline #24425 passed
......@@ -6,7 +6,7 @@ import logging
from django.test import TestCase
from mock_reader import MockReader
from tests.functions import create_study_subject
from web.tests.functions import create_study_subject
from web.importer import Importer
from web.models import Subject, StudySubject, Study
from web.models.constants import GLOBAL_STUDY_ID
......
# coding=utf-8
import logging
import tempfile
from shutil import copyfile
from django.conf import settings
from django.test import TestCase
......@@ -15,6 +17,9 @@ from django_cron.models import CronJobLog
class TestCronJobImporter(TestCase):
def tearDown(self):
setattr(settings, "DAILY_IMPORT_FILE", None)
def test_import_without_configuration(self):
CronJobLog.objects.all().delete()
......@@ -27,7 +32,10 @@ class TestCronJobImporter(TestCase):
def test_import(self):
filename = get_resource_path('import.csv')
setattr(settings, "DAILY_IMPORT_FILE", filename)
new_file, tmp = tempfile.mkstemp()
copyfile(filename, tmp)
setattr(settings, "DAILY_IMPORT_FILE", tmp)
CronJobLog.objects.all().delete()
job = ImporterCronJob()
......@@ -36,5 +44,3 @@ class TestCronJobImporter(TestCase):
self.assertEqual("import is successful", status)
self.assertEqual(1, len(mail.outbox))
setattr(settings, "DAILY_IMPORT_FILE", None)
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