def test_messaging_as_speaker(self): speaker = SpeakerFactory(user=self.user) self.presentation.speaker = speaker self.presentation.save() self.login() rsp = self.client.get(self.tutorial_url) self.assertIn('id="messages"', rsp.content) # We can display the page prompting for a message to send them url = reverse( 'tutorial_message', kwargs={'pk': self.presentation.proposal.pk}) rsp = self.client.get(url) self.assertEqual(200, rsp.status_code) # "Send" a message to those two applications test_message = 'One if by land and two if by sea' data = {'message': test_message, } rsp = self.client.post(url, data=data) self.assertEqual(302, rsp.status_code) msg = PyConTutorialMessage.objects.get( user=self.user, tutorial=self.presentation.proposal) self.assertEqual(test_message, msg.message) # For each message, it's visible, so it should have been emailed to # both the other attendees and speakers. Total: 1 message for this case self.assertEqual(1, len(mail.outbox))
def test_cospeaker(self): # Avaialable to cospeakers speaker = SpeakerFactory(user=self.user) self.presentation.additional_speakers.add(speaker) self.login() rsp = self.client.get(self.tutorial_url) self.assertIn('id="messages"', rsp.content)
def test_speaker(self): # Avaialable to speakers speaker = SpeakerFactory(user=self.user) self.presentation.speaker = speaker self.presentation.save() self.login() rsp = self.client.get(self.tutorial_url)
def check_one_kind(self, kind_slug, factory): section_slug = kind_slug + "s" speaker = SpeakerFactory(user=self.create_user()) section = Section.objects.get(conference=current_conference(), slug=section_slug) kind, __ = ProposalKind.objects.get_or_create(slug=kind_slug, section=section) proposal = factory( kind=kind, speaker=speaker, ) # Create a new user to be the reviewer, because nobody # can review their own proposals. reviewer = self.create_user(username="******", email="*****@*****.**") ct = ContentType.objects.get_for_model(Review) perm = Permission.objects.get(content_type=ct, codename="can_review_%s" % section_slug) reviewer.user_permissions.add(perm) perm = Permission.objects.get(content_type=ct, codename="can_manage_%s" % section_slug) reviewer.user_permissions.add(perm) self.login(username="******") url = reverse('review_section', args=(section_slug, )) data = {'status': PyConProposal.STATUS_REJECTED, 'pk': proposal.pk} rsp = self.client.post(url, data, follow=False) self.assertRedirects(rsp, url) model = get_proposal_model(kind_slug) assert model prop = model.objects.get(pk=proposal.pk) self.assertEqual(PyConProposal.STATUS_REJECTED, prop.overall_status)
def test_create_edusummit_proposal(self): SpeakerFactory(user=self.create_user()) self.login() section = Section.objects.get(conference=current_conference(), slug='edusummits') psection = ProposalSection.objects.get(section=section) if not psection.is_available(): psection.closed = False psection.start = now() - timedelta(days=3) psection.end = now() + timedelta(days=3) psection.save() url = reverse('proposal_submit_kind', args=['edusummit']) data = { 'category': PyConProposalCategoryFactory().pk, 'audience_level': PyConTalkProposal.AUDIENCE_LEVEL_NOVICE, 'description': 'Rad', 'title': 'Massively rad', } self.assertFalse(EduSummitTalkProposal.objects.exists()) rsp = self.client.post(url, data) self.assertRedirects(rsp, reverse('dashboard')) # There should now be one prop = EduSummitTalkProposal.objects.get() self.assertEqual(data['description'], prop.description) self.assertEqual(data['title'], prop.title)
def test_post_email_from_speaker(self): # redirect to send email form, , speaker = SpeakerFactory(user=self.user) self.presentation.speaker = speaker self.presentation.save() self.login() data = {'email_action': '', 'user_1': 1} email_url = reverse('tutorial_email', kwargs={ 'pk': self.presentation.pk, 'pks': 1 }) rsp = self.client.post(self.tutorial_url, data) self.assertEqual(302, rsp.status_code) self.assertIn(email_url, rsp['Location'])
def test_email_submit_as_speaker(self, mock_queue_mail): attendee = self.create_user(username='******', email="*****@*****.**") speaker = SpeakerFactory(user=self.user) self.presentation.speaker = speaker self.presentation.save() self.login() # Actually submit the thing data = {'subject': 'Test Subject', 'body': 'Test Body'} # We can display the page prompting for a message to send them url = reverse('tutorial_email', kwargs={ 'pk': self.presentation.pk, 'pks': attendee.pk }) rsp = self.client.post(url, data) self.assertEqual(302, rsp.status_code, rsp.content) self.assertEqual(1, mock_queue_mail.call_count) args, kwargs = mock_queue_mail.call_args self.assertEqual(kwargs['bcc'][0], attendee.email)
def test_email_submit_as_attendee(self, mock_queue_mail): user = self.create_user('speaker', '*****@*****.**') speaker = SpeakerFactory(user=user) self.presentation.speaker = speaker self.presentation.save() self.presentation.proposal.registrants.add(self.user) self.login() data = {'subject': 'Test Subject', 'body': 'Test Body'} # We can display the page prompting for a message to send them url = reverse('tutorial_email', kwargs={ 'pk': self.presentation.pk, 'pks': self.presentation.speaker.user.pk }) rsp = self.client.post(url, data) self.assertEqual(302, rsp.status_code, rsp.content) self.assertEqual(1, mock_queue_mail.call_count) args, kwargs = mock_queue_mail.call_args email = self.presentation.speaker.user.email self.assertEqual(kwargs['bcc'][0], email)
def test_cospeaker(self): # Avaialable to cospeakers speaker = SpeakerFactory(user=self.user) self.presentation.additional_speakers.add(speaker) self.login() rsp = self.client.get(self.tutorial_url)