Skip to content

Commit 1837c1d

Browse files
Started unit tests
1 parent 7b2891e commit 1837c1d

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
flake8==3.7.5
2+
pytest==4.2.0

tests/config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"apiEndpoint": "http://localhost:8080/api/public/v1/",
3+
"apiKey": "ApiKey XXXX:YYYYY",
4+
"products": "CN-631-322-000"
5+
}

tests/test_config.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
3+
import pytest
4+
5+
from connectsdk.config import Config
6+
7+
8+
def setup_module(module):
9+
module.prev_dir = os.getcwd()
10+
os.chdir(os.path.dirname(os.path.abspath(__file__)))
11+
12+
13+
def teardown_module(module):
14+
os.chdir(module.prev_dir)
15+
16+
17+
def test_create_with_non_existing_file():
18+
with pytest.raises(IOError):
19+
Config(file='non_existing_config.json')
20+
21+
22+
def test_create_with_file():
23+
config = Config(file='config.json')
24+
assert config.api_url == 'http://localhost:8080/api/public/v1/'
25+
assert config.api_key == 'ApiKey XXXX:YYYYY'
26+
assert isinstance(config.products, list)
27+
assert len(config.products) == 1
28+
assert config.products[0] == 'CN-631-322-000'

0 commit comments

Comments
 (0)