Skip to content

Commit 89a0fdd

Browse files
committed
chore: remove dependency on sure in code
1 parent 1ee72f5 commit 89a0fdd

File tree

1 file changed

+30
-41
lines changed

1 file changed

+30
-41
lines changed

tests/test_api.py

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,18 @@ def test_API_initial():
2828
"""Tests the API initialization without any parameters."""
2929
client = API()
3030

31-
client.should.be.a(API)
32-
client.api_key.should.be.none
33-
client.timeout.should.equal(10)
34-
client.show_limit_usage.should.be.false
35-
client.show_header.should.be.false
36-
client.session.should.be.a(requests.Session)
37-
client.session.headers.should.have.key("Content-Type").which.should.equal(
38-
"application/json;charset=utf-8"
31+
assert isinstance(client, API)
32+
assert client.api_key is None
33+
assert client.timeout == 10
34+
assert client.show_limit_usage is False
35+
assert client.show_header is False
36+
assert isinstance(client.session, requests.Session)
37+
assert (
38+
client.session.headers.get("Content-Type") == "application/json;charset=utf-8"
3939
)
40-
client.session.headers.should.have.key("User-Agent").which.should.equal(
41-
"datamaxi/" + __version__
42-
)
43-
client.session.headers.should.have.key("X-DTMX-APIKEY").which.should.be.equal(
44-
"None"
45-
)
46-
47-
client._logger.should.be(logging.getLogger("datamaxi.api"))
40+
assert client.session.headers.get("User-Agent") == "datamaxi/" + __version__
41+
assert client.session.headers.get("X-DTMX-APIKEY") == "None"
42+
assert client._logger is logging.getLogger("datamaxi.api")
4843

4944

5045
def test_API_env_key():
@@ -53,23 +48,19 @@ def test_API_env_key():
5348
os.environ["DATAMAXI_API_KEY"] = api_key
5449
client = API()
5550

56-
client.should.be.a(API)
57-
client.api_key.should.be.equal(api_key)
58-
client.session.headers.should.have.key("X-DTMX-APIKEY").which.should.be.equal(
59-
api_key
60-
)
51+
assert isinstance(client, API)
52+
assert client.api_key == api_key
53+
assert client.session.headers.get("X-DTMX-APIKEY") == api_key
6154

6255

6356
def test_API_with_explicit_key():
6457
"""Tests the API initialization with explicit API key parameter."""
6558
api_key = random_str()
6659
client = API(api_key)
6760

68-
client.should.be.a(API)
69-
client.api_key.should.be.equal(api_key)
70-
client.session.headers.should.have.key("X-DTMX-APIKEY").which.should.be.equal(
71-
api_key
72-
)
61+
assert isinstance(client, API)
62+
assert client.api_key == api_key
63+
assert client.session.headers.get("X-DTMX-APIKEY") == api_key
7364

7465

7566
def test_API_explicit_key_overrides_env():
@@ -79,10 +70,8 @@ def test_API_explicit_key_overrides_env():
7970
os.environ["DATAMAXI_API_KEY"] = env_key
8071
client = API(explicit_key)
8172

82-
client.api_key.should.be.equal(explicit_key)
83-
client.session.headers.should.have.key("X-DTMX-APIKEY").which.should.be.equal(
84-
explicit_key
85-
)
73+
assert client.api_key == explicit_key
74+
assert client.session.headers.get("X-DTMX-APIKEY") == explicit_key
8675

8776

8877
def test_API_with_extra_parameters():
@@ -100,29 +89,29 @@ def test_API_with_extra_parameters():
10089
proxies=proxies,
10190
)
10291

103-
client.should.be.a(API)
104-
client.api_key.should.equal(api_key)
105-
client.timeout.should.equal(0.1)
106-
client.base_url.should.equal(base_url)
107-
client.show_limit_usage.should.be.true
108-
client.show_header.should.be.true
109-
client.proxies.should.equal(proxies)
110-
client.session.headers.should.have.key("X-DTMX-APIKEY").which.should.equal(api_key)
92+
assert isinstance(client, API)
93+
assert client.api_key == api_key
94+
assert client.timeout == 0.1
95+
assert client.base_url == base_url
96+
assert client.show_limit_usage is True
97+
assert client.show_header is True
98+
assert client.proxies == proxies
99+
assert client.session.headers.get("X-DTMX-APIKEY") == api_key
111100

112101

113102
def test_API_with_custom_timeout():
114103
"""Tests the API initialization with custom timeout."""
115104
client = API(timeout=30)
116-
client.timeout.should.equal(30)
105+
assert client.timeout == 30
117106

118107

119108
def test_API_with_show_limit_usage():
120109
"""Tests the API initialization with show_limit_usage enabled."""
121110
client = API(show_limit_usage=True)
122-
client.show_limit_usage.should.be.true
111+
assert client.show_limit_usage is True
123112

124113

125114
def test_API_with_show_header():
126115
"""Tests the API initialization with show_header enabled."""
127116
client = API(show_header=True)
128-
client.show_header.should.be.true
117+
assert client.show_header is True

0 commit comments

Comments
 (0)