Merge pull request #3056 from hughrun/user-migrate

fix tests and linting
This commit is contained in:
Hugh Rundle 2023-10-22 17:27:57 +11:00 committed by GitHub
commit c5e536aeaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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() file.close()
def json_export(user): def json_export(user): # pylint: disable=too-many-locals, too-many-statements
"""Generate an export for a user""" """Generate an export for a user"""
# user # user
exported_user = {} exported_user = {}

View file

@ -124,7 +124,7 @@ def get_or_create_edition(book_data, tar):
): ):
book[key] = edition[key] book[key] = edition[key]
existing = find_existing(models.Edition, book, None) existing = find_existing(models.Edition, book)
if existing: if existing:
return existing return existing
@ -233,7 +233,7 @@ def get_or_create_authors(data):
authors = [] authors = []
for author in data: for author in data:
clean = clean_values(author) clean = clean_values(author)
existing = find_existing(models.Author, clean, None) existing = find_existing(models.Author, clean)
if existing: if existing:
authors.append(existing) authors.append(existing)
else: else:

View file

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

View file

@ -1,6 +1,5 @@
"""test bookwyrm user export functions""" """test bookwyrm user export functions"""
import datetime import datetime
import time
import json import json
from unittest.mock import patch 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" 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""" """test the tar export function"""
# TODO # 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") self.assertEqual(models.Edition.objects.first().openlibrary_key, "OL28216445M")
existing = bookwyrm_import_job.find_existing( 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") self.assertEqual(existing.title, "Test Book")

View file

@ -10,7 +10,7 @@ def read_tar():
yield tar yield tar
def get_write_tar(): def write_tar():
archive_path = "/tmp/test.tar.gz" archive_path = "/tmp/test.tar.gz"
with open(archive_path, "wb") as archive_file: with open(archive_path, "wb") as archive_file:
with BookwyrmTarFile.open(mode="w:gz", fileobj=archive_file) as tar: 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") @method_decorator(login_required, name="dispatch")
class ExportArchive(View): # pylint: disable=line-too-long class ExportArchive(View):
"""Serve the archive file""" """Serve the archive file"""
def get(self, request, archive_id): def get(self, request, archive_id):
@ -145,6 +145,6 @@ class ExportArchive(View): # pylint: disable=line-too-long
export.export_data, export.export_data,
content_type="application/gzip", content_type="application/gzip",
headers={ headers={
"Content-Disposition": 'attachment; filename="bookwyrm-account-export.tar.gz"' "Content-Disposition": 'attachment; filename="bookwyrm-account-export.tar.gz"' # pylint: disable=line-too-long
}, },
) )