Exemple #1
0
    def test_depth_connection_doesnt_exist(self, monkeypatch):
        registry.reset()
        monkeypatch.setattr(settings, "SERVICE_CONNECTIONS", ["pong"])

        app = Insanic("ping")

        request, response = app.test_client.get("/ping/ping/",
                                                params={"depth": 1})
        assert response.status_code == 200
        assert "response" in response.json
        assert "process_time" in response.json

        assert "response" in response.json
        assert "pong" in response.json["response"]
Exemple #2
0
    def sanic_test_server(self, loop, test_server, sanic_test_server_2,
                          monkeypatch):

        sr = {
            "version": 1,
            "rules": [],
            "default": {
                "fixed_target": 1,
                "rate": 0
            },
        }
        monkeypatch.setattr(settings,
                            "INCENDIARY_XRAY_SAMPLING_RULES",
                            sr,
                            raising=False)
        monkeypatch.setattr(settings,
                            "INCENDIARY_XRAY_ENABLED",
                            True,
                            raising=False)
        monkeypatch.setattr(
            settings,
            "SERVICE_CONNECTIONS",
            ["incendiary", "incendiary_exception"],
            raising=False,
        )

        registry.reset()

        monkeypatch.setattr(Incendiary, "_check_prerequisites",
                            _mock_check_prerequisites)

        incendiary_service = get_service("incendiary")

        monkeypatch.setattr(incendiary_service, "host", "127.0.0.1")
        monkeypatch.setattr(incendiary_service, "port",
                            sanic_test_server_2.port)

        incendiary_exception_service = get_service("incendiary_exception")
        monkeypatch.setattr(incendiary_exception_service, "host", "127.0.0.2")
        monkeypatch.setattr(incendiary_exception_service, "port",
                            sanic_test_server_2.port)

        from ..incendiary1.app import app

        return loop.run_until_complete(test_server(app))
Exemple #3
0
    async def test_depth_connection_exists(self, monkeypatch, pong_server,
                                           ping_client):
        registry.reset()
        monkeypatch.setattr(settings, "SERVICE_CONNECTIONS", ["pong"])

        pong_service = get_service("pong")
        pong_service.host = "127.0.0.1"
        pong_service.port = pong_server.port

        response = await ping_client.get(
            "/ping/ping/",
            params={"depth": 1},
            # server_kwargs={"run_async": True}
        )

        assert response.status == 200

        response_body = await response.json()
        assert "response" in response_body
        assert "process_time" in response_body

        assert "response" in response_body
        assert "pong" in response_body["response"]
        assert response_body["response"]["pong"]["status_code"] == 200
Exemple #4
0
def reset_registry():

    yield
    from insanic.services.registry import registry

    registry.reset()
Exemple #5
0
    def reset_registry(self):
        """ Need to reset registry for each test"""
        from insanic.services.registry import registry

        registry.reset()