Skip to content

Commit a7ee467

Browse files
committed
[test🧪] Update
1 parent c310666 commit a7ee467

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

tests/test_upload.py

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
# #!/usr/bin/env python3
2-
# import os
3-
# import io
4-
# import unittest
5-
# from src.lighthouseweb3 import Lighthouse
6-
# from src.lighthouseweb3.functions.utils import NamedBufferedReader
7-
# from .setup import parse_env
8-
# import string
9-
# import secrets
1+
#!/usr/bin/env python3
2+
import os
3+
import io
4+
import unittest
5+
from src.lighthouseweb3 import Lighthouse
6+
from src.lighthouseweb3.functions.utils import NamedBufferedReader
7+
from .setup import parse_env
8+
import string
9+
import secrets
1010

1111

12-
# def generate_random_string(length: int) -> str:
13-
# characters = string.ascii_letters + string.digits
14-
# return ''.join(secrets.choice(characters) for _ in range(length))
12+
def generate_random_string(length: int) -> str:
13+
characters = string.ascii_letters + string.digits
14+
return ''.join(secrets.choice(characters) for _ in range(length))
1515

1616

17-
# class TestUpload(unittest.TestCase):
18-
# def setUp(self) -> None:
19-
# """setup test environment"""
20-
# parse_env()
17+
class TestUpload(unittest.TestCase):
18+
def setUp(self) -> None:
19+
"""setup test environment"""
20+
parse_env()
2121

22-
# def test_env(self):
23-
# """test env var"""
24-
# self.assertNotEqual(
25-
# os.environ.get("LIGHTHOUSE_TOKEN"), None, "token is not None"
26-
# )
22+
def test_env(self):
23+
"""test env var"""
24+
self.assertNotEqual(
25+
os.environ.get("LIGHTHOUSE_TOKEN"), None, "token is not None"
26+
)
2727

28-
# def test_Upload_file(self):
29-
# """test Upload function"""
30-
# l = Lighthouse() # will use env var
31-
# res = l.upload("tests/testdir/testfile.txt")
32-
# self.assertNotEqual(res.get("data"), None, "data is None")
33-
# self.assertNotEqual(res.get("data").get("Hash"), None, "data is None")
28+
def test_Upload_file(self):
29+
"""test Upload function"""
30+
l = Lighthouse() # will use env var
31+
res = l.upload("tests/testdir/testfile.txt")
32+
self.assertNotEqual(res.get("data"), None, "data is None")
33+
self.assertNotEqual(res.get("data").get("Hash"), None, "data is None")
3434

35-
# def test_Upload_dir(self):
36-
# """test Upload function"""
37-
# l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
38-
# res = l.upload("tests/testdir/")
39-
# self.assertNotEqual(res.get("data"), None, "data is None")
40-
# self.assertIsInstance(res.get("data"), dict, "data is a dict")
41-
# self.assertNotEqual(res.get("data").get("Hash"), None, "data is None")
35+
def test_Upload_dir(self):
36+
"""test Upload function"""
37+
l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
38+
res = l.upload("tests/testdir/")
39+
self.assertNotEqual(res.get("data"), None, "data is None")
40+
self.assertIsInstance(res.get("data"), dict, "data is a dict")
41+
self.assertNotEqual(res.get("data").get("Hash"), None, "data is None")
4242

43-
# def test_Upload_Blob(self):
44-
# """test Upload function"""
45-
# l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
46-
# res = l.uploadBlob(
47-
# io.BytesIO(b"tests/testdir/"), f"{generate_random_string(16)}.txt")
48-
# self.assertNotEqual(res.get("data"), None, "data is None")
49-
# self.assertIsInstance(res.get("data"), dict, "data is a dict")
50-
# self.assertNotEqual(res.get("data").get("Hash"), None, "data is None")
43+
def test_Upload_Blob(self):
44+
"""test Upload function"""
45+
l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
46+
res = l.uploadBlob(
47+
io.BytesIO(b"tests/testdir/"), f"{generate_random_string(16)}.txt")
48+
self.assertNotEqual(res.get("data"), None, "data is None")
49+
self.assertIsInstance(res.get("data"), dict, "data is a dict")
50+
self.assertNotEqual(res.get("data").get("Hash"), None, "data is None")
5151

52-
# def test_Upload_File(self):
53-
# """test Upload function"""
54-
# l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
55-
# with open("./.gitignore", "rb") as file:
56-
# res = l.upload(file)
57-
# self.assertNotEqual(res.get("data"), None, "data is None")
58-
# self.assertIsInstance(res.get("data"), dict, "data is a dict")
59-
# self.assertNotEqual(res.get("data").get(
60-
# "Hash"), None, "data is None")
52+
def test_Upload_File(self):
53+
"""test Upload function"""
54+
l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
55+
with open("./.gitignore", "rb") as file:
56+
res = l.upload(file)
57+
self.assertNotEqual(res.get("data"), None, "data is None")
58+
self.assertIsInstance(res.get("data"), dict, "data is a dict")
59+
self.assertNotEqual(res.get("data").get(
60+
"Hash"), None, "data is None")
6161

6262

63-
# if __name__ == "__main__":
64-
# unittest.main()
63+
if __name__ == "__main__":
64+
unittest.main()

0 commit comments

Comments
 (0)