Skip to content

Commit c9a0427

Browse files
committed
fix: depreciated ordering
1 parent 07725e5 commit c9a0427

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

koala/rest/api.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from aiohttp.abc import Request
1313
from aiohttp.typedefs import Handler
1414

15+
from koala.errors import KoalaException
1516
from koala.log import logger
1617
# Own modules
1718
from koala.models import BaseModel
@@ -122,9 +123,13 @@ async def wrapper(*args, **kwargs):
122123

123124
try:
124125
result = await func(self, **{arg_name: available_args[arg_name] for arg_name in available_args.keys()})
125-
except Exception as e:
126+
127+
except KoalaException as e:
126128
logger.error("API Failed", exc_info=e)
127129
return build_response(BAD_REQUEST, ApiError(type(e).__name__, str(e)))
130+
except Exception as e:
131+
logger.error("API Failed", exc_info=e)
132+
raise e
128133
if raw_response:
129134
return result
130135
else:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pyparsing==2.4.7
2121
pytest==7.2.1
2222
pytest-asyncio==0.20.3
2323
pytest-env==0.8.1
24-
pytest-ordering==0.6
24+
pytest-order==1.1.0
2525
python-dotenv==1.0.0
2626
requests==2.28.2
2727
six==1.16.0

tests/cogs/twitch_alert/test_cog.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import mock
1010
import pytest
1111
import pytest_asyncio
12-
import pytest_ordering as pytest
1312
from discord.ext import commands
1413
from sqlalchemy import select, and_
1514

@@ -68,7 +67,8 @@ async def test_twitch_is_enabled_false(twitch_cog: cog.TwitchAlert):
6867

6968

7069
# @mock.patch("koala.utils.random_id", mock.MagicMock(return_value=7357))
71-
@pytest.mark.asyncio(order=1)
70+
@pytest.mark.order(1)
71+
@pytest.mark.asyncio
7272
async def test_edit_default_message_default_from_none(twitch_cog):
7373
this_channel = dpytest.get_config().channels[0]
7474
assert_embed = discord.Embed(title="Default Message Edited",
@@ -81,7 +81,8 @@ async def test_edit_default_message_default_from_none(twitch_cog):
8181

8282

8383
# @mock.patch("koala.utils.random_id", mock.MagicMock(return_value=7357))
84-
@pytest.mark.asyncio(order=2)
84+
@pytest.mark.order(2)
85+
@pytest.mark.asyncio
8586
async def test_edit_default_message_existing(twitch_cog):
8687
this_channel = dpytest.get_config().channels[0]
8788
assert_embed = discord.Embed(title="Default Message Edited",
@@ -92,8 +93,8 @@ async def test_edit_default_message_existing(twitch_cog):
9293
await dpytest.message(koalabot.COMMAND_PREFIX + "twitch editMsg " + str(this_channel.id) + " {user} is bad")
9394
assert dpytest.verify().message().embed(embed=assert_embed)
9495

95-
96-
@pytest.mark.asyncio(order=3)
96+
@pytest.mark.order(3)
97+
@pytest.mark.asyncio
9798
async def test_add_user_to_twitch_alert(twitch_cog):
9899
assert_embed = discord.Embed(title="Added User to Twitch Alert",
99100
description=f"Channel: {dpytest.get_config().channels[0].id}\n"
@@ -105,8 +106,8 @@ async def test_add_user_to_twitch_alert(twitch_cog):
105106
f"{koalabot.COMMAND_PREFIX}twitch add monstercat {dpytest.get_config().channels[0].id}")
106107
assert dpytest.verify().message().embed(embed=assert_embed)
107108

108-
109-
@pytest.mark.asyncio(order=3)
109+
@pytest.mark.order(3)
110+
@pytest.mark.asyncio
110111
async def test_add_user_to_twitch_alert_wrong_guild(twitch_cog: twitch_alert.cog.TwitchAlert):
111112
guild = dpytest.backend.make_guild(name="TestGuild")
112113
channel = dpytest.backend.make_text_channel(name="TestChannel", guild=guild)
@@ -121,8 +122,8 @@ async def test_add_user_to_twitch_alert_wrong_guild(twitch_cog: twitch_alert.cog
121122
f"{koalabot.COMMAND_PREFIX}twitch add monstercat {dpytest.get_config().guilds[0].channels[0].id}",
122123
channel=-1, member=member)
123124

124-
125-
@pytest.mark.asyncio(order=3)
125+
@pytest.mark.order(3)
126+
@pytest.mark.asyncio
126127
async def test_add_user_to_twitch_alert_custom_message(twitch_cog: twitch_alert.cog.TwitchAlert):
127128
test_custom_message = "We be live gamers!"
128129

@@ -184,8 +185,8 @@ async def test_remove_user_from_twitch_alert_with_message(twitch_cog: twitch_ale
184185
result_after = session.execute(sql_check_updated_server).one_or_none()
185186
assert result_after is None
186187

187-
188-
@pytest.mark.asyncio(order=3)
188+
@pytest.mark.order(3)
189+
@pytest.mark.asyncio
189190
async def test_remove_user_from_twitch_alert_wrong_guild(twitch_cog):
190191
guild = dpytest.backend.make_guild(name="TestGuild")
191192
channel = dpytest.backend.make_text_channel(name="TestChannel", guild=guild)
@@ -283,8 +284,8 @@ async def test_remove_team_from_twitch_alert_with_message(twitch_cog):
283284
assert dpytest.verify().message().embed(new_embed)
284285
pass
285286

286-
287-
@pytest.mark.asyncio(order=3)
287+
@pytest.mark.order(3)
288+
@pytest.mark.asyncio
288289
async def test_remove_team_from_twitch_alert_wrong_guild(twitch_cog):
289290
guild = dpytest.backend.make_guild(name="TestGuild")
290291
channel = dpytest.backend.make_text_channel(name="TestChannel", guild=guild)

tests/cogs/twitch_alert/test_db.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import mock
1616
import pytest
1717
import pytest_asyncio
18-
import pytest_ordering as pytest
1918
from discord.ext import commands
2019
from sqlalchemy import select, update, insert, delete, and_, or_
2120
from twitchAPI.object import Stream

0 commit comments

Comments
 (0)