This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
forked from Rapptz/discord.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add custom coverage test * identified and added an aditional mark * Revert "identified and added an aditional mark" This reverts commit 17c4a75. * Revert "Add custom coverage test" This reverts commit c8f9434. * Added test * Add coverages to report * solved pr review
- Loading branch information
1 parent
ad31e9c
commit 07fbb8f
Showing
5 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
from discord import http | ||
|
||
|
||
class CustomResponse: | ||
def __init__(self, text_data, content_type): | ||
self._text = text_data | ||
self.headers = {'content-type': content_type} | ||
|
||
async def text(self, encoding='utf-8'): | ||
return self._text | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_json_or_text(): | ||
# Testing with json data | ||
response = CustomResponse('{"key": "value"}', 'application/json') | ||
result = await http.json_or_text(response) | ||
assert isinstance(result, dict) | ||
assert result == {"key": "value"} | ||
|
||
# Testing with plain text data | ||
response = CustomResponse('Hello world!', 'text/plain') | ||
result = await http.json_or_text(response) | ||
assert isinstance(result, str) | ||
assert result == 'Hello world!' |