Skip to content

Commit e8aeff7

Browse files
committed
add unit tests for url token replacement
1 parent 09bfa14 commit e8aeff7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/requests/test_batch_request_item.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,43 @@ def test_set_url(batch_request_item):
5050
assert batch_request_item.url == "/v1.0/me"
5151

5252

53+
def test_constructor_url_replacement():
54+
request_info = RequestInformation()
55+
request_info.http_method = "GET"
56+
request_info.url = "https://graph.microsoft.com/v1.0/users/me-token-to-replace"
57+
request_info.headers = RequestHeaders()
58+
request_info.content = None
59+
60+
batch_request_item = BatchRequestItem(request_info)
61+
62+
assert batch_request_item.url == "https://graph.microsoft.com/v1.0/me"
63+
64+
65+
def test_set_url_replacement():
66+
request_info = RequestInformation()
67+
request_info.http_method = "GET"
68+
request_info.url = "https://graph.microsoft.com/v1.0/users/me-token-to-replace"
69+
request_info.headers = RequestHeaders()
70+
request_info.content = None
71+
72+
batch_request_item = BatchRequestItem(request_info)
73+
batch_request_item.set_url("https://graph.microsoft.com/v1.0/users/me-token-to-replace")
74+
75+
assert batch_request_item.url == "/v1.0/me"
76+
77+
78+
def test_constructor_url_replacement_with_query():
79+
request_info = RequestInformation()
80+
request_info.http_method = "GET"
81+
request_info.url = "https://graph.microsoft.com/v1.0/users/me-token-to-replace?param=value"
82+
request_info.headers = RequestHeaders()
83+
request_info.content = None
84+
85+
batch_request_item = BatchRequestItem(request_info)
86+
87+
assert batch_request_item.url == "https://graph.microsoft.com/v1.0/me?param=value"
88+
89+
5390
def test_id_property(batch_request_item):
5491
batch_request_item.id = "new_id"
5592
assert batch_request_item.id == "new_id"

0 commit comments

Comments
 (0)