Skip to content

Commit 8acb5b7

Browse files
committed
chores: added usage docs to readme
1 parent 66c4bbe commit 8acb5b7

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

readme.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,34 @@ or using nose2
2222
pip install requirements.txt && python -m nose2
2323
```
2424

25-
# Bundling
25+
# Usage
2626

27-
To bundle the library, run the following command:
27+
### Instantiate the client
2828

29+
```python
30+
from lighthouse import Lighthouse
31+
32+
# use token from env variable LIGHTHOUSE_TOKEN
33+
lh = LighthouseClient()
34+
35+
# or you can pass token as parameter
36+
lh = LighthouseClient(token="your_token")
2937
```
30-
python setup.py
38+
39+
### Uploading a file
40+
41+
```python
42+
from lighthouse import Lighthouse
43+
lh = Lighthouse()
44+
response = lh.upload_file("path/to/file")
45+
print(response) # prints a dict containing the cid of the file
46+
```
47+
48+
### Uploading a directory
49+
50+
```python
51+
from lighthouse import Lighthouse
52+
lh = Lighthouse("my-lightouse-token")
53+
response = lh.deploy("path/to/directory")
54+
print(response) # prints a dict containing the root cid of the directory
3155
```

tests/test_deploy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ def setUp(self) -> None:
1111
"""setup test environment"""
1212
parse_env()
1313

14+
def test_env(self):
15+
"""test env var"""
16+
self.assertNotEqual(
17+
os.environ.get("LIGHTHOUSE_TOKEN"), None, "token is not None"
18+
)
19+
1420
def test_deploy_file(self):
1521
"""test deploy function"""
1622
l = Lighthouse() # will use env var
@@ -20,7 +26,7 @@ def test_deploy_file(self):
2026

2127
def test_deploy_dir(self):
2228
"""test deploy function"""
23-
l = Lighthouse(os.environ["LIGHTHOUSE_TOKEN"])
29+
l = Lighthouse(os.environ.get("LIGHTHOUSE_TOKEN"))
2430
res = l.deploy("tests/testdir/")
2531
self.assertNotEqual(res.get("data"), None, "data is None")
2632
self.assertIsInstance(res.get("data"), dict, "data is a dict")

0 commit comments

Comments
 (0)