@@ -1717,11 +1717,26 @@ def testLinkCreationOrder(self):
1717
1717
grp_id = rspJson ["id" ]
1718
1718
self .assertTrue (helper .validateId (grp_id ))
1719
1719
1720
+ link_names = [
1721
+ "first" ,
1722
+ "second" ,
1723
+ "third" ,
1724
+ "fourth" ,
1725
+ "fifth" ,
1726
+ "sixth" ,
1727
+ "seventh" ,
1728
+ "eighth" ,
1729
+ "ninth" ,
1730
+ "tenth" ,
1731
+ "eleventh" ,
1732
+ "twelfth" ,
1733
+ ]
1734
+
1720
1735
# create soft links under the group in sequence
1721
- link_count = 10
1736
+ link_count = len ( link_names )
1722
1737
1723
1738
for i in range (link_count ):
1724
- title = f"link_ { i } "
1739
+ title = link_names [ i ]
1725
1740
req = helper .getEndpoint () + f"/groups/{ grp_id } /links/{ title } "
1726
1741
body = {"h5path" : f"some_path_{ i } " }
1727
1742
rsp = self .session .put (req , data = json .dumps (body ), headers = headers )
@@ -1740,11 +1755,44 @@ def testLinkCreationOrder(self):
1740
1755
prev_link = links_json [i ]
1741
1756
link = links_json [i + 1 ]
1742
1757
1743
- self .assertEqual (prev_link ['title' ], f"link_ { i } " )
1744
- self .assertEqual (link ['title' ], f"link_ { i + 1 } " )
1758
+ self .assertEqual (prev_link ['title' ], link_names [ i ] )
1759
+ self .assertEqual (link ['title' ], link_names [ i + 1 ] )
1745
1760
1746
1761
self .assertTrue (prev_link ["created" ] < link ["created" ])
1747
1762
1763
+ # retrieve all links in grp in alphanumeric order
1764
+ req = helper .getEndpoint () + f"/groups/{ grp_id } /links"
1765
+ params = {} # default should be alphanumeric
1766
+ rsp = self .session .get (req , params = params , headers = headers )
1767
+ self .assertEqual (rsp .status_code , 200 )
1768
+ rspJson = json .loads (rsp .text )
1769
+ links_json = rspJson ["links" ]
1770
+ print ("params:" , params )
1771
+
1772
+ # verify the links are in order
1773
+ for i in range (link_count - 1 ):
1774
+ prev_link = links_json [i ]
1775
+ link = links_json [i + 1 ]
1776
+
1777
+ self .assertEqual (prev_link ['title' ], sorted (link_names )[i ])
1778
+ self .assertEqual (link ['title' ], sorted (link_names )[i + 1 ])
1779
+
1780
+ # retrieve all links in grp in alphanumeric order
1781
+ req = helper .getEndpoint () + f"/groups/{ grp_id } /links"
1782
+ params = {"CreateOrder" : 0 }
1783
+ rsp = self .session .get (req , params = params , headers = headers )
1784
+ self .assertEqual (rsp .status_code , 200 )
1785
+ rspJson = json .loads (rsp .text )
1786
+ links_json = rspJson ["links" ]
1787
+
1788
+ # verify the links are in order
1789
+ for i in range (link_count - 1 ):
1790
+ prev_link = links_json [i ]
1791
+ link = links_json [i + 1 ]
1792
+
1793
+ self .assertEqual (prev_link ['title' ], sorted (link_names )[i ])
1794
+ self .assertEqual (link ['title' ], sorted (link_names )[i + 1 ])
1795
+
1748
1796
1749
1797
if __name__ == "__main__" :
1750
1798
# setup test files
0 commit comments