-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSL3-2071 CSL3-2108 - Case Insensitive headers test
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
larky/src/test/resources/quick_tests/test_case_insensitive_headers.star
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
load("@stdlib//larky", "larky") | ||
load("@stdlib//unittest","unittest") | ||
load("@stdlib//json","json") | ||
load("@stdlib//types", "types") | ||
load("@stdlib//builtins", builtins="builtins") | ||
|
||
load("@vendor//asserts","asserts") | ||
|
||
load("@vgs//http/request", "VGSHttpRequest") | ||
|
||
|
||
def test_read_case_insensitive_headers(): | ||
actual_header_key = 'case-sensitive' | ||
expected_header_key = actual_header_key.upper() | ||
header_value = 'Header Value' | ||
headers = {actual_header_key : header_value} | ||
request = VGSHttpRequest("http://example.com", data=b'{"cardNumber": "4111111111111111"}', headers=headers, method='POST') | ||
|
||
asserts.assert_that(request.headers[expected_header_key]).is_equal_to(header_value) | ||
asserts.assert_that(request.headers.get(expected_header_key)).is_equal_to(header_value) | ||
asserts.assert_that(request.headers.pop(expected_header_key)).is_equal_to(header_value) | ||
|
||
def test_write_case_insensitive_headers(): | ||
actual_header_key = 'case-sensitive' | ||
expected_header_key = actual_header_key.upper() | ||
headers = {actual_header_key : header_value} | ||
request = VGSHttpRequest("http://example.com", data=b'{"cardNumber": "4111111111111111"}', headers=headers, method='POST') | ||
|
||
asserts.assert_that(request.headers.size()).is_equal_to(1) | ||
request.headers[expected_header_key] = 'New Value' | ||
asserts.assert_that(request.headers.size()).is_equal_to(1) | ||
|
||
|
||
def _testsuite(): | ||
_suite = unittest.TestSuite() | ||
_suite.addTest(unittest.FunctionTestCase(test_read_case_insensitive_headers)) | ||
_suite.addTest(unittest.FunctionTestCase(test_write_case_insensitive_headers)) | ||
return _suite | ||
|
||
|
||
_runner = unittest.TextTestRunner() | ||
_runner.run(_testsuite()) |