|
| 1 | +from sheepy.sheeptest import SheepyTestCase |
| 2 | + |
| 3 | +class TestHttpBinApi(SheepyTestCase): |
| 4 | + """ Expected output: |
| 5 | +
|
| 6 | + Test Results: |
| 7 | + TestHttpBinApi.test_delete_resource: OK |
| 8 | + TestHttpBinApi.test_get_json: OK |
| 9 | + TestHttpBinApi.test_get_status: OK |
| 10 | + TestHttpBinApi.test_post_data: OK |
| 11 | + TestHttpBinApi.test_put_data: OK |
| 12 | +
|
| 13 | + """ |
| 14 | + def __init__(self): |
| 15 | + super().__init__(base_url="https://httpbin.org") |
| 16 | + |
| 17 | + def test_get_status(self): |
| 18 | + |
| 19 | + response = self.api.get("/status/200") |
| 20 | + self.assertStatusCode(response, 200) |
| 21 | + |
| 22 | + def test_get_json(self): |
| 23 | + |
| 24 | + response = self.api.get("/json") |
| 25 | + self.assertStatusCode(response, 200) |
| 26 | + self.assertJsonResponse(response) |
| 27 | + self.assertResponseContains(response, "slideshow") |
| 28 | + |
| 29 | + def test_post_data(self): |
| 30 | + |
| 31 | + payload = {"name": "SheepyTest", "framework": "unittest"} |
| 32 | + response = self.api.post("/post", json=payload) |
| 33 | + self.assertStatusCode(response, 200) |
| 34 | + self.assertJsonResponse(response) |
| 35 | + self.assertResponseContains(response, "json") |
| 36 | + self.assertEqual(response.json()["json"], payload) |
| 37 | + |
| 38 | + def test_put_data(self): |
| 39 | + |
| 40 | + payload = {"key": "value"} |
| 41 | + response = self.api.put("/put", json=payload) |
| 42 | + self.assertStatusCode(response, 200) |
| 43 | + self.assertJsonResponse(response) |
| 44 | + self.assertResponseContains(response, "json") |
| 45 | + self.assertEqual(response.json()["json"], payload) |
| 46 | + |
| 47 | + def test_delete_resource(self): |
| 48 | + |
| 49 | + response = self.api.delete("/delete") |
| 50 | + self.assertStatusCode(response, 200) |
| 51 | + self.assertJsonResponse(response) |
0 commit comments