Ejemplo n.º 1
0
    def test_raise_for_api_error_warning(self, caplog):
        caplog.set_level(logging.WARNING)
        data = {"ok": True, "warning": "test warning"}
        sansio.raise_for_api_error({}, data)

        assert len(caplog.records) == 1
        assert caplog.records[0].msg == "Slack API WARNING: %s"
        assert caplog.records[0].args == ("test warning", )
Ejemplo n.º 2
0
    def test_raise_for_api_error_nok_with_error(self):

        data = {"ok": False, "error": "test_error"}

        with pytest.raises(exceptions.SlackAPIError) as exc:
            sansio.raise_for_api_error({}, data)

        assert exc.type == exceptions.SlackAPIError
        assert exc.value.error == "test_error"
Ejemplo n.º 3
0
    def test_raise_for_api_error_nok(self):

        data = {"ok": False}
        headers = {"test-header": "hello"}

        with pytest.raises(exceptions.SlackAPIError) as exc:
            sansio.raise_for_api_error(headers, data)

        assert exc.type == exceptions.SlackAPIError
        assert exc.value.headers == {"test-header": "hello"}
        assert exc.value.data == {"ok": False}
        assert exc.value.error == "unknow_error"
Ejemplo n.º 4
0
 def test_raise_for_api_error_ok(self):
     try:
         sansio.raise_for_api_error({}, {"ok": True})
     except Exception as exc:
         raise pytest.fail("RAISE {}".format(exc))