mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-30 05:21:08 +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()
|
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 = {}
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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")
|
||||||
|
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue