def test_up(self): w = Wiremock(host="localhost", port=8080) w.delete_all_mappings() mapping = { "request": { "method": "GET", "url": "/some/thing/to/delete" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" }, "chunkedDribbleDelay": { "numberOfChunks": 5, "totalDuration": 1000 } } } id = w.add_mapping(mapping) stored_mapping = w.mapping_by_id(id) self.assertEqual(stored_mapping["id"], id) self.assertEqual( stored_mapping["response"]["chunkedDribbleDelay"] ["numberOfChunks"], 5) ids_up = w.up([{"method": "GET", "url": "/some/thing/to/delete"}]) up_mapping = w.mapping_by_id(ids_up[0]) self.assertFalse("chunkedDribbleDelay" in up_mapping["response"])
def test_chunked_dribble_delay(self): w = Wiremock(host="localhost", port=8080) w.delete_all_mappings() mapping = { "request": { "method": "GET", "url": "/some/thing/to/delete" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } } id = w.add_mapping(mapping) delayed = w.chunked_dribble_delay(mapping["request"], { "numberOfChunks": 5, "totalDuration": 1000 }) self.assertTrue(isinstance(delayed, dict)) self.assertTrue(isinstance(delayed["id"], str)) self.assertEqual(delayed["id"], id) map = w.mapping_by_id(delayed["id"]) self.assertEqual( map["response"]["chunkedDribbleDelay"]["totalDuration"], 1000)
def test_mapping_by_id(self): w = Wiremock(host="localhost", port=8080) w.delete_all_mappings() id = w.add_mapping({ "request": { "method": "GET", "url": "/some/thing/to/delete" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } }) mapping = w.mapping_by_id(id) self.assertTrue(isinstance(mapping, dict)) self.assertEqual(mapping["id"], id)