|
39 | 39 | from ietf.meeting.utils import finalize, condition_slide_order |
40 | 40 | from ietf.meeting.utils import add_event_info_to_session_qs |
41 | 41 | from ietf.meeting.utils import current_session_status |
| 42 | +from ietf.meeting.views import session_draft_list |
42 | 43 | from ietf.name.models import SessionStatusName, ImportantDateName |
43 | 44 | from ietf.utils.decorators import skip_coverage |
44 | 45 | from ietf.utils.mail import outbox, empty_outbox |
|
49 | 50 | from ietf.group.factories import GroupFactory, GroupEventFactory, RoleFactory |
50 | 51 | from ietf.meeting.factories import ( SessionFactory, SessionPresentationFactory, ScheduleFactory, |
51 | 52 | MeetingFactory, FloorPlanFactory, TimeSlotFactory, SlideSubmissionFactory ) |
52 | | -from ietf.doc.factories import DocumentFactory |
| 53 | +from ietf.doc.factories import DocumentFactory, WgDraftFactory |
53 | 54 | from ietf.submit.tests import submission_file |
54 | 55 |
|
55 | 56 |
|
@@ -504,37 +505,46 @@ def test_group_ical(self): |
504 | 505 | self.assertNotContains(r, t2.time.strftime('%Y%m%dT%H%M%S')) |
505 | 506 | self.assertContains(r, 'END:VEVENT') |
506 | 507 |
|
507 | | - def test_session_draft_tarfile(self): |
| 508 | + def build_session_setup(self): |
| 509 | + # This setup is intentionally unusual - the session has one draft attached as a session presentation, |
| 510 | + # but lists a different on in its agenda. The expectation is that the pdf and tgz views will return both. |
508 | 511 | session = SessionFactory(group__type_id='wg',meeting__type_id='ietf') |
509 | | - doc = DocumentFactory(type_id='draft') |
510 | | - session.sessionpresentation_set.create(document=doc) |
511 | | - file,_ = submission_file(name=doc.name,format='txt',templatename='test_submission.txt',group=session.group,rev="00") |
512 | | - filename = os.path.join(doc.get_file_path(),file.name) |
513 | | - with io.open(filename,'w') as draftbits: |
514 | | - draftbits.write(file.getvalue()) |
515 | | - |
| 512 | + draft1 = WgDraftFactory(group=session.group) |
| 513 | + session.sessionpresentation_set.create(document=draft1) |
| 514 | + draft2 = WgDraftFactory(group=session.group) |
| 515 | + agenda = DocumentFactory(type_id='agenda',group=session.group, uploaded_filename='agenda-%s-%s' % (session.meeting.number,session.group.acronym), states=[('agenda','active')]) |
| 516 | + session.sessionpresentation_set.create(document=agenda) |
| 517 | + self.write_materials_file(session.meeting, session.materials.get(type="agenda"), |
| 518 | + "1. WG status (15 minutes)\n\n2. Status of %s\n\n" % draft2.name) |
| 519 | + filenames = [] |
| 520 | + for d in (draft1, draft2): |
| 521 | + file,_ = submission_file(name=d.name,format='txt',templatename='test_submission.txt',group=session.group,rev="00") |
| 522 | + filename = os.path.join(d.get_file_path(),file.name) |
| 523 | + with io.open(filename,'w') as draftbits: |
| 524 | + draftbits.write(file.getvalue()) |
| 525 | + filenames.append(filename) |
| 526 | + self.assertEqual( len(session_draft_list(session.meeting.number,session.group.acronym)), 2) |
| 527 | + return (session, filenames) |
| 528 | + |
| 529 | + def test_session_draft_tarfile(self): |
| 530 | + session, filenames = self.build_session_setup() |
516 | 531 | url = urlreverse('ietf.meeting.views.session_draft_tarfile', kwargs={'num':session.meeting.number,'acronym':session.group.acronym}) |
517 | 532 | response = self.client.get(url) |
518 | 533 | self.assertEqual(response.status_code, 200) |
519 | 534 | self.assertEqual(response.get('Content-Type'), 'application/octet-stream') |
520 | | - os.unlink(filename) |
| 535 | + for filename in filenames: |
| 536 | + os.unlink(filename) |
521 | 537 |
|
522 | 538 | @skipIf(skip_pdf_tests, skip_message) |
523 | 539 | @skip_coverage |
524 | 540 | def test_session_draft_pdf(self): |
525 | | - session = SessionFactory(group__type_id='wg',meeting__type_id='ietf') |
526 | | - doc = DocumentFactory(type_id='draft') |
527 | | - session.sessionpresentation_set.create(document=doc) |
528 | | - file,_ = submission_file(name=doc.name,format='txt',templatename='test_submission.txt',group=session.group,rev="00") |
529 | | - filename = os.path.join(doc.get_file_path(),file.name) |
530 | | - with io.open(filename,'w') as draftbits: |
531 | | - draftbits.write(file.getvalue()) |
532 | | - |
| 541 | + session, filenames = self.build_session_setup() |
533 | 542 | url = urlreverse('ietf.meeting.views.session_draft_pdf', kwargs={'num':session.meeting.number,'acronym':session.group.acronym}) |
534 | 543 | response = self.client.get(url) |
535 | 544 | self.assertEqual(response.status_code, 200) |
536 | 545 | self.assertEqual(response.get('Content-Type'), 'application/pdf') |
537 | | - os.unlink(filename) |
| 546 | + for filename in filenames: |
| 547 | + os.unlink(filename) |
538 | 548 |
|
539 | 549 | def test_current_materials(self): |
540 | 550 | url = urlreverse('ietf.meeting.views.current_materials') |
|
0 commit comments