mirror of
https://github.com/gogcom/galaxy-integrations-python-api.git
synced 2026-01-01 11:28:12 -05:00
Compare commits
6 Commits
0.68
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
433b4958dd | ||
|
|
46cda7d61a | ||
|
|
f0f6210c3e | ||
|
|
468dfcc60d | ||
|
|
8f91f705ee | ||
|
|
46588c321e |
@@ -7,7 +7,7 @@ stages:
|
||||
test_package:
|
||||
stage: test
|
||||
script:
|
||||
- pip install -r requirements.txt
|
||||
- pip install -r requirements-dev.txt
|
||||
- pytest
|
||||
except:
|
||||
- tags
|
||||
|
||||
7
requirements-dev.txt
Normal file
7
requirements-dev.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
-r requirements.txt
|
||||
pytest==5.2.2
|
||||
pytest-asyncio==0.10.0
|
||||
pytest-mock==1.10.3
|
||||
pytest-mypy==0.4.1
|
||||
pytest-flakes==4.0.0
|
||||
types-certifi==2020.4.0
|
||||
@@ -1,10 +1,7 @@
|
||||
-e .
|
||||
pytest==5.2.2
|
||||
pytest-asyncio==0.10.0
|
||||
pytest-mock==1.10.3
|
||||
pytest-mypy==0.4.1
|
||||
pytest-flakes==4.0.0
|
||||
# because of pip bug https://github.com/pypa/pip/issues/4780
|
||||
aiohttp==3.5.4
|
||||
# Copied from setup.py because of a pip bug
|
||||
# see https://github.com/pypa/pip/issues/4780
|
||||
aiohttp==3.7.4
|
||||
certifi==2019.3.9
|
||||
psutil==5.6.6; sys_platform == 'darwin'
|
||||
# End of copy from setup.py
|
||||
|
||||
@@ -34,10 +34,6 @@ class NetworkError(ApplicationError):
|
||||
def __init__(self, data=None):
|
||||
super().__init__(101, "Network error", data)
|
||||
|
||||
class LoggedInElsewhere(ApplicationError):
|
||||
def __init__(self, data=None):
|
||||
super().__init__(102, "Logged in elsewhere", data)
|
||||
|
||||
class ProtocolError(ApplicationError):
|
||||
def __init__(self, data=None):
|
||||
super().__init__(103, "Protocol error", data)
|
||||
|
||||
@@ -299,14 +299,11 @@ class Connection():
|
||||
except TypeError:
|
||||
raise InvalidRequest()
|
||||
|
||||
def _send(self, data, sensitive=True):
|
||||
def _send(self, data, log_level=logging.DEBUG):
|
||||
try:
|
||||
line = self._encoder.encode(data)
|
||||
logger.log(log_level, "Sending data: %s", line)
|
||||
data = (line + "\n").encode("utf-8")
|
||||
if sensitive:
|
||||
logger.debug("Sending %d bytes of data", len(data))
|
||||
else:
|
||||
logger.debug("Sending data: %s", line)
|
||||
self._writer.write(data)
|
||||
except TypeError as error:
|
||||
logger.error(str(error))
|
||||
@@ -317,7 +314,7 @@ class Connection():
|
||||
"id": request_id,
|
||||
"result": result
|
||||
}
|
||||
self._send(response, sensitive=False)
|
||||
self._send(response, logging.INFO)
|
||||
|
||||
def _send_error(self, request_id, error):
|
||||
response = {
|
||||
@@ -325,8 +322,7 @@ class Connection():
|
||||
"id": request_id,
|
||||
"error": error.json()
|
||||
}
|
||||
|
||||
self._send(response, sensitive=False)
|
||||
self._send(response, logging.ERROR)
|
||||
|
||||
def _send_request(self, request_id, method, params):
|
||||
request = {
|
||||
@@ -335,7 +331,7 @@ class Connection():
|
||||
"id": request_id,
|
||||
"params": params
|
||||
}
|
||||
self._send(request, sensitive=True)
|
||||
self._send(request, logging.NOTSET)
|
||||
|
||||
def _send_notification(self, method, params):
|
||||
notification = {
|
||||
@@ -343,7 +339,7 @@ class Connection():
|
||||
"method": method,
|
||||
"params": params
|
||||
}
|
||||
self._send(notification, sensitive=True)
|
||||
self._send(notification, logging.NOTSET)
|
||||
|
||||
@staticmethod
|
||||
def _log_request(request, sensitive_params):
|
||||
|
||||
@@ -2,8 +2,16 @@ import pytest
|
||||
|
||||
from galaxy.api.types import Authentication
|
||||
from galaxy.api.errors import (
|
||||
UnknownError, InvalidCredentials, NetworkError, LoggedInElsewhere, ProtocolError,
|
||||
BackendNotAvailable, BackendTimeout, BackendError, TemporaryBlocked, Banned, AccessDenied
|
||||
UnknownError,
|
||||
BackendNotAvailable,
|
||||
BackendTimeout,
|
||||
BackendError,
|
||||
InvalidCredentials,
|
||||
NetworkError,
|
||||
ProtocolError,
|
||||
TemporaryBlocked,
|
||||
Banned,
|
||||
AccessDenied,
|
||||
)
|
||||
from galaxy.unittest.mock import async_return_value, skip_loop
|
||||
|
||||
@@ -42,7 +50,6 @@ async def test_success(plugin, read, write):
|
||||
pytest.param(BackendError, 4, "Backend error", id="backend_error"),
|
||||
pytest.param(InvalidCredentials, 100, "Invalid credentials", id="invalid_credentials"),
|
||||
pytest.param(NetworkError, 101, "Network error", id="network_error"),
|
||||
pytest.param(LoggedInElsewhere, 102, "Logged in elsewhere", id="logged_elsewhere"),
|
||||
pytest.param(ProtocolError, 103, "Protocol error", id="protocol_error"),
|
||||
pytest.param(TemporaryBlocked, 104, "Temporary blocked", id="temporary_blocked"),
|
||||
pytest.param(Banned, 105, "Banned", id="banned"),
|
||||
|
||||
Reference in New Issue
Block a user