Skip to content

Commit 9c4b133

Browse files
committed
added negative testcase of invalid token and invalid cid
1 parent b0d63e4 commit 9c4b133

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_get_file_info.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,19 @@ def test_get_file_info(self):
1313
l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
1414
res = l.getFileInfo("Qmd5MBBScDUV3Ly8qahXtZFqyRRfYSmUwEcxpYcV4hzKfW")
1515
self.assertIsInstance(res, dict, "data is a dict")
16-
self.assertEqual(res.get("cid"),"Qmd5MBBScDUV3Ly8qahXtZFqyRRfYSmUwEcxpYcV4hzKfW", "cid is matching")
16+
self.assertEqual(res.get("cid"),"Qmd5MBBScDUV3Ly8qahXtZFqyRRfYSmUwEcxpYcV4hzKfW", "cid is matching")
17+
18+
def test_get_file_info_invalid_token(self):
19+
"""test get_upload with invalid token"""
20+
with self.assertRaises(Exception) as context:
21+
l = Lighthouse("invalid_token")
22+
l.getFileInfo("Qmd5MBBScDUV3Ly8qahXtZFqyRRfYSmUwEcxpYcV4hzKfW")
23+
self.assertIn("authentication failed", str(context.exception).lower())
24+
25+
def test_get_file_info_invalid_cid(self):
26+
parse_env()
27+
l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
28+
res = l.getFileInfo("invalid_cid")
29+
self.assertIsInstance(res, dict, "res is dict")
30+
self.assertIsInstance(res.get('error'), dict, "error is dict")
31+
self.assertEqual(res.get("error").get('message'), 'Not Found', 'cid not found')

0 commit comments

Comments
 (0)