def test_list_keys_v2_http_prefix(mock_bucket, capsys, env_variables): mock_bucket.return_value = bucket_contents() list_keys_v2( prefix="source/", delimiter="", max_keys=1, http_prefix=True, key_methods="key", ) assert mock_bucket.called == True captured = capsys.readouterr() assert captured.out == "https://http_prefix.com/source/empty.txt\n"
def test_list_keys_v2_size(mock_bucket, capsys): mock_bucket.return_value = bucket_contents() list_keys_v2( prefix="source/", delimiter="", max_keys=1, http_prefix=False, key_methods="size", ) assert mock_bucket.called == True captured = capsys.readouterr() assert captured.out == "source/empty.txt -> 0.0Mb\n"
def test_list_keys_v2_no_key(mock_bucket, capsys): mock_bucket.return_value = bucket_contents() list_keys_v2( prefix="nothing_here/", delimiter="", max_keys=1, http_prefix=False, key_methods="key", ) assert mock_bucket.called == True captured = capsys.readouterr() assert captured.out == "No key was found!\n"
def test_list_keys_v2_delimiter(mock_bucket, capsys): mock_bucket.return_value = bucket_contents() list_keys_v2( prefix="delimiter/", delimiter="/", max_keys=1, http_prefix=False, key_methods="key", ) assert mock_bucket.called == True captured = capsys.readouterr() assert captured.out == "delimiter/delimiter/\n"
def test_list_keys_v2_last_modified(mock_bucket, capsys): mock_bucket.return_value = bucket_contents() list_keys_v2( prefix="source/", delimiter="", max_keys=1, http_prefix=False, key_methods="last_modified", ) assert mock_bucket.called == True captured = capsys.readouterr() captured_datetime = datetime.fromisoformat(captured.out.strip()) assert type(captured_datetime) is datetime
def test_list_keys_v2_owner(mock_bucket, capsys): mock_bucket.return_value = bucket_contents() list_keys_v2( prefix="source/", delimiter="", max_keys=1, http_prefix=False, key_methods="owner", ) assert mock_bucket.called == True captured = capsys.readouterr() assert ( captured.out == "{'DisplayName': 'webfile', 'ID': '75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a'}\n" )
def test_delete_origin_object(mock_bucket, capsys): mock_bucket.return_value = bucket_contents() move_object( origin_files=["source/empty.txt"], destination_path="source2", rename=None, permission=access_types.ACLTypes.public_read, threads=1, ) list_keys_v2( prefix="source/empty.txt", delimiter="", max_keys=1, http_prefix=False, key_methods=object_methods.ObjectMethods.key, ) assert mock_bucket.called == True captured = capsys.readouterr() assert captured.out == "No key was found!\n"