Skip to content

Commit

Permalink
Add test for no matching collection
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn committed Aug 12, 2024
1 parent 79e7b5d commit 667df5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arches_references/management/commands/controlled_lists.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from arches.app.models.models import Concept, Value
from arches.app.models.models import Value
from django.core.management.base import BaseCommand


Expand Down Expand Up @@ -99,7 +99,7 @@ def migrate_collections_to_controlled_lists(
]

if len(failed_collections) > 0:
self.stdout.write(
self.stderr.write(
"Failed to find the following collections in the database: %s"
% ", ".join(failed_collections)
)
Expand Down
15 changes: 15 additions & 0 deletions tests/cli_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,18 @@ def test_migrate_collections_to_controlled_lists(self):
imported_list = List.objects.get(name="Concept Label Import Test")
imported_items = imported_list.list_items.all()
self.assertEqual(len(imported_items), 3)

def test_no_matching_collection_error(self):
expected_output = "Failed to find the following collections in the database: Collection That Doesn't Exist"
with captured_stdout() as output:
management.call_command(
"controlled_lists",
operation="migrate_collections_to_controlled_lists",
collections_to_migrate=["Collection That Doesn't Exist"],
host="http://localhost:8000/plugins/controlled-list-manager/item/",
preferred_sort_language="en",
overwrite=False,
stdout=output,
stderr=output,
)
self.assertIn(expected_output, output.getvalue().strip())

0 comments on commit 667df5b

Please sign in to comment.