Ignore:
Timestamp:
22 Mar 2012, 03:18:04 (13 years ago)
Author:
uli
Message:

Create a setup for import/export tests. Could also be used in tests in
test_batching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r7933 r7947  
    9595    '\n')[0].split(',')
    9696
     97class StudentImportExportSetup(FunctionalTestCase):
     98
     99    layer = FunctionalLayer
     100
     101    def setUp(self):
     102        super(StudentImportExportSetup, self).setUp()
     103        self.dc_root = tempfile.mkdtemp()
     104        self.workdir = tempfile.mkdtemp()
     105        app = University()
     106        app['datacenter'].setStoragePath(self.dc_root)
     107        self.getRootFolder()['app'] = app
     108        self.app = self.getRootFolder()['app']
     109        setSite(app)
     110
     111        # Import students with subobjects
     112        #student_file = os.path.join(self.workdir, 'sample_student_data.csv')
     113        #open(student_file, 'wb').write(STUDENT_SAMPLE_DATA)
     114        #num, num_warns, fin_file, fail_file = StudentProcessor().doImport(
     115        #    student_file, STUDENT_HEADER_FIELDS)
     116        #shutil.rmtree(os.path.dirname(fin_file))
     117
     118        # Populate university
     119        self.certificate = createObject('waeup.Certificate')
     120        self.certificate.code = 'CERT1'
     121        self.certificate.application_category = 'basic'
     122        self.certificate.start_level = 200
     123        self.certificate.end_level = 500
     124        self.app['faculties']['fac1'] = Faculty()
     125        self.app['faculties']['fac1']['dep1'] = Department()
     126        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     127            self.certificate)
     128
     129        self.importer = StudentStudyCourseProcessor()
     130        self.csv_file = os.path.join(
     131            self.workdir, 'sample_studycourse_data.csv')
     132        open(self.csv_file, 'wb').write(STUDYCOURSE_SAMPLE_DATA)
     133        return
     134
     135    def tearDown(self):
     136        super(StudentImportExportSetup, self).tearDown()
     137        shutil.rmtree(self.workdir)
     138        shutil.rmtree(self.dc_root)
     139        clearSite()
     140        return
     141
     142
    97143class StudentProcessorTest(FunctionalTestCase):
    98144
Note: See TracChangeset for help on using the changeset viewer.