mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
fix tests and linting
This commit is contained in:
parent
0a2efeb5aa
commit
07ef12ce8e
7 changed files with 20 additions and 20 deletions
|
@ -69,7 +69,7 @@ def tar_export(json_data: str, user, file):
|
|||
file.close()
|
||||
|
||||
|
||||
def json_export(user):
|
||||
def json_export(user): # pylint: disable=too-many-locals, too-many-statements
|
||||
"""Generate an export for a user"""
|
||||
# user
|
||||
exported_user = {}
|
||||
|
|
|
@ -124,7 +124,7 @@ def get_or_create_edition(book_data, tar):
|
|||
):
|
||||
book[key] = edition[key]
|
||||
|
||||
existing = find_existing(models.Edition, book, None)
|
||||
existing = find_existing(models.Edition, book)
|
||||
if existing:
|
||||
return existing
|
||||
|
||||
|
@ -233,7 +233,7 @@ def get_or_create_authors(data):
|
|||
authors = []
|
||||
for author in data:
|
||||
clean = clean_values(author)
|
||||
existing = find_existing(models.Author, clean, None)
|
||||
existing = find_existing(models.Author, clean)
|
||||
if existing:
|
||||
authors.append(existing)
|
||||
else:
|
||||
|
|
|
@ -283,7 +283,8 @@
|
|||
{% else %}
|
||||
class="tag is-success"
|
||||
{% endif %}
|
||||
>{{ import.status }}</span></td>
|
||||
>{{ import.status }}
|
||||
</span>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
"""test bookwyrm user export functions"""
|
||||
import datetime
|
||||
import time
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
|
@ -227,8 +226,8 @@ class BookwyrmExport(TestCase):
|
|||
json_data["books"][0]["quotes"][0]["quote"], "A rose by any other name"
|
||||
)
|
||||
|
||||
def test_tar_export(self): # pylint: disable=unnecessary-pass
|
||||
def test_tar_export(self):
|
||||
"""test the tar export function"""
|
||||
|
||||
# TODO
|
||||
pass
|
||||
pass # pylint: disable=unnecessary-pass
|
||||
|
|
|
@ -306,7 +306,7 @@ class BookwyrmImport(TestCase):
|
|||
self.assertEqual(models.Edition.objects.first().openlibrary_key, "OL28216445M")
|
||||
|
||||
existing = bookwyrm_import_job.find_existing(
|
||||
models.Edition, {"openlibrary_key": "OL28216445M", "isbn_10": None}, None
|
||||
models.Edition, {"openlibrary_key": "OL28216445M", "isbn_10": None}
|
||||
)
|
||||
self.assertEqual(existing.title, "Test Book")
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ def read_tar():
|
|||
yield tar
|
||||
|
||||
|
||||
def get_write_tar():
|
||||
def write_tar():
|
||||
archive_path = "/tmp/test.tar.gz"
|
||||
with open(archive_path, "wb") as archive_file:
|
||||
with BookwyrmTarFile.open(mode="w:gz", fileobj=archive_file) as tar:
|
||||
|
|
|
@ -135,7 +135,7 @@ class ExportUser(View):
|
|||
|
||||
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
class ExportArchive(View): # pylint: disable=line-too-long
|
||||
class ExportArchive(View):
|
||||
"""Serve the archive file"""
|
||||
|
||||
def get(self, request, archive_id):
|
||||
|
@ -145,6 +145,6 @@ class ExportArchive(View): # pylint: disable=line-too-long
|
|||
export.export_data,
|
||||
content_type="application/gzip",
|
||||
headers={
|
||||
"Content-Disposition": 'attachment; filename="bookwyrm-account-export.tar.gz"'
|
||||
"Content-Disposition": 'attachment; filename="bookwyrm-account-export.tar.gz"' # pylint: disable=line-too-long
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue