Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c82db84

Browse files
authoredJul 26, 2020
Merge pull request #128 from Pradhvan/IncreaseTestCoverage#123
test/test_connectionConfig.py:Adds test to for connectionConfig
2 parents 27146e5 + 6d86a4b commit c82db84

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed
 

‎terminusdb_client/tests/test_connectionConfig.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
import secrets
2+
import string
3+
14
from terminusdb_client.woqlclient.connectionConfig import ConnectionConfig
25

36

47
class TestConnectionConfig:
58
start_server_url = "http://localhost:6363/"
69
start_dbid = "testDB"
710
local_user = "admin"
11+
# Set of random string values that can as replacements for dummy id valuess
12+
# i.e accountid,branchid,refid etc
13+
id_value = "".join(
14+
secrets.choice(string.ascii_uppercase + string.ascii_lowercase)
15+
for _ in range(16)
16+
)
817
# to be review !!!!!
918
connection_config = ConnectionConfig(
1019
start_server_url,
@@ -38,3 +47,103 @@ def test_change_server(self):
3847

3948
def test_check_basic_auth(self):
4049
assert self.connection_config.basic_auth == "admin:mykey"
50+
51+
def test_set_remote_auth(self):
52+
auth_dict = {type: "jwt", "key": "eyJhbGciOiJIUzI1NiIsInR5c"}
53+
self.connection_config.set_remote_auth(auth_dict)
54+
assert self.connection_config.remote_auth == auth_dict
55+
auth_dict = {
56+
type: "basic",
57+
"user": self.local_user,
58+
"key": "admin_testDB_Password",
59+
}
60+
self.connection_config.update(remote_auth=auth_dict)
61+
assert self.connection_config.remote_auth == auth_dict
62+
63+
def test_update(self):
64+
self.connection_config.update(db=self.id_value)
65+
self.connection_config.update(account=self.id_value)
66+
self.connection_config.update(repo=self.id_value)
67+
self.connection_config.update(branch=self.id_value)
68+
self.connection_config.update(ref=self.id_value)
69+
self.connection_config.update(repo=self.id_value)
70+
assert self.connection_config.db == self.id_value
71+
assert self.connection_config.account == self.id_value
72+
assert self.connection_config.repo == self.id_value
73+
assert self.connection_config.branch == self.id_value
74+
assert self.connection_config.ref == self.id_value
75+
assert self.connection_config.repo == self.id_value
76+
77+
def test_clear_cursor(self):
78+
self.connection_config.update(branch=self.id_value)
79+
self.connection_config.update(repo=self.id_value)
80+
self.connection_config.update(account=self.id_value)
81+
self.connection_config.update(db=self.id_value)
82+
self.connection_config.update(ref=self.id_value)
83+
self.connection_config.clear_cursor()
84+
assert self.connection_config.branch != self.id_value
85+
assert self.connection_config.repo != self.id_value
86+
assert self.connection_config.account is False
87+
assert self.connection_config.db is False
88+
assert self.connection_config.ref is False
89+
90+
def test_user(self):
91+
assert self.connection_config.user() == self.local_user
92+
auth_dict = {type: "jwt", "key": "eyJhbGciOiJIUzI1NiIsInR5c"}
93+
self.connection_config.update(remote=auth_dict)
94+
assert self.connection_config.user() == self.local_user
95+
96+
def test_set_basic_auth(self):
97+
assert self.connection_config.set_basic_auth() is None
98+
self.connection_config.set_basic_auth(api_key="admin_testDB_Password")
99+
basic_auth = self.connection_config.basic_auth
100+
assert basic_auth == "admin:admin_testDB_Password"
101+
102+
def test_db_url_fragmen(self):
103+
self.connection_config.update(db=self.id_value)
104+
self.connection_config.update(account=self.id_value)
105+
db_url_fragment = self.connection_config.db_url_fragment()
106+
assert db_url_fragment == f"{self.id_value}/{self.id_value}"
107+
108+
def test_db_base(self):
109+
self.connection_config.update(db=self.id_value)
110+
self.connection_config.update(account=self.id_value)
111+
db_base = self.connection_config.db_base("push")
112+
assert db_base == f"http://localhost:6363/push/{self.id_value}/{self.id_value}"
113+
114+
def test_repo_base(self):
115+
self.connection_config.update(db=self.id_value)
116+
self.connection_config.update(account=self.id_value)
117+
self.connection_config.db_base("pull")
118+
default_base = self.connection_config.repo_base("pull")
119+
assert (
120+
default_base
121+
== f"http://localhost:6363/pull/{self.id_value}/{self.id_value}/local"
122+
)
123+
124+
self.connection_config.update(repo=self.id_value)
125+
updated_base = self.connection_config.db_base("pull")
126+
assert (
127+
updated_base
128+
== f"http://localhost:6363/pull/{self.id_value}/{self.id_value}"
129+
)
130+
131+
def test_account(self):
132+
self.connection_config.account = self.id_value
133+
assert self.connection_config.account == self.id_value
134+
135+
def test_db(self):
136+
self.connection_config.db = self.id_value
137+
assert self.connection_config.db == self.id_value
138+
139+
def test_repo(self):
140+
self.connection_config.repo = self.id_value
141+
assert self.connection_config.repo == self.id_value
142+
143+
def branch(self):
144+
self.connection_config.branch = self.id_value
145+
assert self.connection_config.branch == self.id_value
146+
147+
def ref(self):
148+
self.connection_config.ref = self.id_value
149+
assert self.connection_config.ref == self.id_value

‎terminusdb_client/woqldataframe/woqlDataframe.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class EmptyException(Exception):
2828
If the result table of the query is empty
2929
3030
"""
31-
pass
3231

3332

3433
def _is_empty(query):

0 commit comments

Comments
 (0)
Please sign in to comment.