Changeset 7951 for main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Timestamp:
- 22 Mar 2012, 07:21:20 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students/tests
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data.csv
r7643 r7951 1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone 2 X666666,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234 3 ,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234 4 ,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234 1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,reg_state 2 X666666,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,courses validated 3 ,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,courses validated 4 ,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,courses validated -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r7947 r7951 34 34 StudentProcessor, StudentStudyCourseProcessor, 35 35 StudentStudyLevelProcessor, CourseTicketProcessor, 36 StudentOnlinePaymentProcessor )36 StudentOnlinePaymentProcessor, StudentVerdictProcessor) 37 37 from waeup.kofa.students.student import Student 38 38 from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase … … 65 65 66 66 STUDYCOURSE_HEADER_FIELDS = STUDYCOURSE_SAMPLE_DATA.split( 67 '\n')[0].split(',') 68 69 VERDICT_SAMPLE_DATA = open( 70 os.path.join(os.path.dirname(__file__), 'sample_verdict_data.csv'), 71 'rb').read() 72 73 VERDICT_HEADER_FIELDS = VERDICT_SAMPLE_DATA.split( 67 74 '\n')[0].split(',') 68 75 … … 108 115 self.app = self.getRootFolder()['app'] 109 116 setSite(app) 110 111 # Import students with subobjects112 #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 117 118 118 # Populate university … … 126 126 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 127 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 128 return 134 129 … … 297 292 298 293 299 class StudentStudyCourseProcessorTest(FunctionalTestCase): 300 301 layer = FunctionalLayer 294 class StudentStudyCourseProcessorTest(StudentImportExportSetup): 302 295 303 296 def setUp(self): 304 297 super(StudentStudyCourseProcessorTest, self).setUp() 305 self.dc_root = tempfile.mkdtemp()306 self.workdir = tempfile.mkdtemp()307 app = University()308 app['datacenter'].setStoragePath(self.dc_root)309 self.getRootFolder()['app'] = app310 self.app = self.getRootFolder()['app']311 setSite(app)312 298 313 299 # Import students with subobjects … … 318 304 shutil.rmtree(os.path.dirname(fin_file)) 319 305 320 # Populate university321 self.certificate = createObject('waeup.Certificate')322 self.certificate.code = 'CERT1'323 self.certificate.application_category = 'basic'324 self.certificate.start_level = 200325 self.certificate.end_level = 500326 self.app['faculties']['fac1'] = Faculty()327 self.app['faculties']['fac1']['dep1'] = Department()328 self.app['faculties']['fac1']['dep1'].certificates.addCertificate(329 self.certificate)330 331 306 self.processor = StudentStudyCourseProcessor() 332 307 self.csv_file = os.path.join( … … 335 310 return 336 311 337 def tearDown(self):338 super(StudentStudyCourseProcessorTest, self).tearDown()339 shutil.rmtree(self.workdir)340 shutil.rmtree(self.dc_root)341 clearSite()342 return343 344 312 def test_interface(self): 345 313 # Make sure we fulfill the interface contracts. … … 384 352 shutil.rmtree(os.path.dirname(fin_file)) 385 353 386 class StudentStudyLevelProcessorTest(FunctionalTestCase): 387 388 layer = FunctionalLayer 354 class StudentVerdictProcessorTest(StudentImportExportSetup): 355 389 356 390 357 def setUp(self): 391 super(StudentStudyLevelProcessorTest, self).setUp() 392 self.dc_root = tempfile.mkdtemp() 393 self.workdir = tempfile.mkdtemp() 394 app = University() 395 app['datacenter'].setStoragePath(self.dc_root) 396 self.getRootFolder()['app'] = app 397 self.app = self.getRootFolder()['app'] 398 setSite(app) 358 super(StudentVerdictProcessorTest, self).setUp() 399 359 400 360 # Import students with subobjects … … 404 364 student_file, STUDENT_HEADER_FIELDS) 405 365 shutil.rmtree(os.path.dirname(fin_file)) 406 407 # Populate university408 self.certificate = createObject('waeup.Certificate')409 self.certificate.code = 'CERT1'410 self.certificate.application_category = 'basic'411 self.certificate.start_level = 200412 self.certificate.end_level = 500413 self.app['faculties']['fac1'] = Faculty()414 self.app['faculties']['fac1']['dep1'] = Department()415 self.app['faculties']['fac1']['dep1'].certificates.addCertificate(416 self.certificate)417 366 418 367 # Update study courses … … 425 374 shutil.rmtree(os.path.dirname(fin_file)) 426 375 376 self.processor = StudentVerdictProcessor() 377 self.csv_file = os.path.join( 378 self.workdir, 'sample_verdict_data.csv') 379 open(self.csv_file, 'wb').write(VERDICT_SAMPLE_DATA) 380 return 381 382 def test_import(self): 383 num, num_warns, fin_file, fail_file = self.processor.doImport( 384 self.csv_file, VERDICT_HEADER_FIELDS,'update') 385 self.assertEqual(num_warns,0) 386 studycourse = self.processor.getEntry(dict(reg_number='1'), self.app) 387 self.assertEqual(studycourse.certificate.code, u'CERT1') 388 shutil.rmtree(os.path.dirname(fin_file)) 389 390 391 class StudentStudyLevelProcessorTest(StudentImportExportSetup): 392 393 def setUp(self): 394 super(StudentStudyLevelProcessorTest, self).setUp() 395 396 # Import students with subobjects 397 student_file = os.path.join(self.workdir, 'sample_student_data.csv') 398 open(student_file, 'wb').write(STUDENT_SAMPLE_DATA) 399 num, num_warns, fin_file, fail_file = StudentProcessor().doImport( 400 student_file, STUDENT_HEADER_FIELDS) 401 shutil.rmtree(os.path.dirname(fin_file)) 402 403 # Update study courses 404 studycourse_file = os.path.join( 405 self.workdir, 'sample_studycourse_data.csv') 406 open(studycourse_file, 'wb').write(STUDYCOURSE_SAMPLE_DATA) 407 processor = StudentStudyCourseProcessor() 408 num, num_warns, fin_file, fail_file = processor.doImport( 409 studycourse_file, STUDYCOURSE_HEADER_FIELDS,'update') 410 shutil.rmtree(os.path.dirname(fin_file)) 411 427 412 self.processor = StudentStudyLevelProcessor() 428 413 self.csv_file = os.path.join( 429 414 self.workdir, 'sample_studylevel_data.csv') 430 415 open(self.csv_file, 'wb').write(STUDYLEVEL_SAMPLE_DATA) 431 432 def tearDown(self):433 super(StudentStudyLevelProcessorTest, self).tearDown()434 shutil.rmtree(self.workdir)435 shutil.rmtree(self.dc_root)436 clearSite()437 return438 416 439 417 def test_interface(self): … … 471 449 472 450 473 class CourseTicketProcessorTest(FunctionalTestCase): 474 475 layer = FunctionalLayer 451 class CourseTicketProcessorTest(StudentImportExportSetup): 476 452 477 453 def setUp(self): 478 454 super(CourseTicketProcessorTest, self).setUp() 479 self.dc_root = tempfile.mkdtemp()480 self.workdir = tempfile.mkdtemp()481 app = University()482 app['datacenter'].setStoragePath(self.dc_root)483 self.getRootFolder()['app'] = app484 self.app = self.getRootFolder()['app']485 setSite(app)486 455 487 456 # Import students with subobjects … … 492 461 shutil.rmtree(os.path.dirname(fin_file)) 493 462 494 # Populate university 495 self.certificate = createObject('waeup.Certificate') 496 self.certificate.code = 'CERT1' 497 self.certificate.application_category = 'basic' 498 self.certificate.start_level = 200 499 self.certificate.end_level = 500 500 self.app['faculties']['fac1'] = Faculty() 501 self.app['faculties']['fac1']['dep1'] = Department() 502 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 503 self.certificate) 463 # Add course and course referrer 504 464 self.course = createObject('waeup.Course') 505 465 self.course.code = 'COURSE1' … … 534 494 self.workdir, 'sample_courseticket_data.csv') 535 495 open(self.csv_file, 'wb').write(COURSETICKET_SAMPLE_DATA) 536 537 def tearDown(self):538 super(CourseTicketProcessorTest, self).tearDown()539 shutil.rmtree(self.workdir)540 shutil.rmtree(self.dc_root)541 clearSite()542 return543 496 544 497 def test_interface(self): … … 579 532 shutil.rmtree(os.path.dirname(fin_file)) 580 533 581 class PaymentProcessorTest(FunctionalTestCase): 582 583 layer = FunctionalLayer 534 class PaymentProcessorTest(StudentImportExportSetup): 584 535 585 536 def setUp(self): 586 537 super(PaymentProcessorTest, self).setUp() 587 self.dc_root = tempfile.mkdtemp()588 self.workdir = tempfile.mkdtemp()589 app = University()590 app['datacenter'].setStoragePath(self.dc_root)591 self.getRootFolder()['app'] = app592 self.app = self.getRootFolder()['app']593 setSite(app)594 538 595 539 # Add student with payment … … 616 560 self.workdir, 'sample_payment_data.csv') 617 561 open(self.csv_file, 'wb').write(PAYMENT_SAMPLE_DATA) 618 619 def tearDown(self):620 super(PaymentProcessorTest, self).tearDown()621 shutil.rmtree(self.workdir)622 shutil.rmtree(self.dc_root)623 clearSite()624 return625 562 626 563 def test_interface(self): … … 690 627 StudentProcessorTest,StudentStudyCourseProcessorTest, 691 628 StudentStudyLevelProcessorTest,CourseTicketProcessorTest, 692 PaymentProcessorTest, ]:629 PaymentProcessorTest,StudentVerdictProcessorTest]: 693 630 suite.addTest(unittest.TestLoader().loadTestsFromTestCase( 694 631 testcase
Note: See TracChangeset for help on using the changeset viewer.