def test_format_request_with_a_kernel_language_perl(self): test_request = ( '''{"body": "", "headers": {}, "args": {}, "path": {}}''') request_code = format_request(test_request, 'perl') self.assertTrue( request_code.startswith("my $REQUEST"), 'Call format_request with a kernel language "perl" was not formatted correctly' )
def test_format_request_without_a_kernel_language_arg(self): test_request = ( '''{"body": "", "headers": {}, "args": {}, "path": {}}''') request_code = format_request(test_request) self.assertTrue( request_code.startswith("REQUEST"), "Call format_request without a kernel_language argument was not formatted correctly" )
def test_format_request_code_escaped(self): """Should handle backslash escaped characeters in headers.""" test_request = ('''{"body": "", "headers": {"Accept-Language": "en-US,en;q=0.8", "If-None-Match": "\"\"9a28a9262f954494a8de7442c63d6d0715ce0998\"\"", "Accept-Encoding": "gzip, deflate, sdch"}, "args": {}, "path": {}}''') request_code = format_request(test_request) #Get the value of REQUEST = "{ to test for equality test_request_js_value = request_code[request_code.index("\"{"):] self.assertEqual(test_request, json.loads(test_request_js_value), "Escaped Request code was not formatted correctly")
def test_format_request_code_escaped(self): """Should handle backslash escaped characeters in headers.""" test_request = ( '''{"body": "", "headers": {"Accept-Language": "en-US,en;q=0.8", "If-None-Match": "\"\"9a28a9262f954494a8de7442c63d6d0715ce0998\"\"", "Accept-Encoding": "gzip, deflate, sdch"}, "args": {}, "path": {}}''' ) request_code = format_request(test_request) #Get the value of REQUEST = "{ to test for equality test_request_js_value = request_code[request_code.index("\"{"):] self.assertEqual(test_request, json.loads(test_request_js_value), "Escaped Request code was not formatted correctly")