Skip to content

Commit 6a54f7d

Browse files
mshaileshr@gmail.commshaileshr@gmail.com
authored andcommitted
testcases and doc string added
1 parent 90bbe85 commit 6a54f7d

File tree

7 files changed

+79
-27
lines changed

7 files changed

+79
-27
lines changed

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,4 @@ venv.bak/
104104

105105
# mypy
106106
.mypy_cache/
107-
108-
109107
.idea/
110-
# OS generated files #
111-
.DS_Store
112-
.DS_Store?
113-
.DS_Store

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
testcase
8+
9+
10+
{
11+
"type": "chrome",
12+
"request": "launch",
13+
"name": "Launch Chrome against localhost",
14+
"url": "http://localhost:8080",
15+
"webRoot": "${workspaceFolder}"
16+
}
17+
]
18+
}

.vscode/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"python.pythonPath": "venv/bin/python3.7",
3+
"python.testing.unittestArgs": [
4+
"-v",
5+
"-s",
6+
"./tests",
7+
"-p",
8+
"*test.py"
9+
],
10+
"python.testing.pytestEnabled": true,
11+
"python.testing.nosetestsEnabled": false,
12+
"python.testing.unittestEnabled": false,
13+
"python.testing.pytestArgs": [
14+
"tests"
15+
]
16+
}

contentstack/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
"""
99

1010
import warnings
11+
import os
12+
import sys
13+
sys.path.insert(0, os.path.abspath('.'))
1114

12-
__author__ = 'Contentstack (Shailesh Mishra)'
15+
__author__ = 'Shailesh Mishra'
1316
__status__ = 'debug'
1417
__version__ = '1.0.0'
1518
__package__ = 'contentstack'

contentstack/config.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import os
2+
import sys
3+
import enum
4+
import logging
5+
sys.path.insert(0, os.path.abspath('.'))
6+
17
"""
28
Config
39
contentstack
@@ -6,8 +12,6 @@
612
713
"""
814

9-
import logging
10-
import enum
1115

1216
logging.basicConfig(filename='report.log', format='%(asctime)s - %(message)s', level=logging.INFO)
1317
logging.getLogger(__name__)
@@ -28,11 +32,16 @@ def region(self, region=ContentstackRegion.US):
2832
"""
2933
The base URL for Content Delivery API is cdn.contentstack.io.
3034
default region is for ContentstackRegion is US
31-
:param region: ContentstackRegion
32-
:return: self
35+
36+
:param region: Region support given for US and EU
37+
:return: ContentstackRegion
38+
3339
==============================
40+
3441
[Example:]
42+
3543
>>> config = Config().region(region=ContentstackRegion.US)
44+
3645
==============================
3746
"""
3847

@@ -44,20 +53,13 @@ def host(self, host):
4453

4554
"""
4655
The base URL for Content Delivery API is cdn.contentstack.io.
47-
host is the domain name or IP address (
48-
IPv4) of the host that serves the API. It may include the port number if different from the scheme's default
56+
host is the domain name or IP address of the host that serves the API. It may include the
57+
port number if different from the scheme's default
4958
port (443 for HTTPS).
59+
60+
Returns:
61+
[Config] -- Config, So we can chain more functions
5062
51-
Note: contentstack supports HTTPS only
52-
:param host: host is the domain name
53-
:type host: str
54-
:return: self
55-
:rtype: Config
56-
57-
==============================
58-
[Example:]
59-
>>> config = Config().host('api.contentstack.io')
60-
==============================
6163
"""
6264

6365
if host is not None and isinstance(host, str):
@@ -73,11 +75,14 @@ def version(self, version=None):
7375
:type version: str
7476
:return: self
7577
:rtype: Config
78+
7679
==============================
80+
7781
[Example:] The API version (in our case, 'v3') can be found in the URL
7882
7983
>>> config = Config()
8084
>>> config.version = 'v3'
85+
8186
==============================
8287
"""
8388

@@ -91,6 +96,7 @@ def endpoint(self):
9196

9297
"""
9398
:return: url endpoint to make Http requst
99+
94100
"""
95101
return self.__get_url()
96102

contentstack/errors.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
77
"""
88

9+
import os
10+
import sys
11+
sys.path.insert(0, os.path.abspath('.'))
912

1013
class Error:
1114

@@ -38,10 +41,13 @@ def error_code(self):
3841
It returns error code from the stack response
3942
:return: error_code as int
4043
:rtype: int
44+
4145
==============================
46+
4247
[Example:]
4348
44-
>>> ode = error.error_code
49+
>>> code = error.error_code
50+
4551
==============================
4652
"""
4753
return self.__error_code
@@ -53,10 +59,13 @@ def error_message(self):
5359
Returns error_message from the stack response
5460
:return: error_message
5561
:rtype: str
62+
5663
==============================
64+
5765
[Example:]
5866
59-
>>> ode = error.error_message
67+
>>> message = error.error_message
68+
6069
==============================
6170
"""
6271

@@ -69,10 +78,13 @@ def error(self):
6978
This returns error code and error_message in dict formats
7079
:return: error dict
7180
:rtype: dict
81+
7282
==============================
83+
7384
[Example:]
7485
7586
>>> ode = error.error
87+
7688
==============================
7789
"""
7890

@@ -85,10 +97,13 @@ def error_info(self) -> dict:
8597
error information
8698
:return: error information
8799
:rtype: dict
100+
88101
==============================
102+
89103
[Example:]
90104
91105
>>> ode = error.error_info
106+
92107
==============================
93108
"""
94109
return self.__error_dict

contentstack/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class NullHandler(logging.Handler):
1515
def emit(self, record):
1616
pass
1717

18-
logging.basicConfig(filename='contentstack.log', format='%(asctime)s - %(message)s', level=logging.INFO)
18+
logging.basicConfig(filename='report_log.log', format='%(asctime)s - %(message)s', level=logging.INFO)
1919
logging.getLogger("Config")
2020

2121

22-
def log(message: str):
22+
def log(message):
2323
logging.debug(message)
2424

2525

0 commit comments

Comments
 (0)