Skip to content

Commit

Permalink
Update fixture references to 'dsc'
Browse files Browse the repository at this point in the history
  • Loading branch information
ehanson8 committed Dec 11, 2024
1 parent 656bcbb commit 21414da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def config_instance() -> Config:
def mocked_s3(config_instance):
with mock_aws():
s3 = boto3.client("s3", region_name=config_instance.AWS_REGION_NAME)
s3.create_bucket(Bucket="awd")
s3.create_bucket(Bucket="dsc")
yield s3


Expand Down Expand Up @@ -130,11 +130,11 @@ def submission_message_body():
{
"SubmissionSystem": "DSpace@MIT",
"CollectionHandle": "123.4/5678",
"MetadataLocation": "s3://awd/10.1002-term.3131.json",
"MetadataLocation": "s3://dsc/10.1002-term.3131.json",
"Files": [
{
"BitstreamName": "10.1002-term.3131.pdf",
"FileLocation": "s3://awd/10.1002-term.3131.pdf",
"FileLocation": "s3://dsc/10.1002-term.3131.pdf",
"BitstreamDescription": None,
}
],
Expand Down
24 changes: 12 additions & 12 deletions tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,60 @@
def test_s3_archive_file_in_bucket(mocked_s3, s3_client):
s3_client.put_file(
file_content="test1,test2,test3,test4",
bucket="awd",
bucket="dsc",
key="test.csv",
)
s3_client.archive_file_with_new_key(
bucket="awd",
bucket="dsc",
key="test.csv",
archived_key_prefix="archived",
)
with pytest.raises(ClientError) as e:
response = s3_client.client.get_object(Bucket="awd", Key="test.csv")
response = s3_client.client.get_object(Bucket="dsc", Key="test.csv")
assert (
"An error occurred (NoSuchKey) when calling the GetObject operation: The"
" specified key does not exist." in str(e.value)
)
response = s3_client.client.get_object(Bucket="awd", Key="archived/test.csv")
response = s3_client.client.get_object(Bucket="dsc", Key="archived/test.csv")
assert response["ResponseMetadata"]["HTTPStatusCode"] == HTTPStatus.OK


def test_s3_put_file(mocked_s3, s3_client):
assert "Contents" not in s3_client.client.list_objects(Bucket="awd")
assert "Contents" not in s3_client.client.list_objects(Bucket="dsc")
s3_client.put_file(
file_content=str({"metadata": {"key": "dc.title", "value": "A Title"}}),
bucket="awd",
bucket="dsc",
key="test.json",
)
assert len(s3_client.client.list_objects(Bucket="awd")["Contents"]) == 1
assert len(s3_client.client.list_objects(Bucket="dsc")["Contents"]) == 1
assert (
s3_client.client.list_objects(Bucket="awd")["Contents"][0]["Key"] == "test.json"
s3_client.client.list_objects(Bucket="dsc")["Contents"][0]["Key"] == "test.json"
)


def test_s3_get_files_iter_with_matching_csv(mocked_s3, s3_client):
s3_client.put_file(
file_content="test1,test2,test3,test4",
bucket="awd",
bucket="dsc",
key="test.csv",
)
assert list(
s3_client.get_files_iter(
bucket="awd", file_type="csv", excluded_key_prefix="archived"
bucket="dsc", file_type="csv", excluded_key_prefix="archived"
)
) == ["test.csv"]


def test_s3_get_files_iter_without_matching_csv(mocked_s3, s3_client):
s3_client.put_file(
file_content="test1,test2,test3,test4",
bucket="awd",
bucket="dsc",
key="archived/test.csv",
)
assert (
list(
s3_client.get_files_iter(
bucket="awd", file_type="csv", excluded_key_prefix="archived"
bucket="dsc", file_type="csv", excluded_key_prefix="archived"
)
)
== []
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def test_sqs_create_dss_message_body(sqs_client, submission_message_body):
dss_message_body = sqs_client.create_dss_message_body(
submission_system="DSpace@MIT",
collection_handle="123.4/5678",
metadata_s3_uri="s3://awd/10.1002-term.3131.json",
metadata_s3_uri="s3://dsc/10.1002-term.3131.json",
bitstream_file_name="10.1002-term.3131.pdf",
bitstream_s3_uri="s3://awd/10.1002-term.3131.pdf",
bitstream_s3_uri="s3://dsc/10.1002-term.3131.pdf",
)
assert dss_message_body == submission_message_body

Expand Down

0 comments on commit 21414da

Please sign in to comment.