Skip to content

Commit

Permalink
CSL3-2071 CSL3-2108 - Case Insensitive headers test
Browse files Browse the repository at this point in the history
  • Loading branch information
kochniev committed May 6, 2024
1 parent e9e4888 commit 8e50015
Showing 1 changed file with 42 additions and 0 deletions.
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())

0 comments on commit 8e50015

Please sign in to comment.