Skip to content

Commit

Permalink
remove unused lines and update consume.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Jun 27, 2024
1 parent 3011bed commit 55d3157
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion breathecode/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
response_207,
)
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
from breathecode.utils.decorators import consume, has_permission
from breathecode.utils.decorators import consume
from breathecode.utils.i18n import translation
from breathecode.utils.multi_status_response import MultiStatusResponse
from breathecode.utils.views import private_view, render_message
Expand Down
1 change: 0 additions & 1 deletion breathecode/registry/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from breathecode.services.seo import SEOAnalyzer
from breathecode.utils import GenerateLookupsMixin, capable_of, consume
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
from breathecode.utils.decorators.has_permission import has_permission
from breathecode.utils.i18n import translation
from breathecode.utils.views import render_message
from capyc.rest_framework.exceptions import ValidationException
Expand Down
4 changes: 2 additions & 2 deletions breathecode/utils/decorators/consume.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def wrapper(*args, **kwargs):

elif it_will_consume:
item = context['consumables'].first()
consume_service.send(instance=item, sender=item.__class__, how_many=context['price'])
consume_service.send_robust(instance=item, sender=item.__class__, how_many=context['price'])

return response

Expand Down Expand Up @@ -369,7 +369,7 @@ async def async_wrapper(*args, **kwargs):

elif it_will_consume:
item = await context['consumables'].afirst()
consume_service.send(instance=item, sender=item.__class__, how_many=context['price'])
consume_service.send_robust(instance=item, sender=item.__class__, how_many=context['price'])

return response

Expand Down
1 change: 0 additions & 1 deletion breathecode/utils/decorators/has_permission.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import logging
import traceback
from contextlib import asynccontextmanager, contextmanager
from typing import Any, Optional

from adrf.requests import AsyncRequest
Expand Down
42 changes: 21 additions & 21 deletions breathecode/utils/tests/decorators/tests_consume.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@pytest.fixture(autouse=True)
def setup(db, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr('django.utils.timezone.now', MagicMock(return_value=UTC_NOW))
monkeypatch.setattr('breathecode.payments.signals.consume_service.send', MagicMock(return_value=None))
monkeypatch.setattr('breathecode.payments.signals.consume_service.send_robust', MagicMock(return_value=None))
monkeypatch.setattr('breathecode.payments.models.ConsumptionSession.build_session',
MagicMock(wraps=models.ConsumptionSession.build_session))

Expand Down Expand Up @@ -283,7 +283,7 @@ async def test_anonymous_user(self, database: capy.Database, make_view_all_cases

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand All @@ -304,7 +304,7 @@ async def test_with_user(self, database: capy.Database, make_view_all_cases):

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand All @@ -325,7 +325,7 @@ async def test_with_user__with_permission__dont_match(self, database: capy.Datab

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand All @@ -350,7 +350,7 @@ async def test_with_user__with_group_related_to_permission__without_consumable(s

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand Down Expand Up @@ -379,7 +379,7 @@ async def test_with_user__with_group_related_to_permission__consumable__how_many

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == [
assert payments_signals.consume_service.send_robust.call_args_list == [
call(instance=model.consumable, sender=model.consumable.__class__, how_many=1),
]

Expand Down Expand Up @@ -411,7 +411,7 @@ async def test_with_user__with_group_related_to_permission__consumable__how_many

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand Down Expand Up @@ -440,7 +440,7 @@ async def test_with_user__with_group_related_to_permission__consumable__how_many

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == [
assert payments_signals.consume_service.send_robust.call_args_list == [
call(instance=model.consumable, sender=model.consumable.__class__, how_many=1),
]

Expand Down Expand Up @@ -472,7 +472,7 @@ async def test_with_user__with_group_related_to_permission__group_was_blackliste

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == [
assert payments_signals.consume_service.send_robust.call_args_list == [
call(instance=model.consumable, sender=model.consumable.__class__, how_many=1),
]

Expand All @@ -497,7 +497,7 @@ async def test__function__get__anonymous_user(self, bc: Breathecode, make_view_c

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand All @@ -518,7 +518,7 @@ async def test__function__get__with_user(self, bc: Breathecode, make_view_consum

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand All @@ -540,7 +540,7 @@ async def test__function__get__with_user__with_permission__dont_match(self, bc:

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand Down Expand Up @@ -590,7 +590,7 @@ async def test__function__get__with_user__with_group_related_to_permission__with

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand Down Expand Up @@ -646,7 +646,7 @@ async def test__function__get__with_user__with_group_related_to_permission__cons

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == [
assert payments_signals.consume_service.send_robust.call_args_list == [
call(instance=model.consumable, sender=model.consumable.__class__, how_many=1),
]

Expand Down Expand Up @@ -705,7 +705,7 @@ async def test__function__get__with_user__with_group_related_to_permission__cons

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand Down Expand Up @@ -761,7 +761,7 @@ async def test__function__get__with_user__with_group_related_to_permission__cons

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == [
assert payments_signals.consume_service.send_robust.call_args_list == [
call(instance=model.consumable, sender=model.consumable.__class__, how_many=1),
]

Expand Down Expand Up @@ -821,7 +821,7 @@ async def test__function__get__with_user__with_group_related_to_permission__grou

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand Down Expand Up @@ -879,7 +879,7 @@ async def test__function__get__with_user__without_consumption_session(self, bc:

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == [
assert payments_signals.consume_service.send_robust.call_args_list == [
call(instance=model.consumable, sender=model.consumable.__class__, how_many=1),
]

Expand Down Expand Up @@ -945,7 +945,7 @@ async def test__with_user__consumption_session__does_not_match(self, bc: Breathe

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == [
assert payments_signals.consume_service.send_robust.call_args_list == [
call(instance=model.consumable, sender=model.consumable.__class__, how_many=1),
]

Expand Down Expand Up @@ -1001,7 +1001,7 @@ async def test__with_user__consumption_session__does_not_match__consumables_minu

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()

Expand Down Expand Up @@ -1054,6 +1054,6 @@ async def test__with_user__consumption_session__match(self, bc: Breathecode, mak

@sync_to_async
def check_consume_service():
assert payments_signals.consume_service.send.call_args_list == []
assert payments_signals.consume_service.send_robust.call_args_list == []

await check_consume_service()
2 changes: 1 addition & 1 deletion breathecode/utils/validate_conversion_info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from breathecode.utils.i18n import translation
from capyc.rest_framework.exceptions import PaymentException, ValidationException
from capyc.rest_framework.exceptions import ValidationException

__all__ = ['validate_conversion_info']

Expand Down

0 comments on commit 55d3157

Please sign in to comment.