Skip to content

Commit

Permalink
Update tests to new utilities base class
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgarde committed Nov 30, 2023
1 parent 996b1e1 commit 366faa9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
1 change: 0 additions & 1 deletion tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
TEST_ARN = 'ABC123'

with (
patch('boto3.client'),
patch.dict(os.environ, {
'SWODLR_ENV': 'dev',
'SWODLR_stepfunction_arn': TEST_ARN
Expand Down
7 changes: 3 additions & 4 deletions tests/test_poll_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from pathlib import Path
import json
from os import environ
from podaac.swodlr_ingest_to_sds import utils
from podaac.swodlr_ingest_to_sds.utilities import utils

with (
patch('boto3.client'),
patch('boto3.resource'),
patch.dict(environ, {
'SWODLR_ENV': 'dev',
'SWODLR_sds_username': 'AAAAAA',
Expand All @@ -25,7 +23,8 @@ class TestPollStatus(TestCase):
with open(poll_event_path, encoding='utf-8') as f:
poll_event = json.load(f)

def test_poll_status(self):
@patch('boto3.resource')
def test_poll_status(self, _):
'''
Test the lambda handler for the poll_status module by submitting two
jobs, polling their status, verifying that the correct jobs are
Expand Down
18 changes: 9 additions & 9 deletions tests/test_submit_to_sds.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'''Tests for the submit_to_sds module'''
from unittest import TestCase
from unittest.mock import patch
import importlib
from pathlib import Path
import json
from os import environ


with (
patch('boto3.client'),
patch('boto3.resource'),
patch('otello.mozart.Mozart.get_job_type'),
patch.dict(environ, {
'SWODLR_ENV': 'dev',
'SWODLR_sds_username': 'test_username',
'SWODLR_sds_password': 'test_password',
'SWODLR_ingest_table_name': 'test_ingest_table_name',
'SWODLR_ingest_queue_url': 'test_ingest_queue_url'
'SWODLR_ingest_queue_url': 'test_ingest_queue_url',
'SWODLR_available_tiles_table': 'test_available_tiles_table'
})
):
from podaac.swodlr_ingest_to_sds import submit_to_sds, utils

from podaac.swodlr_ingest_to_sds import submit_to_sds

class TestSubmitToSds(TestCase):
'''Tests for the submit_to_sds module'''
Expand All @@ -32,7 +32,8 @@ class TestSubmitToSds(TestCase):
with open(invalid_event_path, encoding='utf-8') as f:
invalid_event = json.load(f)

def test_valid_submit(self):
@patch('boto3.resource')
def test_valid_submit(self, _):
'''
Test the lambda handler for the submit_to_sds module by submitting
three jobs, verifying all jobs are submitted, and verifying that
Expand All @@ -45,7 +46,7 @@ def test_valid_submit(self):
input_calls = submit_to_sds.ingest_job_type.set_input_params\
.call_args_list
# pylint: disable=no-member,unnecessary-dunder-call
put_item_calls = utils.ingest_table.batch_writer().__enter__()\
put_item_calls = submit_to_sds.utils.ingest_table.batch_writer().__enter__()\
.put_item.call_args_list

self.assertEqual(len(input_calls), 3)
Expand Down Expand Up @@ -103,7 +104,8 @@ def test_valid_submit(self):
{'granule_id': {'S': 'test-2'}},
{'granule_id': {'S': 'test-3'}},
],
'ProjectionExpression': 'granule_id'
'ProjectionExpression': 'granule_id, #status',
'ExpressionAttributeNames': {'#status': 'status'}
}
},
ReturnConsumedCapacity='NONE'
Expand All @@ -124,6 +126,4 @@ def tearDown(self):

submit_to_sds.ingest_job_type.set_input_params.reset_mock()
submit_to_sds.ingest_job_type.submit_job.reset_mock()
# pylint: disable=unnecessary-dunder-call
utils.ingest_table.batch_writer().__enter__().put_item.reset_mock()
submit_to_sds.dynamodb.batch_get_item.reset_mock()

0 comments on commit 366faa9

Please sign in to comment.