コード例 #1
0
ファイル: test_forms.py プロジェクト: jorricarter/lmn
    def test_image_upload(self):
        form_data = {"title": "test", "text": "this is a test"}
        form = NewNoteForm(form_data)
        form.picture = File(open("lmn/tests/test2.jpg"))
        form.save()

        self.assertIsNotNone(form.picture)
コード例 #2
0
ファイル: test_forms.py プロジェクト: jorricarter/lmn
    def test_image_size(self):
        form_data = {"title": "test", "text": "this is a test"}
        form = NewNoteForm(form_data)
        form.picture = File(open("lmn/tests/test1.jpg"))

        with self.assertRaises(ValidationError):
            form.save()
コード例 #3
0
ファイル: test_forms.py プロジェクト: jorricarter/lmn
    def test_wrong_file_type_upload(self):
        form_data = {"title": "test", "text": "this is a test"}
        form = NewNoteForm(form_data)
        form.picture = File(open("testFile.txt", "w"))

        with self.assertRaises(ValidationError):
            form.save()
        os.remove('testFile.txt')
コード例 #4
0
ファイル: test_forms.py プロジェクト: jorricarter/lmn
    def test_upload_of_multiple_images(self):
        test_picture = File(open("lmn/tests/test3.jpg"))

        form_data = {"title": "test", "text": "this is a test"}
        form = NewNoteForm(form_data)
        form.picture = File(open("lmn/tests/test2.jpg"))
        form.picture = File(open("lmn/tests/test3.jpg"))
        form.save()

        self.assertEqual(form.picture.file, test_picture.file)