Skip to content

Commit 9a57f81

Browse files
committed
Fixed type issue of lastKey and added test case with lastKey for getUploads and improved existing testcase for getUploads
1 parent be306d6 commit 9a57f81

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/lighthouseweb3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def getDealStatus(cid: str):
6969
except Exception as e:
7070
raise e
7171

72-
def getUploads(self, lastKey: int = None):
72+
def getUploads(self, lastKey: str = None):
7373
"""
7474
Get uploads from the Lighthouse.
7575

src/lighthouseweb3/functions/get_uploads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def bytes_to_size(bytes_size):
1111
return f"{round(bytes_size, 2)} {units[index]}"
1212

1313

14-
def get_uploads(token: str, lastKey: int = None) :
14+
def get_uploads(token: str, lastKey: str = None) :
1515
headers = {
1616
"Authorization": f"Bearer {token}",
1717
}

tests/test_get_uploads.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ def test_get_upload(self):
1414
parse_env()
1515
l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
1616
res = l.getUploads()
17-
self.assertIsInstance(res.get("fileList"), list, "data is a list")
17+
self.assertIsInstance(res.get("fileList"), list, "data is a list")
18+
self.assertIsInstance(res.get('totalFiles'), int, "totalFiles is an int")
19+
20+
def test_get_upload_with_last_key(self):
21+
"""test get_upload function with lastKey"""
22+
parse_env()
23+
l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
24+
res = l.getUploads('b5f60ba0-b708-41a3-b0f2-5c808ce63b48')
25+
self.assertIsInstance(res.get("fileList"), list, "data is a list")
26+
self.assertIsInstance(res.get('totalFiles'), int, "totalFiles is an int")

0 commit comments

Comments
 (0)