Exemple #1
0
    def test_save_talk_proposal_with_new_speaker(self):
        data = {
            'talk_title': 'some title',
            'talk_description': 'some desc',
            'speaker_first_name': 'first',
            'speaker_last_name': 'last',
            'speaker_website': 'http://pywaw.org/',
            'speaker_phone': '123',
            'speaker_email': '*****@*****.**',
            'speaker_biography': 'short bio',
            'speaker_photo': files.create_inmemory_image(),
            'message': 'some comment',
        }
        request = self.factory.post(data=data)

        self.view(request, data=data)

        self.assertEqual(models.TalkProposal.objects.count(), 1)
        talk_proposal = models.TalkProposal.objects.get()
        self.assertEqual(talk_proposal.message, data['message'])
        talk = talk_proposal.talk
        self.assertEqual(talk.title, data['talk_title'])
        self.assertEqual(talk.description, data['talk_description'])
        self.assertEqual(talk.speakers.count(), 1)
        speaker = talk.speakers.get()
        self.assertEqual(speaker.first_name, data['speaker_first_name'])
        self.assertEqual(speaker.last_name, data['speaker_last_name'])
        self.assertEqual(speaker.website, data['speaker_website'])
        self.assertEqual(speaker.phone, data['speaker_phone'])
        self.assertEqual(speaker.email, data['speaker_email'])
        self.assertEqual(speaker.biography, data['speaker_biography'])
        self.assertTrue(speaker.photo)
Exemple #2
0
    def test_accepts_when_all_required_new_speaker_fields_are_set_and_existing_speaker_is_not(self):
        form = forms.TalkProposalForm(
            data={
                'talk_title': 'title',
                'talk_description': 'description',
                'speaker_first_name': 'first',
                'speaker_last_name': 'last',
                'speaker_phone': '123',
                'speaker_email': '*****@*****.**',
                'speaker_biography': 'short bio',
            },
            files={
                'speaker_photo': files.create_inmemory_image(),
            },
        )

        self.assertTrue(form.is_valid())
Exemple #3
0
    def test_make_inmemory_image_should_pass(self):
        file = files.create_inmemory_image('test.png', format='PNG')

        self.assertEqual(file.name, 'test.png')
Exemple #4
0
    def test_make_inmemory_image_should_pass(self):
        file = files.create_inmemory_image('test.png', format='PNG')

        self.assertEqual(file.name, 'test.png')