1
0
Fork 0

fix tests and clean up

* cleans up some test logging
* cleans up some commented-out code
* adds export_job model tests
* reconsiders some tests in export user view tests
This commit is contained in:
Hugh Rundle 2023-10-15 15:09:19 +11:00
parent 688978369f
commit a4bfcb34d5
No known key found for this signature in database
GPG key ID: A7E35779918253F9
5 changed files with 261 additions and 46 deletions

View file

@ -49,26 +49,3 @@ class ExportUserViews(TestCase):
jobs = models.bookwyrm_export_job.BookwyrmExportJob.objects.count()
self.assertEqual(jobs, 1)
def test_download_export_user_file(self, *_):
"""simple user export"""
# TODO: need some help with this one
job = models.bookwyrm_export_job.BookwyrmExportJob.objects.create(
user=self.local_user
)
MockTask = namedtuple("Task", ("id"))
with patch(
"bookwyrm.models.bookwyrm_export_job.start_export_task.delay"
) as mock:
mock.return_value = MockTask(b'{"name": "mouse"}')
job.start_job()
request = self.factory.get("")
request.user = self.local_user
job.refresh_from_db()
export = views.ExportArchive.as_view()(request, job.id)
self.assertIsInstance(export, HttpResponse)
self.assertEqual(export.status_code, 200)
# pylint: disable=line-too-long
self.assertEqual(export.content, b'{"name": "mouse"}')