Ejemplo n.º 1
0
    def test_matching_tutorials_unregister(self, mock_get):
        """Simple Test Case where matches occur and a User has unregistered"""
        user_model = get_user_model()
        u1 = user_model.objects.create_user('john', email='*****@*****.**', password='******')
        u2 = user_model.objects.create_user('jane', email='*****@*****.**', password='******')

        tut1 = PyConTutorialProposalFactory(title='Tutorial1')
        PresentationFactory(proposal_base=tut1)
        tut2 = PyConTutorialProposalFactory(title='Tutorial2')
        PresentationFactory(proposal_base=tut2)

        # Add u2 to tut2
        tut2.registrants.add(u2)
        self.assertIsNone(tut1.max_attendees)
        self.assertIn(u2, tut2.registrants.all())

        mock_get.return_value = MockGet(tut1=tut1.pk,
                                        tut2=tut2.pk,
                                        u1=u1.pk,
                                        u2=u2.pk)
        call_command('update_tutorial_registrants')

        tut1 = PyConTutorialProposal.objects.get(pk=tut1.pk)
        self.assertEqual(8, tut1.max_attendees)
        self.assertEqual(2, tut1.registrants.all().count())
        for u in [u1, u2]:
            self.assertIn(u, tut1.registrants.all())

        tut2 = PyConTutorialProposal.objects.get(pk=tut2.pk)
        self.assertEqual(10, tut2.max_attendees)
        # updated; dropping u2 and adding u1
        self.assertEqual(1, tut2.registrants.all().count())
        self.assertIn(u1, tut2.registrants.all())
Ejemplo n.º 2
0
    def test_tutorials_presentation(self):
        section = Section.objects.get(name='Tutorials')
        schedule = Schedule.objects.get(section=section)
        prop_kind = ProposalKind.objects.get(name__iexact='tutorial')
        proposal = PyConTutorialProposalFactory(kind=prop_kind, )
        day = Day.objects.create(schedule=schedule, date=date.today())
        kind = SlotKind.objects.create(schedule=schedule, label="Foo")
        slot = Slot.objects.create(
            day=day,
            kind=kind,
            start=now().time(),
            end=now().time(),
        )
        pres = PresentationFactory(
            title=proposal.title,
            abstract=proposal.abstract,
            section=section,
            slot=slot,
            cancelled=False,
            proposal_base=proposal,
        )
        rsp = self.client.get(self.url)
        self.assertEqual(OK, rsp.status_code)
        self.assertEqual('attachment; filename=program_export.zip',
                         rsp['Content-Disposition'])

        zipfile = ZipFile(StringIO(rsp.content), "r")
        # Check out the zip - testzip() returns None if no errors found
        self.assertIsNone(zipfile.testzip())

        fname = "program_export/presentations/csv/tutorials.csv"
        file_contents = zipfile.open(fname, "U").read().decode('utf-8')
        self.assertIn(pres.title, file_contents)
        self.assertIn(pres.abstract, file_contents)
Ejemplo n.º 3
0
 def setUp(self):
     super(TestTutorialMessageView, self).setUp()
     self.presentation = PresentationFactory(
         section__conference=Conference.objects.get(
             id=settings.CONFERENCE_ID))
     self.tutorial_url = reverse('schedule_presentation_detail',
                                 args=[self.presentation.pk])
     self.user = self.create_user()
Ejemplo n.º 4
0
 def setUp(self):
     self.auth_key = APIAuth.objects.create(name="test")
     self.presentation = PresentationFactory(
         video_url='http://video.example.com',
         assets_url='http://assets.example.com',
         slides_url='http://slides.example.com',
     )
     self.url = reverse('set_talk_urls', args=[self.presentation.slot.pk])
Ejemplo n.º 5
0
    def test_surprise_email_address(self, mock_get):
        """Simple Test Case where registrant has a different email than our DB"""
        user_model = get_user_model()
        u1 = user_model.objects.create_user('john', email='*****@*****.**', password='******')
        u2 = user_model.objects.create_user('jane', email='*****@*****.**', password='******')

        tut1 = PyConTutorialProposalFactory(title='Tutorial1')
        PresentationFactory(proposal_base=tut1)
        tut2 = PyConTutorialProposalFactory(title='Tutorial2')
        PresentationFactory(proposal_base=tut2)

        # Add u2 to tut2
        tut2.registrants.add(u2)
        self.assertIsNone(tut1.max_attendees)
        self.assertIn(u2, tut2.registrants.all())

        mock_get.return_value = MockGet(tut1=tut1.pk,
                                        tut2=tut2.pk,
                                        u1=u1.pk,
                                        u2=u2.pk)
        call_command('update_tutorial_registrants')

        tut1 = PyConTutorialProposal.objects.get(pk=tut1.pk)
        self.assertEqual(8, tut1.max_attendees)
        self.assertEqual(2, tut1.registrants.all().count())
        for u in [u1, u2]:
            self.assertIn(u, tut1.registrants.all())

        tut2 = PyConTutorialProposal.objects.get(pk=tut2.pk)
        self.assertEqual(10, tut2.max_attendees)
        # updated; dropping u2 and adding u1
        self.assertEqual(1, tut2.registrants.all().count())
        self.assertIn(u1, tut2.registrants.all())

        emails1 = EmailAddress.objects.filter(user=u1)
        emails2 = EmailAddress.objects.filter(user=u2)

        self.assertEqual(['*****@*****.**'], [e.email for e in emails1])
        self.assertEqual(
            sorted(['*****@*****.**', '*****@*****.**']),
            sorted([e.email for e in emails2])
        )
Ejemplo n.º 6
0
 def setUp(self):
     self.presentation = PresentationFactory()
     self.tutorial_url = reverse(
         'schedule_presentation_detail', args=[self.presentation.pk])
     self.user = self.create_user()
Ejemplo n.º 7
0
 def setUp(self):
     super(TestTutorialMessageView, self).setUp()
     self.presentation = PresentationFactory()
     self.tutorial_url = reverse('schedule_presentation_detail',
                                 args=[self.presentation.pk])
     self.user = self.create_user()
Ejemplo n.º 8
0
 def test_can_edit(self):
     # If a presentation has been created, speaker can no longer edit their proposal
     prop = ProposalBaseFactory()
     self.assertTrue(prop.can_edit())
     PresentationFactory(proposal_base=prop)
     self.assertFalse(prop.can_edit())