Skip to content

Commit

Permalink
updated unit tests, fixed linting, and updated agave function to tapis
Browse files Browse the repository at this point in the history
  • Loading branch information
asimregmi committed Sep 19, 2023
1 parent e637aa7 commit a4d43a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion server/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def agave_storage_system_mock():


@pytest.fixture
def agave_file_mock():
def tapis_file_mock():
with open(os.path.join(settings.BASE_DIR, 'fixtures/agave/files/file.json')) as f:
yield json.load(f)

Expand Down
8 changes: 3 additions & 5 deletions server/portal/apps/datafiles/views_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,15 @@ def test_tapis_file_view_put_is_logged_for_metrics(mock_indexer, client, authent
@patch('portal.libs.agave.operations.tapis_indexer')
def test_tapis_file_view_post_is_logged_for_metrics(mock_indexer, client, authenticated_user, mock_tapis_client,
logging_metric_mock,
agave_file_mock, requests_mock, text_file_fixture):
tapis_file_mock, requests_mock, text_file_fixture):

mock_tapis_client.access_token.access_token = "my_access_token"
requests_mock.post(f'{settings.TAPIS_TENANT_BASEURL}/v3/files/ops/frontera.home.username/text_file.txt',
json=agave_file_mock)
mock_tapis_client.files.insert.return_value = tapis_file_mock

response = client.post("/api/datafiles/tapis/upload/private/frontera.home.username/",
data={"uploaded_file": text_file_fixture})

assert response.status_code == 200
assert response.json() == {"data": agave_file_mock}
assert response.json() == {"data": tapis_file_mock}

# Ensure metric-related logging is being performed
logging_metric_mock.assert_called_with(
Expand Down
8 changes: 1 addition & 7 deletions server/portal/libs/agave/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from portal.libs.agave.filter_mapping import filter_mapping
from pathlib import Path
from tapipy.errors import BaseTapyException
import requests as r

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -448,14 +447,9 @@ def upload(client, system, path, uploaded_file):
file_listing = client.files.listFiles(systemId=system, path=path)
uploaded_file.name = increment_file_name(listing=file_listing, file_name=uploaded_file.name)

base_url = settings.TAPIS_TENANT_BASEURL
token = client.access_token.access_token
systemId = system
dest_path = os.path.join(path.strip('/'), uploaded_file.name)

response_json = client.files.insert(systemId=systemId, path = dest_path, file = uploaded_file)


response_json = client.files.insert(systemId=systemId, path=dest_path, file=uploaded_file)
tapis_indexer.apply_async(kwargs={'access_token': client.access_token.access_token,
'systemId': system,
'filePath': path,
Expand Down

0 comments on commit a4d43a3

Please sign in to comment.