Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

up test and req #2853

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,19 @@ async def inner_test_get_api_key_permissions(self):
"_get_api_key_rights_using_order", mock.AsyncMock(side_effect=origin_get_api_key_rights_using_order)
) as _get_api_key_rights_using_order_mock:
permissions = await self.exchange_manager.exchange_backend._get_api_key_rights()
assert len(permissions) > 0
assert trading_backend.enums.APIKeyRights.READING in permissions
assert trading_backend.enums.APIKeyRights.SPOT_TRADING in permissions
assert trading_backend.enums.APIKeyRights.FUTURES_TRADING in permissions
self._ensure_required_permissions(permissions)
if self.USE_ORDER_OPERATION_TO_CHECK_API_KEY_RIGHTS:
# failed ? did not use _get_api_key_rights_using_order while expected
_get_api_key_rights_using_order_mock.assert_called_once()
else:
# failed ? used _get_api_key_rights_using_order when not expected
_get_api_key_rights_using_order_mock.assert_not_called()

def _ensure_required_permissions(self, permissions):
assert len(permissions) > 0
assert trading_backend.enums.APIKeyRights.READING in permissions
assert trading_backend.enums.APIKeyRights.SPOT_TRADING in permissions

async def test_missing_trading_api_key_permissions(self):
async with self.local_exchange_manager(identifiers_suffix="_READONLY"):
await self.inner_test_missing_trading_api_key_permissions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# License along with OctoBot. If not, see <https://www.gnu.org/licenses/>.
import contextlib
import decimal
import ccxt
import pytest

import octobot_trading.enums as trading_enums
import octobot_trading.constants as trading_constants
import octobot_trading.errors as trading_errors
import trading_backend.enums
from additional_tests.exchanges_tests import abstract_authenticated_exchange_tester


Expand Down Expand Up @@ -192,6 +192,10 @@ async def _inner_test_create_and_cancel_limit_orders_for_margin_type(
symbol=self.INVERSE_SYMBOL, settlement_currency=self.ORDER_CURRENCY, margin_type=margin_type
)

def _ensure_required_permissions(self, permissions):
super()._ensure_required_permissions(permissions)
assert trading_backend.enums.APIKeyRights.FUTURES_TRADING in permissions

async def inner_test_create_and_fill_market_orders(self):
portfolio = await self.get_portfolio()
position = await self.get_position()
Expand Down
8 changes: 3 additions & 5 deletions octobot/community/errors_upload/sentry_aiohttp_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ def capture_event(
def capture_envelope(
self, envelope: sentry_sdk.envelope.Envelope
) -> None:
hub = self.hub_cls.current

async def send_envelope_wrapper() -> None:
with hub: # pylint: disable=not-context-manager
with sentry_sdk.utils.capture_internal_exceptions():
await self._async_send_envelope(envelope)
self._flush_client_reports()
with sentry_sdk.utils.capture_internal_exceptions():
await self._async_send_envelope(envelope)
self._flush_client_reports()

if not self._worker.submit(send_envelope_wrapper):
self.on_dropped_event("full_queue")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Drakkar-Software requirements
OctoBot-Commons==1.9.70
OctoBot-Trading==2.4.143
OctoBot-Trading==2.4.144
OctoBot-Evaluators==1.9.7
OctoBot-Tentacles-Manager==2.9.16
OctoBot-Services==1.6.23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ def _before_send_callback(event: dict, hint: dict):
SENTRY_CONFIG["enabled"] = False
if handle and hasattr(handle._client.transport, "async_kill"):
await handle._client.transport.async_kill()
client = sentry_sdk.Hub.current.client
if client is not None:
client.close(timeout=0)


def _mocked_context(return_value):
Expand Down
Loading