Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Feb 5, 2024
1 parent 27edf40 commit 0b186c1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions osf_tests/management_commands/test_recatalog_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,19 @@ def test_recatalog_metadata(
)
assert mock_update_share_task.apply_async.mock_calls == expected_apply_async_calls(registrations[2:6])

mock_update_share_task.reset_mock()

# datacite custom types
call_command(
'recatalog_metadata',
'--datacite-custom-types',
)
assert set(mock_update_share_task.apply_async.mock_calls) == set(
expected_apply_async_calls(items_with_custom_datacite_type),
)
_expected_osfids = set(_iter_osfids(items_with_custom_datacite_type))
_actual_osfids = {
_call[-1]['kwargs']['guid']
for _call in mock_update_share_task.apply_async.mock_calls
}
assert _expected_osfids == _actual_osfids


###
Expand All @@ -198,15 +203,20 @@ def expected_apply_async_calls(items):
return [
mock.call(
kwargs={
'guid': _item.guids.values_list('_id', flat=True).first(),
'guid': _osfid,
'is_backfill': True,
},
queue='low',
)
for _item in items
for _osfid in _iter_osfids(items)
]


def _iter_osfids(items):
for _item in items:
yield _item.guids.values_list('_id', flat=True).first()


def sorted_by_id(things_with_ids):
return sorted(
things_with_ids,
Expand Down

0 comments on commit 0b186c1

Please sign in to comment.