def test_mapping_response_serialization(self):
     e = MappingResponse(
         additional_proxy_request_headers={"test": "1"},
         base64_body="test2",
         body="test3",
         body_file_name="test4",
         json_body="test5",
         delay_distribution=DelayDistribution(distribution_type="lognormal",
                                              sigma=0.1,
                                              median=0.2),
         fault="test6",
         fixed_delay_milliseconds=500,
         from_configured_stub="test7",
         headers={"test": "1"},
         proxy_base_url="test8",
         status=200,
         status_message="test9",
         transformer_parameters={"test2": "2"},
         transformers=["test10"],
     )
     serialized = e.get_json_data()
     self.assertDictContainsKeyWithValue(serialized,
                                         "additionalProxyRequestHeaders",
                                         {"test": "1"})
     self.assertDictContainsKeyWithValue(serialized, "base64Body", "test2")
     self.assertDictContainsKeyWithValue(serialized, "body", "test3")
     self.assertDictContainsKeyWithValue(serialized, "bodyFileName",
                                         "test4")
     self.assertDictContainsKeyWithValue(serialized, "jsonBody", "test5")
     self.assertDictContainsKeyWithValue(serialized, "delayDistribution", {
         "type": "lognormal",
         "sigma": 0.1,
         "median": 0.2
     })
     self.assertDictContainsKeyWithValue(serialized, "fault", "test6")
     self.assertDictContainsKeyWithValue(serialized,
                                         "fixedDelayMilliseconds", 500)
     self.assertDictContainsKeyWithValue(serialized, "fromConfiguredStub",
                                         "test7")
     self.assertDictContainsKeyWithValue(serialized, "headers",
                                         {"test": "1"})
     self.assertDictContainsKeyWithValue(serialized, "proxyBaseUrl",
                                         "test8")
     self.assertDictContainsKeyWithValue(serialized, "status", 200)
     self.assertDictContainsKeyWithValue(serialized, "statusMessage",
                                         "test9")
     self.assertDictContainsKeyWithValue(serialized,
                                         "transformerParameters",
                                         {"test2": "2"})
     self.assertDictContainsKeyWithValue(serialized, "transformers",
                                         ["test10"])
Example #2
0
 def test_mapping_response_serialization(self):
     e = MappingResponse(additional_proxy_request_headers={'test': '1'},
                         base64_body='test2',
                         body='test3',
                         body_file_name='test4',
                         json_body='test5',
                         delay_distribution=DelayDistribution(
                             distribution_type='lognormal',
                             sigma=0.1,
                             median=0.2),
                         fault='test6',
                         fixed_delay_milliseconds=500,
                         from_configured_stub='test7',
                         headers={'test': '1'},
                         proxy_base_url='test8',
                         status=200,
                         status_message='test9',
                         transformer_parameters={'test2': '2'},
                         transformers=['test10'])
     serialized = e.get_json_data()
     self.assertDictContainsKeyWithValue(serialized,
                                         'additionalProxyRequestHeaders',
                                         {'test': '1'})
     self.assertDictContainsKeyWithValue(serialized, 'base64Body', 'test2')
     self.assertDictContainsKeyWithValue(serialized, 'body', 'test3')
     self.assertDictContainsKeyWithValue(serialized, 'bodyFileName',
                                         'test4')
     self.assertDictContainsKeyWithValue(serialized, 'jsonBody', 'test5')
     self.assertDictContainsKeyWithValue(serialized, 'delayDistribution', {
         'type': 'lognormal',
         'sigma': 0.1,
         'median': 0.2
     })
     self.assertDictContainsKeyWithValue(serialized, 'fault', 'test6')
     self.assertDictContainsKeyWithValue(serialized,
                                         'fixedDelayMilliseconds', 500)
     self.assertDictContainsKeyWithValue(serialized, 'fromConfiguredStub',
                                         'test7')
     self.assertDictContainsKeyWithValue(serialized, 'headers',
                                         {'test': '1'})
     self.assertDictContainsKeyWithValue(serialized, 'proxyBaseUrl',
                                         'test8')
     self.assertDictContainsKeyWithValue(serialized, 'status', 200)
     self.assertDictContainsKeyWithValue(serialized, 'statusMessage',
                                         'test9')
     self.assertDictContainsKeyWithValue(serialized,
                                         'transformerParameters',
                                         {'test2': '2'})
     self.assertDictContainsKeyWithValue(serialized, 'transformers',
                                         ['test10'])