Skip to content

Commit

Permalink
DAS-2254: PR review updates
Browse files Browse the repository at this point in the history
use a config and verify it was used in a mock.
Mock Asset() call
  • Loading branch information
flamingbear committed Nov 27, 2024
1 parent 532d447 commit 66e5620
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/test_service/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ def test_process_sample_file(tmp_path, sample_datatree_file, sample_stac, mocker
filename_mock.return_value = output_filename

stage_mock = mocker.patch('harmony_service.adapter.stage')
stage_mock.return_value = 's3://bucketname/staged-location'
staging_dir = tmp_path / 'staging'

asset_mock = mocker.patch('harmony_service.adapter.Asset')

message = HarmonyMessage(
{
'accessToken': 'fake_token',
Expand All @@ -39,20 +42,21 @@ def test_process_sample_file(tmp_path, sample_datatree_file, sample_stac, mocker
)

# Set up Adapter class
the_config = config(validate=False)
smap_l2_gridding_service = SMAPL2GridderAdapter(
message, config=config(validate=False), catalog=sample_stac
message, config=the_config, catalog=sample_stac
)

# Invoke the adapter.
_, _ = smap_l2_gridding_service.invoke()
smap_l2_gridding_service.invoke()

asset_href = sample_stac.get_item('input granule').assets['input data'].href

download_mock.assert_called_once_with(
asset_href,
tmp_path,
logger=mocker.ANY,
cfg=mocker.ANY,
cfg=the_config,
access_token=message.accessToken,
)

Expand All @@ -65,6 +69,13 @@ def test_process_sample_file(tmp_path, sample_datatree_file, sample_stac, mocker
cfg=mocker.ANY,
)

asset_mock.assert_called_once_with(
's3://bucketname/staged-location',
title=mocker.ANY,
media_type='application/x-netcdf4',
roles=['data'],
)

# Validate the gridded output data
results = open_datatree(tmp_path / 'working_gridded.nc')
assert set(results.groups) == set(
Expand Down

0 comments on commit 66e5620

Please sign in to comment.