From 07ef12ce8e02d187e109c9efde2a8720526782b6 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sun, 22 Oct 2023 17:26:27 +1100 Subject: [PATCH] fix tests and linting --- bookwyrm/models/bookwyrm_export_job.py | 2 +- bookwyrm/models/bookwyrm_import_job.py | 4 ++-- .../templates/settings/imports/imports.html | 21 ++++++++++--------- .../tests/models/test_bookwyrm_export_job.py | 5 ++--- .../tests/models/test_bookwyrm_import_job.py | 2 +- bookwyrm/tests/utils/test_tar.py | 2 +- bookwyrm/views/preferences/export.py | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bookwyrm/models/bookwyrm_export_job.py b/bookwyrm/models/bookwyrm_export_job.py index e3fb2a81f..1185c867a 100644 --- a/bookwyrm/models/bookwyrm_export_job.py +++ b/bookwyrm/models/bookwyrm_export_job.py @@ -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 = {} diff --git a/bookwyrm/models/bookwyrm_import_job.py b/bookwyrm/models/bookwyrm_import_job.py index 8fe797ed7..32c1a037a 100644 --- a/bookwyrm/models/bookwyrm_import_job.py +++ b/bookwyrm/models/bookwyrm_import_job.py @@ -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: diff --git a/bookwyrm/templates/settings/imports/imports.html b/bookwyrm/templates/settings/imports/imports.html index 0f4ae04fc..8898aab71 100644 --- a/bookwyrm/templates/settings/imports/imports.html +++ b/bookwyrm/templates/settings/imports/imports.html @@ -274,16 +274,17 @@ {% else %} {{ import.status }} + {% 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 }} + {% endif %} diff --git a/bookwyrm/tests/models/test_bookwyrm_export_job.py b/bookwyrm/tests/models/test_bookwyrm_export_job.py index 73b59a4cc..d3e81a161 100644 --- a/bookwyrm/tests/models/test_bookwyrm_export_job.py +++ b/bookwyrm/tests/models/test_bookwyrm_export_job.py @@ -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 diff --git a/bookwyrm/tests/models/test_bookwyrm_import_job.py b/bookwyrm/tests/models/test_bookwyrm_import_job.py index c07772e16..78a8ec160 100644 --- a/bookwyrm/tests/models/test_bookwyrm_import_job.py +++ b/bookwyrm/tests/models/test_bookwyrm_import_job.py @@ -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") diff --git a/bookwyrm/tests/utils/test_tar.py b/bookwyrm/tests/utils/test_tar.py index 5989d3bb9..d1945c735 100644 --- a/bookwyrm/tests/utils/test_tar.py +++ b/bookwyrm/tests/utils/test_tar.py @@ -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: diff --git a/bookwyrm/views/preferences/export.py b/bookwyrm/views/preferences/export.py index c55e12c86..f54d97ccb 100644 --- a/bookwyrm/views/preferences/export.py +++ b/bookwyrm/views/preferences/export.py @@ -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 }, )