You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2021/04/27 16:30:06 UTC

[airavata-django-portal-sdk] 01/02: AIRAVATA-3420 Fix unit tests

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch mft-integration
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-sdk.git

commit dc30954baee272c438b13b3b2ed3c4a09efbd496
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Tue Apr 27 12:13:39 2021 -0400

    AIRAVATA-3420 Fix unit tests
---
 airavata_django_portal_sdk/user_storage/api.py | 4 ++--
 tests/test_user_storage.py                     | 9 ++++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/airavata_django_portal_sdk/user_storage/api.py b/airavata_django_portal_sdk/user_storage/api.py
index 9a45afc..16e0786 100644
--- a/airavata_django_portal_sdk/user_storage/api.py
+++ b/airavata_django_portal_sdk/user_storage/api.py
@@ -94,7 +94,7 @@ def save(request, path, file, name=None, content_type=None, storage_resource_id=
     backend = get_user_storage_provider(request, storage_resource_id=storage_resource_id)
     storage_resource_id, resource_path = backend.save(path, file, name=name, content_type=content_type)
     data_product = _save_data_product(
-        request, resource_path, storage_resource_id, name=name, content_type=content_type
+        request, resource_path, storage_resource_id, name=name, content_type=content_type, backend=backend
     )
     return data_product
 
@@ -121,7 +121,7 @@ def save_input_file(request, file, name=None, content_type=None, storage_resourc
         storage_resource_id, resource_path = backend.save(
             TMP_INPUT_FILE_UPLOAD_DIR, file, name=file_name)
         data_product = _save_data_product(
-            request, resource_path, storage_resource_id, name=name, content_type=content_type
+            request, resource_path, storage_resource_id, name=name, content_type=content_type, backend=backend
         )
         return data_product
 
diff --git a/tests/test_user_storage.py b/tests/test_user_storage.py
index a53922c..5d13b02 100644
--- a/tests/test_user_storage.py
+++ b/tests/test_user_storage.py
@@ -11,6 +11,7 @@ from airavata.model.data.replica.ttypes import (
     DataReplicaLocationModel,
     ReplicaLocationCategory
 )
+from airavata.model.security.ttypes import AuthzToken
 from django.contrib.auth.models import User
 from django.test import RequestFactory, TestCase, override_settings
 
@@ -32,7 +33,9 @@ class BaseTestCase(TestCase):
         self.product_uri = f"airavata-dp://{uuid.uuid4()}"
         self.request.airavata_client.registerDataProduct.return_value = \
             self.product_uri
-        self.request.authz_token = "dummy"
+        self.request.authz_token = AuthzToken(accessToken="dummy",
+                                              claimsMap={'gatewayID': GATEWAY_ID,
+                                                         'userName': self.user.username})
 
 
 class SaveTests(BaseTestCase):
@@ -60,7 +63,7 @@ class SaveTests(BaseTestCase):
             self.assertDictEqual({'mime-type': 'text/plain'},
                                  dp.productMetadata)
             self.assertEqual(1, len(dp.replicaLocations))
-            self.assertEqual(f"file://gateway.com:{path}/{file.name}",
+            self.assertEqual(f"{path}/{file.name}",
                              dp.replicaLocations[0].filePath)
 
     def test_save_with_name_and_content_type(self):
@@ -90,7 +93,7 @@ class SaveTests(BaseTestCase):
             self.assertDictEqual({'mime-type': 'application/some-app'},
                                  dp.productMetadata)
             self.assertEqual(1, len(dp.replicaLocations))
-            self.assertEqual(f"file://gateway.com:{path}/bar.txt",
+            self.assertEqual(f"{path}/bar.txt",
                              dp.replicaLocations[0].filePath)
 
     def test_save_with_unknown_text_file_type(self):