Skip to content

Commit c27e2f5

Browse files
committed
refactoring tests, changing release command
1 parent 0185e51 commit c27e2f5

File tree

3 files changed

+87
-18
lines changed

3 files changed

+87
-18
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build:
1414
python -m build
1515

1616
release:
17-
twine upload --repository pypi dist/*
17+
python -m twine upload dist/*
1818

1919
install: requirements
2020

tests/test_rest_calls.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,3 @@ def test_delete_with_header_auth(client, dummy_data):
8080
assert isinstance(response, dict)
8181
assert request_user_agent() == dummy_data.user_agent
8282
assert_basic_auth()
83-
84-
85-
@responses.activate
86-
def test_patch(client, dummy_data):
87-
stub(responses.PATCH, "https://api.nexmo.com/v1/applications")
88-
host = "api.nexmo.com"
89-
request_uri = "/v1/applications"
90-
params = {"aaa": "xxx", "bbb": "yyy"}
91-
response = client.patch(host, request_uri, params=params, auth_type='jwt')
92-
assert request_headers()['Content-Type'] == 'application/json'
93-
assert re.search(b'^Bearer ', request_headers()['Authorization']) is not None
94-
assert isinstance(response, dict)
95-
assert request_user_agent() == dummy_data.user_agent
96-
assert b"aaa" in request_body()
97-
assert b"xxx" in request_body()
98-
assert b"bbb" in request_body()
99-
assert b"yyy" in request_body()

tests/test_signature.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import vonage
2+
from util import *
3+
4+
5+
def test_check_signature(dummy_data):
6+
params = {
7+
"a": "1",
8+
"b": "2",
9+
"timestamp": "1461605396",
10+
"sig": "6af838ef94998832dbfc29020b564830",
11+
}
12+
13+
client = vonage.Client(
14+
key=dummy_data.api_key, secret=dummy_data.api_secret, signature_secret="secret"
15+
)
16+
17+
assert client.check_signature(params)
18+
19+
20+
def test_signature(client, dummy_data):
21+
params = {"a": "1", "b": "2", "timestamp": "1461605396"}
22+
client = vonage.Client(
23+
key=dummy_data.api_key, secret=dummy_data.api_secret, signature_secret="secret"
24+
)
25+
assert client.signature(params) == "6af838ef94998832dbfc29020b564830"
26+
27+
28+
def test_signature_adds_timestamp(dummy_data):
29+
params = {"a=7": "1", "b": "2 & 5"}
30+
31+
client = vonage.Client(
32+
key=dummy_data.api_key, secret=dummy_data.api_secret, signature_secret="secret"
33+
)
34+
35+
client.signature(params)
36+
assert params["timestamp"] is not None
37+
38+
39+
def test_signature_md5(dummy_data):
40+
params = {"a": "1", "b": "2", "timestamp": "1461605396"}
41+
client = vonage.Client(
42+
key=dummy_data.api_key,
43+
secret=dummy_data.api_secret,
44+
signature_secret=dummy_data.signature_secret,
45+
signature_method="md5",
46+
)
47+
assert client.signature(params) == "c15c21ced558c93a226c305f58f902f2"
48+
49+
50+
def test_signature_sha1(dummy_data):
51+
params = {"a": "1", "b": "2", "timestamp": "1461605396"}
52+
client = vonage.Client(
53+
key=dummy_data.api_key,
54+
secret=dummy_data.api_secret,
55+
signature_secret=dummy_data.signature_secret,
56+
signature_method="sha1",
57+
)
58+
assert client.signature(params) == "3e19a4e6880fdc2c1426bfd0587c98b9532f0210"
59+
60+
61+
def test_signature_sha256(dummy_data):
62+
params = {"a": "1", "b": "2", "timestamp": "1461605396"}
63+
client = vonage.Client(
64+
key=dummy_data.api_key,
65+
secret=dummy_data.api_secret,
66+
signature_secret=dummy_data.signature_secret,
67+
signature_method="sha256",
68+
)
69+
assert (
70+
client.signature(params)
71+
== "a321e824b9b816be7c3f28859a31749a098713d39f613c80d455bbaffae1cd24"
72+
)
73+
74+
75+
def test_signature_sha512(dummy_data):
76+
params = {"a": "1", "b": "2", "timestamp": "1461605396"}
77+
client = vonage.Client(
78+
key=dummy_data.api_key,
79+
secret=dummy_data.api_secret,
80+
signature_secret=dummy_data.signature_secret,
81+
signature_method="sha512",
82+
)
83+
assert (
84+
client.signature(params)
85+
== "812a18f76680fa0fe1b8bd9ee1625466ceb1bd96242e4d050d2cfd9a7b40166c63ed26ec9702168781b6edcf1633db8ff95af9341701004eec3fcf9550572ee8"
86+
)

0 commit comments

Comments
 (0)