Adds start import view test

This commit is contained in:
Mouse Reeve 2021-08-06 11:43:55 -07:00
parent 0d2622e4ff
commit 568e30230a
7 changed files with 54 additions and 8 deletions

View file

@ -1,11 +1,12 @@
""" test for app action functionality """ """ test for app action functionality """
import pathlib
from unittest.mock import patch from unittest.mock import patch
from django.core.files.uploadedfile import SimpleUploadedFile
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.test import TestCase from django.test import TestCase
from django.test.client import RequestFactory from django.test.client import RequestFactory
from bookwyrm import models from bookwyrm import forms, models, views
from bookwyrm import views
class ImportViews(TestCase): class ImportViews(TestCase):
@ -47,6 +48,27 @@ class ImportViews(TestCase):
result.render() result.render()
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
def test_start_import(self):
"""retry failed items"""
view = views.Import.as_view()
form = forms.ImportForm()
form.data["source"] = "LibraryThing"
form.data["privacy"] = "public"
form.data["include_reviews"] = False
csv_file = pathlib.Path(__file__).parent.joinpath("../data/goodreads.csv")
form.data["csv_file"] = SimpleUploadedFile(
csv_file, open(csv_file, "rb").read(), content_type="text/csv"
)
request = self.factory.post("", form.data)
request.user = self.local_user
with patch("bookwyrm.importers.Importer.start_import"):
view(request)
job = models.ImportJob.objects.get()
self.assertFalse(job.include_reviews)
self.assertEqual(job.privacy, "public")
def test_retry_import(self): def test_retry_import(self):
"""retry failed items""" """retry failed items"""
view = views.ImportStatus.as_view() view = views.ImportStatus.as_view()

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.0.1\n" "Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-05 01:33+0000\n" "POT-Creation-Date: 2021-08-06 18:34+0000\n"
"PO-Revision-Date: 2021-03-02 17:19-0800\n" "PO-Revision-Date: 2021-03-02 17:19-0800\n"
"Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n" "Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n"
"Language-Team: English <LL@li.org>\n" "Language-Team: English <LL@li.org>\n"
@ -3295,6 +3295,10 @@ msgstr ""
msgid "%(title)s: %(subtitle)s" msgid "%(title)s: %(subtitle)s"
msgstr "" msgstr ""
#: bookwyrm/views/authentication.py:58
msgid "Username or password are incorrect"
msgstr ""
#: bookwyrm/views/import_data.py:67 #: bookwyrm/views/import_data.py:67
#, fuzzy #, fuzzy
#| msgid "Email address:" #| msgid "Email address:"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.0.1\n" "Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-05 01:33+0000\n" "POT-Creation-Date: 2021-08-06 18:34+0000\n"
"PO-Revision-Date: 2021-02-28 17:19-0800\n" "PO-Revision-Date: 2021-02-28 17:19-0800\n"
"Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n" "Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n"
"Language-Team: English <LL@li.org>\n" "Language-Team: English <LL@li.org>\n"
@ -2991,6 +2991,10 @@ msgstr ""
msgid "%(title)s: %(subtitle)s" msgid "%(title)s: %(subtitle)s"
msgstr "" msgstr ""
#: bookwyrm/views/authentication.py:58
msgid "Username or password are incorrect"
msgstr ""
#: bookwyrm/views/import_data.py:67 #: bookwyrm/views/import_data.py:67
msgid "Not a valid csv file" msgid "Not a valid csv file"
msgstr "" msgstr ""

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.0.1\n" "Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-05 01:33+0000\n" "POT-Creation-Date: 2021-08-06 18:34+0000\n"
"PO-Revision-Date: 2021-03-19 11:49+0800\n" "PO-Revision-Date: 2021-03-19 11:49+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -3036,6 +3036,10 @@ msgstr ""
msgid "%(title)s: %(subtitle)s" msgid "%(title)s: %(subtitle)s"
msgstr "" msgstr ""
#: bookwyrm/views/authentication.py:58
msgid "Username or password are incorrect"
msgstr ""
#: bookwyrm/views/import_data.py:67 #: bookwyrm/views/import_data.py:67
msgid "Not a valid csv file" msgid "Not a valid csv file"
msgstr "No un archivo csv válido" msgstr "No un archivo csv válido"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.1.1\n" "Project-Id-Version: 0.1.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-05 01:33+0000\n" "POT-Creation-Date: 2021-08-06 18:34+0000\n"
"PO-Revision-Date: 2021-04-05 12:44+0100\n" "PO-Revision-Date: 2021-04-05 12:44+0100\n"
"Last-Translator: Fabien Basmaison <contact@arkhi.org>\n" "Last-Translator: Fabien Basmaison <contact@arkhi.org>\n"
"Language-Team: Mouse Reeve <LL@li.org>\n" "Language-Team: Mouse Reeve <LL@li.org>\n"
@ -3015,6 +3015,10 @@ msgstr "Ce fichier dépasse la taille limite: 10Mo"
msgid "%(title)s: %(subtitle)s" msgid "%(title)s: %(subtitle)s"
msgstr "%(title)s (%(subtitle)s)" msgstr "%(title)s (%(subtitle)s)"
#: bookwyrm/views/authentication.py:58
msgid "Username or password are incorrect"
msgstr ""
#: bookwyrm/views/import_data.py:67 #: bookwyrm/views/import_data.py:67
msgid "Not a valid csv file" msgid "Not a valid csv file"
msgstr "Fichier CSV non valide" msgstr "Fichier CSV non valide"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.1.1\n" "Project-Id-Version: 0.1.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-05 01:33+0000\n" "POT-Creation-Date: 2021-08-06 18:34+0000\n"
"PO-Revision-Date: 2021-03-20 00:56+0000\n" "PO-Revision-Date: 2021-03-20 00:56+0000\n"
"Last-Translator: Kana <gudzpoz@live.com>\n" "Last-Translator: Kana <gudzpoz@live.com>\n"
"Language-Team: Mouse Reeve <LL@li.org>\n" "Language-Team: Mouse Reeve <LL@li.org>\n"
@ -2992,6 +2992,10 @@ msgstr "文件超过了最大大小: 10MB"
msgid "%(title)s: %(subtitle)s" msgid "%(title)s: %(subtitle)s"
msgstr "%(title)s%(subtitle)s" msgstr "%(title)s%(subtitle)s"
#: bookwyrm/views/authentication.py:58
msgid "Username or password are incorrect"
msgstr ""
#: bookwyrm/views/import_data.py:67 #: bookwyrm/views/import_data.py:67
msgid "Not a valid csv file" msgid "Not a valid csv file"
msgstr "不是有效的 csv 文件" msgstr "不是有效的 csv 文件"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.0.1\n" "Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-05 01:33+0000\n" "POT-Creation-Date: 2021-08-06 18:34+0000\n"
"PO-Revision-Date: 2021-06-30 10:36+0000\n" "PO-Revision-Date: 2021-06-30 10:36+0000\n"
"Last-Translator: Grace Cheng <chengracecwy@gmail.com>\n" "Last-Translator: Grace Cheng <chengracecwy@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -3011,6 +3011,10 @@ msgstr "檔案超過了最大大小: 10MB"
msgid "%(title)s: %(subtitle)s" msgid "%(title)s: %(subtitle)s"
msgstr "" msgstr ""
#: bookwyrm/views/authentication.py:58
msgid "Username or password are incorrect"
msgstr ""
#: bookwyrm/views/import_data.py:67 #: bookwyrm/views/import_data.py:67
msgid "Not a valid csv file" msgid "Not a valid csv file"
msgstr "不是有效的 csv 檔案" msgstr "不是有效的 csv 檔案"