Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
helrond committed Jan 21, 2025
1 parent 16ec48d commit d46158c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
.coverage
.tox

### App
/destination
/storage


### Django ###
*.log
*.pot
Expand Down
17 changes: 15 additions & 2 deletions package_review/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .clients import ArchivesSpaceClient, AWSClient
from .helpers import get_config
from .management.commands import (check_qc_status, discover_packages,
fetch_rights_statements,
fetch_rights_statements, remove_approved,
send_startup_message)
from .models import Package, RightsStatement

Expand Down Expand Up @@ -263,6 +263,18 @@ def test_handle(self, mock_rights):
self.assertEqual(RightsStatement.objects.all().count(), len(rights_statements))


class RemoveApprovedCommandTests(TestCase):

def test_handle(self):
"""Asserts command deletes only packages with missing binaries"""
create_packages()
copy_binaries()
shutil.rmtree(Path(settings.BASE_STORAGE_DIR, "9ba10e5461d401517b0e1a53d514ec87"))
remove_approved.Command().handle()
self.assertEqual(Package.objects.all().count(), 1)
self.assertEqual(Package.objects.all().first().refid, "f7d3dd6dc9c4732fa17dbd88fbe652b6")


class ViewMixinTests(TestCase):

def setUp(self):
Expand Down Expand Up @@ -304,7 +316,8 @@ def test_approve_view(self, mock_deliver, mock_init):
for package in Package.objects.all():
self.assertEqual(package.process_status, Package.APPROVED)
self.assertEqual(package.rights_ids, rights_list)
self.assertEqual(len(list(Path(settings.BASE_STORAGE_DIR).iterdir())), Package.objects.all().count())
self.assertEqual(len(list(Path(settings.BASE_DESTINATION_DIR).iterdir())), Package.objects.all().count())
self.assertEqual(len(list(Path(settings.BASE_STORAGE_DIR).iterdir())), 0)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse('package-list'))

Expand Down

0 comments on commit d46158c

Please sign in to comment.