Skip to content

Commit

Permalink
added additional link list tests (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey authored Jan 16, 2025
1 parent f3bc695 commit 43e1961
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
1 change: 1 addition & 0 deletions hsds/link_sn.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def GET_Links(request):
log.request(request)
app = request.app
params = request.rel_url.query
log.debug(f"GET_Links params: {params}")

group_id = request.match_info.get("id")

Expand Down
56 changes: 52 additions & 4 deletions tests/integ/link_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1717,11 +1717,26 @@ def testLinkCreationOrder(self):
grp_id = rspJson["id"]
self.assertTrue(helper.validateId(grp_id))

link_names = [
"first",
"second",
"third",
"fourth",
"fifth",
"sixth",
"seventh",
"eighth",
"ninth",
"tenth",
"eleventh",
"twelfth",
]

# create soft links under the group in sequence
link_count = 10
link_count = len(link_names)

for i in range(link_count):
title = f"link_{i}"
title = link_names[i]
req = helper.getEndpoint() + f"/groups/{grp_id}/links/{title}"
body = {"h5path": f"some_path_{i}"}
rsp = self.session.put(req, data=json.dumps(body), headers=headers)
Expand All @@ -1740,11 +1755,44 @@ def testLinkCreationOrder(self):
prev_link = links_json[i]
link = links_json[i + 1]

self.assertEqual(prev_link['title'], f"link_{i}")
self.assertEqual(link['title'], f"link_{i + 1}")
self.assertEqual(prev_link['title'], link_names[i])
self.assertEqual(link['title'], link_names[i + 1])

self.assertTrue(prev_link["created"] < link["created"])

# retrieve all links in grp in alphanumeric order
req = helper.getEndpoint() + f"/groups/{grp_id}/links"
params = {} # default should be alphanumeric
rsp = self.session.get(req, params=params, headers=headers)
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
links_json = rspJson["links"]
print("params:", params)

# verify the links are in order
for i in range(link_count - 1):
prev_link = links_json[i]
link = links_json[i + 1]

self.assertEqual(prev_link['title'], sorted(link_names)[i])
self.assertEqual(link['title'], sorted(link_names)[i + 1])

# retrieve all links in grp in alphanumeric order
req = helper.getEndpoint() + f"/groups/{grp_id}/links"
params = {"CreateOrder": 0}
rsp = self.session.get(req, params=params, headers=headers)
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
links_json = rspJson["links"]

# verify the links are in order
for i in range(link_count - 1):
prev_link = links_json[i]
link = links_json[i + 1]

self.assertEqual(prev_link['title'], sorted(link_names)[i])
self.assertEqual(link['title'], sorted(link_names)[i + 1])


if __name__ == "__main__":
# setup test files
Expand Down

0 comments on commit 43e1961

Please sign in to comment.