File tree Expand file tree Collapse file tree 4 files changed +15
-19
lines changed Expand file tree Collapse file tree 4 files changed +15
-19
lines changed Original file line number Diff line number Diff line change @@ -70,16 +70,15 @@ def getDealStatus(cid: str):
70
70
raise e
71
71
72
72
@staticmethod
73
- def getUploads (publicKey : str , pageNo : int = 1 ):
73
+ def getUploads (self , lastKey : int = None ):
74
74
"""
75
75
Get uploads from the Lighthouse.
76
76
77
- :param publicKey: str, public key
78
- :param pageNo: int, page number (default: 1)
77
+ :param lastKey: To navigate to different pages of results
79
78
:return: List[t.DealData], list of deal data
80
79
"""
81
80
try :
82
- return getUploads .get_uploads (publicKey , pageNo )
81
+ return getUploads .get_uploads (self . token , lastKey )
83
82
except Exception as e :
84
83
raise e
85
84
Original file line number Diff line number Diff line change @@ -11,10 +11,14 @@ def bytes_to_size(bytes_size):
11
11
return f"{ round (bytes_size , 2 )} { units [index ]} "
12
12
13
13
14
- def get_uploads (publicKey : str , pageNo : int = 1 ) :
14
+ def get_uploads (token : str , lastKey : int = None ) :
15
+ headers = {
16
+ "Authorization" : f"Bearer { token } " ,
17
+ }
18
+
15
19
try :
16
- url = f"{ Config .lighthouse_api } /api/user/files_uploaded?publicKey= { publicKey } &pageNo= { pageNo } "
17
- response = requests .get (url )
20
+ url = f"{ Config .lighthouse_api } /api/user/files_uploaded?lastKey= { lastKey } "
21
+ response = requests .get (url , headers = headers )
18
22
response .raise_for_status ()
19
23
return response .json ()
20
24
except requests .HTTPError as error :
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def test_deal_status(self):
15
15
"QmT9shXpKcn4HRbJhXJ1ZywzwjEo2QWbxAx4SVgW4eYKjG" )
16
16
self .assertIsInstance (res , list , "data is a list" )
17
17
self .assertIsInstance (res [0 ].get (
18
- "dealId " ), int , "dealId is Int" )
18
+ "DealID " ), int , "DealID is Int" )
19
19
20
20
def test_deal_status_init (self ):
21
21
"""test deal_status function"""
@@ -25,4 +25,4 @@ def test_deal_status_init(self):
25
25
"QmT9shXpKcn4HRbJhXJ1ZywzwjEo2QWbxAx4SVgW4eYKjG" )
26
26
self .assertIsInstance (res , list , "data is a list" )
27
27
self .assertIsInstance (res [0 ].get (
28
- "dealId " ), int , "dealId is Int" )
28
+ "DealID " ), int , "DealID is Int" )
Original file line number Diff line number Diff line change 7
7
from .setup import parse_env
8
8
9
9
10
- class TestDealStatus (unittest .TestCase ):
10
+ class TestGetUploads (unittest .TestCase ):
11
11
12
12
def test_get_upload (self ):
13
- """test static test_get_upload function"""
14
- res = Lighthouse .getUploads (
15
- "0xB23809427cFc9B3346AEC5Bb70E7e574696cAF80" )
16
- self .assertIsInstance (res .get ("fileList" ), list , "data is a list" )
17
-
18
- def test_get_upload_init (self ):
19
13
"""test get_upload function"""
20
14
parse_env ()
21
15
l = Lighthouse (os .environ .get ("LIGHTHOUSE_TOKEN" ))
22
- res = Lighthouse .getUploads (
23
- "0xB23809427cFc9B3346AEC5Bb70E7e574696cAF80" )
24
- self .assertIsInstance (res .get ("fileList" ), list , "data is a list" )
16
+ res = l .getUploads ()
17
+ self .assertIsInstance (res .get ("fileList" ), list , "data is a list" )
You can’t perform that action at this time.
0 commit comments