Changeset 11790 for main/waeup.kofa/trunk/src
- Timestamp:
- 1 Sep 2014, 12:05:55 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/university
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/university/batching.py
r11779 r11790 353 353 iface = ICertificateCourse 354 354 355 location_fields = ['c ourse', 'level', 'faculty_code', 'department_code',356 ' certificate_code',]355 location_fields = ['certificate_code', 'course', 'level', 'faculty_code', 356 'department_code',] 357 357 factory_name = 'waeup.CertificateCourse' 358 358 -
main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py
r9754 r11790 81 81 '\n')[0].split(',') 82 82 83 84 CERTIFICATECOURSE_SAMPLE_DATA = open( 85 os.path.join(os.path.dirname(__file__), 'sample_certificatecourse_data.csv'), 86 'rb').read() 87 88 CERTIFICATECOURSE_HEADER_FIELDS = CERTIFICATECOURSE_SAMPLE_DATA.split( 89 '\n')[0].split(',') 90 83 91 class UniversityProcessorSetup(FunctionalTestCase): 84 92 … … 90 98 self.workdir = tempfile.mkdtemp() 91 99 app = University() 100 app['datacenter'].setStoragePath(self.dc_root) 92 101 self.getRootFolder()['app'] = app 93 102 self.app = self.getRootFolder()['app'] … … 312 321 # Logging message from updateEntry 313 322 self.assertTrue( 314 'INFO - system - Department Processor - sample_department_data ' 315 '- DEP2 - updated: local_roles=anne|waeup.local.DepartmentManager, ' 316 'code=DEP2\n' 323 'INFO - system - Faculty Processor - sample_faculty_data_update - ' 324 'FAC1 - updated: code=FAC1' 325 in logcontent) 326 self.assertTrue( 327 'INFO - system - Faculty Processor - sample_faculty_data_update - ' 328 'FAC2 - updated: local_roles=bob|waeup.local.DepartmentManager, ' 329 'code=FAC2' 330 in logcontent) 331 self.assertTrue( 332 'INFO - system - Faculty Processor - sample_faculty_data_update - ' 333 'FAC3 - updated: code=FAC3' 334 in logcontent) 335 self.assertTrue( 336 'INFO - system - Faculty Processor - sample_faculty_data_update - ' 337 'FAC4 - updated: code=FAC4' 317 338 in logcontent) 318 339 shutil.rmtree(os.path.dirname(fin_file)) … … 636 657 637 658 638 class CertCourseProcessorTests( FunctionalTestCase):659 class CertCourseProcessorTests(UniversityProcessorSetup): 639 660 640 661 layer = FunctionalLayer … … 643 664 super(CertCourseProcessorTests, self).setUp() 644 665 self.proc = CertificateCourseProcessor() 645 self.site0 = dict() 646 self.site1 = dict(faculties=dict()) 647 self.site2 = dict(faculties=dict(FAC=dict())) 648 self.department1 = Department(code='DPT') 649 self.department2 = Department(code='DPT') 650 self.certificate = Certificate(code='CRT') 651 self.department2.certificates['CRT'] = self.certificate 652 self.course = Course(code='CRS') 653 self.department2.certificates['CRT'].addCertCourse(self.course) 654 self.cert_course = self.certificate['CRS_100'] 655 self.department2.courses['CRS'] = self.course 656 self.site3 = dict(faculties=dict(FAC=dict(DPT=self.department1))) 657 self.site4 = dict(faculties=dict(FAC=dict(DPT=self.department2))) 658 self.row = dict( 659 department_code='DPT', 660 faculty_code='FAC', 661 certificate_code='CRT', 662 course=self.course, level='100', 663 code='CRS_100') 666 self.certificate.addCertCourse(self.course) 667 self.row1 = dict( 668 department_code='DEP1', 669 faculty_code='FAC1', 670 certificate_code='CRT1', 671 course=self.course, level='100') 672 self.row2 = dict( 673 department_code='DEP1', 674 faculty_code='FAC1', 675 certificate_code='CRT2', 676 course=self.course, level='100') 677 self.csv_file_certificatecourse = os.path.join( 678 self.workdir, 'sample_certificatecourse_data.csv') 679 open(self.csv_file_certificatecourse, 'wb').write(CERTIFICATECOURSE_SAMPLE_DATA) 664 680 return 665 681 … … 672 688 def test_parents_exist(self): 673 689 # make sure we can find all certificate parents 674 result0 = self.proc.parentsExist(self.row, self.site0) 675 result1 = self.proc.parentsExist(self.row, self.site1) 676 result2 = self.proc.parentsExist(self.row, self.site2) 677 result3 = self.proc.parentsExist(self.row, self.site3) 678 result4 = self.proc.parentsExist(self.row, self.site4) 679 self.assertTrue(result0 is False) 680 self.assertTrue(result1 is False) 681 self.assertTrue(result2 is False) 682 self.assertTrue(result3 is False) 683 self.assertTrue(result4 is True) 690 result1 = self.proc.parentsExist(self.row1, self.app) 691 self.assertTrue(result1) 692 result2 = self.proc.parentsExist(self.row2, self.app) 693 self.assertFalse(result2) 684 694 return 685 695 686 696 def test_entry_exists(self): 687 697 # make sure we find an entry if it exists 688 result0 = self.proc.entryExists(self.row, self.site0) 689 result1 = self.proc.entryExists(self.row, self.site1) 690 result2 = self.proc.entryExists(self.row, self.site2) 691 result3 = self.proc.entryExists(self.row, self.site3) 692 result4 = self.proc.entryExists(self.row, self.site4) 693 self.assertTrue(result0 is False) 694 self.assertTrue(result1 is False) 695 self.assertTrue(result2 is False) 696 self.assertTrue(result3 is False) 697 self.assertTrue(result4 is True) 698 result1 = self.proc.entryExists(self.row1, self.app) 699 self.assertTrue(result1) 700 result2 = self.proc.entryExists(self.row2, self.app) 701 self.assertFalse(result2) 698 702 return 699 703 700 704 def test_get_entry(self): 701 705 # make sure we can get an entry if it exists 702 result1 = self.proc.getEntry(self.row , self.site3)703 result2 = self.proc.getEntry(self.row, self.site4)704 self.assertTrue(result1 is None)705 self.assert True(result2 is self.cert_course)706 result1 = self.proc.getEntry(self.row1, self.app) 707 self.assertTrue(result1 is self.certificate['CRS1_100']) 708 result2 = self.proc.getEntry(self.row2, self.app) 709 self.assertFalse(result2 is self.certificate['CRS1_100']) 706 710 return 707 711 708 712 def test_del_entry(self): 709 713 # make sure we can delete entries 710 self.assertTrue('CRS_100' in self.certificate.keys()) 711 self.proc.delEntry(self.row, self.site4) 712 self.assertTrue('CRS_100' not in self.certificate.keys()) 713 return 714 self.assertTrue('CRS1_100' in self.certificate.keys()) 715 self.proc.delEntry(self.row1, self.app) 716 self.assertTrue('CRS1_100' not in self.certificate.keys()) 717 return 718 719 def test_import(self): 720 num, num_warns, fin_file, fail_file = self.proc.doImport( 721 self.csv_file_certificatecourse, CERTIFICATECOURSE_HEADER_FIELDS) 722 content = open(fail_file).read() 723 self.assertEqual(num_warns,2) 724 self.assertEqual( 725 content, 726 'faculty_code,course,level,department_code,certificate_code,' 727 '--ERRORS--\r\nFAC1,CRS1,100,DEP1,CRT1,' 728 'This object already exists. Skipping.\r\nFAC1,CRS1,100,DEP1,CRT2,' 729 'Not all parents do exist yet. Skipping\r\n' 730 731 ) 732 logcontent = open(self.logfile).read() 733 # Logging message from updateEntry 734 self.assertTrue( 735 'INFO - system - CertificateCourse Processor - ' 736 'sample_certificatecourse_data - CRT1 - updated: ' 737 'course=CRS1, level=200\n' 738 in logcontent) 739 740 return
Note: See TracChangeset for help on using the changeset viewer.