def test_add_mappings(self): ids = add_mappings([{ "request": { "method": "GET", "url": "/some/thing" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } }], { "wiremock": { "host": "localhost", "port": 8080, }, }) delete_mappings([{ "url": "/some/thing", "method": "GET" }], {"wiremock": { "host": "localhost", "port": 8080, }}) self.assertTrue(isinstance(ids[0], str)) self.assertTrue(ids[0] != -1)
def test_delete_mappings(self): self.assertEqual( reset({ "wiremock": { "host": "localhost", "port": 8080 }, }), 1) ids_added = add_mappings([{ "request": { "method": "GET", "url": "/some/thing" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } }], { "wiremock": { "host": "localhost", "port": 8080 }, }) ids_deleted = delete_mappings([{ "url": "/some/thing", "method": "GET" }], {"wiremock": { "host": "localhost", "port": 8080 }}) self.assertTrue(isinstance(ids_deleted[0], str)) self.assertEqual(ids_added[0], ids_deleted[0])
def test_chunked_dribble_delay(self): self.assertEqual( reset({ "wiremock": { "host": "localhost", "port": 8080 }, }), 1) ids_added = add_mappings([{ "request": { "method": "GET", "url": "/some/thing" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } }], { "wiremock": { "host": "localhost", "port": 8080 }, }) delayed = chunked_dribble_delay(filter=[{ "url": "/some/thing", "method": "GET" }], chunkedDribbleDelay={ "numberOfChunks": 5, "totalDuration": 1000 }, configuration={ "wiremock": { "host": "localhost", "port": 8080 }, }) self.assertEqual(delayed[0]['id'], ids_added[0]) self.assertEqual( delayed[0]['response']['chunkedDribbleDelay']['numberOfChunks'], 5) ids_deleted = delete_mappings([{ "url": "/some/thing", "method": "GET" }], {"wiremock": { "host": "localhost", "port": 8080 }}) self.assertTrue(isinstance(ids_deleted[0], str)) self.assertEqual(ids_added[0], ids_deleted[0])
def test_random_delay(self): self.assertEqual( reset({ "wiremock": { "host": "localhost", "port": 8080 }, }), 1) ids_added = add_mappings([{ "request": { "method": "GET", "url": "/some/thing" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } }], { "wiremock": { "host": "localhost", "port": 8080 }, }) delayed = random_delay(filter=[{ "url": "/some/thing", "method": "GET" }], delayDistribution={ "type": "lognormal", "median": 80, "sigma": 0.4 }, configuration={ "wiremock": { "host": "localhost", "port": 8080 }, }) self.assertEqual(delayed[0]['id'], ids_added[0]) ids_deleted = delete_mappings([{ "url": "/some/thing", "method": "GET" }], {"wiremock": { "host": "localhost", "port": 8080 }}) self.assertTrue(isinstance(ids_deleted[0], str)) self.assertEqual(ids_added[0], ids_deleted[0])
def test_fixed_delay(self): self.assertEqual( reset({ "wiremock": { "host": "localhost", "port": 8080 }, }), 1) ids_added = add_mappings([{ "request": { "method": "GET", "url": "/some/thing" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } }], { "wiremock": { "host": "localhost", "port": 8080 }, }) delayed = fixed_delay(filter=[{ "url": "/some/thing", "method": "GET" }], fixedDelayMilliseconds=1000, configuration={ "wiremock": { "host": "localhost", "port": 8080 }, }) self.assertEqual(delayed[0]['id'], ids_added[0]) ids_deleted = delete_mappings([{ "url": "/some/thing", "method": "GET" }], {"wiremock": { "host": "localhost", "port": 8080 }}) self.assertTrue(isinstance(ids_deleted[0], str)) self.assertEqual(ids_added[0], ids_deleted[0])