Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP-97: Fix skipped unit tests: TestAgaveUtils#test_walk_levels #926

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/portal/fixtures/agave/files/file.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"format": "raw",
"mimeType": "text/plain",
"type": "file",
"size":20,
"system": "portal.home.username",
"url": "tapis://portal/home/username/parent_folder/sub_folder/file.txt",
"_links": {
"self": {
"href": "https://api.tacc.utexas.edu/files/v2/media/system/portal.home.username//parent_folder/sub_folder/file.txt"
Expand Down
40 changes: 23 additions & 17 deletions server/portal/fixtures/agave/files/listing.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"format": "folder",
"mimeType": "text/directory",
"type": "dir",
"size": 2,
"system": "portal.home.username",
"url": "tapis://portal/home/username/parent_folder",
"_links": {
"self": {
"href": "https://api.tacc.utexas.edu/files/v2/media/system/portal.home.username//parent_folder"
Expand All @@ -33,6 +35,8 @@
"system": "portal.home.username",
"mimeType": "application/octet-stream",
"type": "file",
"size": 10,
"url": "tapis://portal/home/username/parent_folder/file_one.json",
"_links": {
"self": {
"href": "https://api.tacc.utexas.edu/files/v2/media/system/portal.home.username//parent_folder/file_one.json"
Expand All @@ -42,23 +46,25 @@
}
}
},
{
"name": "sub_folder",
"path": "/parent_folder/sub_folder",
"lastModified": "2018-09-11T11:39:53.000-05:00",
"length": 22,
"permissions": "ALL",
"format": "folder",
"system": "portal.home.username",
"mimeType": "text/directory",
"type": "dir",
"_links": {
"self": {
"href": "https://api.tacc.utexas.edu/files/v2/media/system/portal.home.username//parent_folder/sub_folder"
},
"system": {
"href": "https://api.tacc.utexas.edu/systems/v2/portal.home.username"
}
{
"name": "sub_folder",
"path": "/parent_folder/sub_folder",
"lastModified": "2018-09-11T11:39:53.000-05:00",
"length": 22,
"permissions": "ALL",
"format": "folder",
"system": "portal.home.username",
"mimeType": "text/directory",
"type": "dir",
"size": 1,
"url": "tapis://portal/home/username/parent_folder/sub_folder",
"_links": {
"self": {
"href": "https://api.tacc.utexas.edu/files/v2/media/system/portal.home.username//parent_folder/sub_folder"
},
"system": {
"href": "https://api.tacc.utexas.edu/systems/v2/portal.home.username"
}
}
}
]
51 changes: 6 additions & 45 deletions server/portal/libs/agave/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from django.test import TestCase
from django.conf import settings
from portal.libs.agave import utils as AgaveUtils
from unittest import skip
from tapipy.tapis import TapisResult

# pylint: disable=invalid-name
Expand Down Expand Up @@ -79,44 +78,6 @@ def test_to_camel_case(self):
res = AgaveUtils.to_camel_case(attr)
self.assertEqual(res, 'someAttribute')

@skip(reason="TODOv3: update for v3 tapis")
def test_walk(self):
"""Test `walk` util function."""
self.magave.reset_mock()
agave_dir = [obj for obj in self.agave_listing
if obj['type'] == 'dir' and obj['name'] != '.'][0]
sub_root = copy.deepcopy(agave_dir)
sub_root['name'] = '.'
self.magave.files.list.side_effect = [
self.agave_listing,
[sub_root, self.agave_file]
]
paths_visited = []
for child in AgaveUtils.walk(
self.magave,
self.agave_listing[0]['system'],
os.path.basename(self.agave_listing[0]['path'])
):
paths_visited.append(child.path)

self.assertEqual(
self.magave.files.list.call_args_list,
[call(
systemId=self.agave_listing[0]['system'],
filePath=os.path.basename(self.agave_listing[0]['path'])),
call(
systemId=agave_dir['system'],
filePath=agave_dir['path'])]
)
flat_listing = self.agave_listing + [self.agave_file]

for index, path in enumerate(paths_visited):
self.assertEqual(
path,
flat_listing[index]['path']
)

@skip(reason="TODOv3: update for v3 tapis")
def test_walk_levels(self):
"""Test `walk_levels` util."""
self.magave.reset_mock()
Expand All @@ -125,14 +86,14 @@ def test_walk_levels(self):
sub_root = copy.deepcopy(agave_dir)
sub_root['name'] = '.'
listings = [
self.agave_listing,
[sub_root, self.agave_file],
[TapisResult(**f) for f in self.agave_listing],
[TapisResult(**sub_root), TapisResult(**self.agave_file)],
]
listings_check = [
self.agave_listing,
[sub_root, self.agave_file],
]
self.magave.files.list.side_effect = listings
self.magave.files.listFiles.side_effect = listings

levels_visited = []

Expand All @@ -144,15 +105,15 @@ def test_walk_levels(self):
levels_visited.append((root, folders, files))

self.assertEqual(
self.magave.files.list.call_args_list,
self.magave.files.listFiles.call_args_list,
[call(
systemId=self.agave_listing[0]['system'],
filePath=self.agave_listing[0]['path'],
path=self.agave_listing[0]['path'],
offset=0,
limit=100),
call(
systemId=agave_dir['system'],
filePath=agave_dir['path'],
path=agave_dir['path'],
offset=0,
limit=100)
]
Expand Down