fix tests and linting

This commit is contained in:
Hugh Rundle 2023-10-22 17:26:27 +11:00
parent 0a2efeb5aa
commit 07ef12ce8e
No known key found for this signature in database
GPG key ID: A7E35779918253F9
7 changed files with 20 additions and 20 deletions

View file

@ -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 = {}

View file

@ -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:

View file

@ -274,16 +274,17 @@
{% else %}
<td>
<span
{% if import.status == "stopped" or import.status == "failed" %}
class="tag is-danger"
{% elif import.status == "pending" %}
class="tag is-warning"
{% elif import.complete %}
class="tag"
{% else %}
class="tag is-success"
{% endif %}
>{{ import.status }}</span></td>
{% if import.status == "stopped" or import.status == "failed" %}
class="tag is-danger"
{% elif import.status == "pending" %}
class="tag is-warning"
{% elif import.complete %}
class="tag"
{% else %}
class="tag is-success"
{% endif %}
>{{ import.status }}
</span>
</td>
{% endif %}
</tr>

View file

@ -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

View file

@ -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")

View file

@ -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:

View file

@ -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
},
)