Skip to content
Permalink
Browse files
AIRAVATA-3420 Fix unit tests
  • Loading branch information
machristie committed Apr 27, 2021
1 parent 31d2d07 commit dc30954baee272c438b13b3b2ed3c4a09efbd496
Showing 2 changed files with 8 additions and 5 deletions.
@@ -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

@@ -11,6 +11,7 @@
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 @@ def setUp(self):
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 @@ def test_save_with_defaults(self):
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 @@ def test_save_with_name_and_content_type(self):
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):

0 comments on commit dc30954

Please sign in to comment.