(fixtures)
| 302 | |
| 303 | @pytest.fixture() |
| 304 | def mock_github(fixtures): |
| 305 | pth = fixtures.path("github_api_mock.json") |
| 306 | with open(pth, "r") as fd: |
| 307 | mock_data = json.loads(fd.read()) |
| 308 | |
| 309 | def _callback(request): |
| 310 | resp = json.dumps(mock_data[request.url]) |
| 311 | return (200, {}, resp) |
| 312 | |
| 313 | def _activate_mock(rsps): |
| 314 | for url in mock_data.keys(): |
| 315 | rsps.add_callback( |
| 316 | responses.GET, |
| 317 | url, |
| 318 | callback=_callback |
| 319 | ) |
| 320 | |
| 321 | return _activate_mock |
| 322 | |
| 323 | |
| 324 | @pytest.fixture() |
no test coverage detected