Changeset 6848
- Timestamp:
- 3 Oct 2011, 08:05:53 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students/tests
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_batching.py
r6846 r6848 47 47 '\n')[0].split(',') 48 48 49 STUDENT_SAMPLE_DATA_UPDATE = open( 50 os.path.join(os.path.dirname(__file__), 'sample_student_data_update.csv'), 51 'rb').read() 52 53 STUDENT_HEADER_FIELDS_UPDATE = STUDENT_SAMPLE_DATA_UPDATE.split( 54 '\n')[0].split(',') 55 56 STUDENT_SAMPLE_DATA = open( 57 os.path.join(os.path.dirname(__file__), 'sample_student_data.csv'), 58 'rb').read() 59 60 STUDENT_HEADER_FIELDS = STUDENT_SAMPLE_DATA.split( 61 '\n')[0].split(',') 62 49 63 STUDYCOURSE_SAMPLE_DATA = open( 50 64 os.path.join(os.path.dirname(__file__), 'sample_studycourse_data.csv'), … … 85 99 self.workdir = tempfile.mkdtemp() 86 100 self.csv_file = os.path.join(self.workdir, 'sample_student_data.csv') 101 self.csv_file_update = os.path.join(self.workdir, 'sample_student_data_update.csv') 87 102 open(self.csv_file, 'wb').write(STUDENT_SAMPLE_DATA) 103 open(self.csv_file_update, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE) 88 104 89 105 def tearDown(self): … … 106 122 def test_entryExists(self): 107 123 assert self.importer.entryExists( 108 dict(student_id='ID_NONE'), self.app) is False 109 student = dict(student_id=self.student.student_id), self.app) 124 dict(student_id='ID_NONE'), self.app) is None 125 student = self.importer.getEntry( 126 dict(student_id=self.student.student_id), self.app) 110 127 self.assertEqual(student.reg_number, u'123') 111 128 … … 130 147 assert self.student.student_id not in self.app['students'].keys() 131 148 149 def test_delEntry(self): 150 assert self.student.student_id in self.app['students'].keys() 151 self.importer.delEntry(dict(reg_number=self.student.reg_number), self.app) 152 assert self.student.student_id not in self.app['students'].keys() 153 132 154 def test_import(self): 133 155 num, num_warns, fin_file, fail_file = self.importer.doImport( … … 135 157 self.assertEqual(num_warns,0) 136 158 assert len(self.app['students'].keys()) == 4 159 shutil.rmtree(os.path.dirname(fin_file)) 160 161 def test_import_update(self): 162 num, num_warns, fin_file, fail_file = self.importer.doImport( 163 self.csv_file, STUDENT_HEADER_FIELDS) 164 shutil.rmtree(os.path.dirname(fin_file)) 165 num, num_warns, fin_file, fail_file = self.importer.doImport( 166 self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'update') 167 self.assertEqual(num_warns,0) 168 shutil.rmtree(os.path.dirname(fin_file)) 169 170 def test_import_remove(self): 171 num, num_warns, fin_file, fail_file = self.importer.doImport( 172 self.csv_file, STUDENT_HEADER_FIELDS) 173 shutil.rmtree(os.path.dirname(fin_file)) 174 num, num_warns, fin_file, fail_file = self.importer.doImport( 175 self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'remove') 176 self.assertEqual(num_warns,0) 137 177 shutil.rmtree(os.path.dirname(fin_file)) 138 178 … … 190 230 def test_entryExists(self): 191 231 assert self.importer.entryExists( 192 dict(reg_number='REG_NONE'), self.app) is False232 dict(reg_number='REG_NONE'), self.app) is None 193 233 student = self.importer.entryExists(dict(reg_number='1'), self.app) 194 234 self.assertEqual(student.reg_number, u'1')
Note: See TracChangeset for help on using the changeset viewer.