Skip to content

Commit 27e5cbb

Browse files
committed
Fix tests
1 parent 0efa19e commit 27e5cbb

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

tests/async/test_client.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,33 +176,34 @@ async def test_client_create_private_clash_of_code(
176176

177177

178178
async def test_client_create_private_clash_of_code_logged_in_error(
179-
client: AsyncClient,
179+
client: AsyncClient, mock_httperror
180180
):
181181
with pytest.raises(exceptions.LoginRequired):
182182
await client.create_private_clash_of_code(
183183
["Python3"], ["SHORTEST", "FASTEST"]
184184
)
185185

186-
187-
async def test_client_create_private_clash_of_code_value_error(
188-
auth_client: AsyncClient, mock_httperror
189-
):
190-
with pytest.raises(ValueError):
191-
await auth_client.create_private_clash_of_code(
192-
["Python3"], ["BAD MODE", "FASTEST"]
193-
)
194-
186+
client._state.logged_in = True
195187
mock_httperror(
196-
auth_client._state.http,
188+
client._state.http,
197189
"create_private_clash_of_code",
198190
{"id": 501, "message": "You need to be logged to perform this action."},
199191
)
200192
with pytest.raises(exceptions.LoginRequired):
201-
await auth_client.create_private_clash_of_code(
193+
await client.create_private_clash_of_code(
202194
["Python3"], ["SHORTEST", "FASTEST"]
203195
)
204196

205197

198+
async def test_client_create_private_clash_of_code_value_error(
199+
auth_client: AsyncClient,
200+
):
201+
with pytest.raises(ValueError):
202+
await auth_client.create_private_clash_of_code(
203+
["Python3"], ["BAD MODE", "FASTEST"]
204+
)
205+
206+
206207
async def test_client_join_private_clash_of_code(
207208
auth_client: AsyncClient, private_clash: ClashOfCode, mock_http
208209
):

tests/sync/test_client.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,24 @@ def test_client_create_private_clash_of_code(
165165

166166

167167
def test_client_create_private_clash_of_code_logged_in_error(
168-
client: SyncClient,
168+
client: SyncClient, mock_httperror
169169
):
170170
with pytest.raises(exceptions.LoginRequired):
171171
client.create_private_clash_of_code(
172172
["Python3"], ["SHORTEST", "FASTEST"]
173173
)
174174

175+
client._state.logged_in = True
176+
mock_httperror(
177+
client._state.http,
178+
"create_private_clash_of_code",
179+
{"id": 501, "message": "You need to be logged to perform this action."},
180+
)
181+
with pytest.raises(exceptions.LoginRequired):
182+
client.create_private_clash_of_code(
183+
["Python3"], ["SHORTEST", "FASTEST"]
184+
)
185+
175186

176187
def test_client_create_private_clash_of_code_value_error(
177188
auth_client: SyncClient, mock_httperror
@@ -181,16 +192,6 @@ def test_client_create_private_clash_of_code_value_error(
181192
["Python3"], ["BAD MODE", "FASTEST"]
182193
)
183194

184-
mock_httperror(
185-
auth_client._state.http,
186-
"create_private_clash_of_code",
187-
{"id": 501, "message": "You need to be logged to perform this action."},
188-
)
189-
with pytest.raises(exceptions.LoginRequired):
190-
auth_client.create_private_clash_of_code(
191-
["Python3"], ["SHORTEST", "FASTEST"]
192-
)
193-
194195

195196
def test_client_join_private_clash_of_code(
196197
auth_client: SyncClient, private_clash: ClashOfCode, mock_http

0 commit comments

Comments
 (0)