diff --git a/src/growlery/__init__.py b/src/growlery/__init__.py index e69de29..99d42e4 100644 --- a/src/growlery/__init__.py +++ b/src/growlery/__init__.py @@ -0,0 +1 @@ +"""Clan Quest OSRS hiscore bot.""" diff --git a/src/growlery/__main__.py b/src/growlery/__main__.py index c8a8699..1ab4260 100644 --- a/src/growlery/__main__.py +++ b/src/growlery/__main__.py @@ -1,4 +1,4 @@ -"""Used to launch the bot as a module""" +"""Used to launch the bot as a module.""" import discord diff --git a/src/growlery/cogs/__init__.py b/src/growlery/cogs/__init__.py index f13985d..13e37c9 100644 --- a/src/growlery/cogs/__init__.py +++ b/src/growlery/cogs/__init__.py @@ -1,4 +1,4 @@ -"""Package for Discord cogs""" +"""Package for Discord cogs.""" from growlery.cogs.hiscores import Hiscores diff --git a/src/growlery/cogs/hiscores.py b/src/growlery/cogs/hiscores.py index 35c430a..be0f07a 100644 --- a/src/growlery/cogs/hiscores.py +++ b/src/growlery/cogs/hiscores.py @@ -1,4 +1,4 @@ -"""Implements commands for hiscores""" +"""Implement commands for hiscores.""" from __future__ import annotations @@ -24,114 +24,96 @@ class Hiscores(commands.Cog): # pylint: disable=R0904 - """Hiscores commands""" + """Hiscore commands.""" @commands.command('07hs') async def default_hiscores(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches default hiscores for the given username""" - + """Fetch default hiscores for the given username.""" await self.reply_with_hiscores(ctx, username, AccountType.NORMAL, AccountTypeName.NORMAL) @commands.command('07hs-im') async def ironman_hiscores(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches ironman hiscores for the given username""" - + """Fetch ironman hiscores for the given username.""" await self.reply_with_hiscores(ctx, username, AccountType.IRONMAN, AccountTypeName.IRONMAN) @commands.command('07hs-hcim') async def hardcore_ironman_hiscores(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches hardcore ironman hiscores for the given username""" - + """Fetch hardcore ironman hiscores for the given username.""" await self.reply_with_hiscores(ctx, username, AccountType.HARDCORE_IRONMAN, AccountTypeName.HARDCORE_IRONMAN) @commands.command('07hs-uim') async def ultimate_ironman_hiscores(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches ultimate ironman hiscores for the given username""" - + """Fetch ultimate ironman hiscores for the given username.""" await self.reply_with_hiscores(ctx, username, AccountType.ULTIMATE_IRONMAN, AccountTypeName.ULTIMATE_IRONMAN) @commands.command('07hs-skiller') async def skiller_hiscores(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches skiller hiscores for the given username""" - + """Fetch skiller hiscores for the given username.""" await self.reply_with_hiscores(ctx, username, AccountType.SKILLER, AccountTypeName.SKILLER) @commands.command('07hs-def') async def defence_pure_hiscores(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches 1 Defence hiscores for the given username""" - + """Fetch 1 Defence hiscores for the given username.""" await self.reply_with_hiscores(ctx, username, AccountType.DEFENCE_PURE, AccountTypeName.DEFENCE_PURE) @commands.command('07hs-minigames') async def default_minigames(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches default minigame hiscores for the given username""" - + """Fetch default minigame hiscores for the given username.""" await self.reply_with_minigames(ctx, username, AccountType.NORMAL, AccountTypeName.NORMAL) @commands.command('07hs-im-minigames') async def ironman_minigames(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches ironman minigame hiscores for the given username""" - + """Fetch ironman minigame hiscores for the given username.""" await self.reply_with_minigames(ctx, username, AccountType.IRONMAN, AccountTypeName.IRONMAN) @commands.command('07hs-hcim-minigames') async def hardcore_ironman_minigames(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches hardcore ironman minigame hiscores for the given username""" - + """Fetch hardcore ironman minigame hiscores for the given username.""" await self.reply_with_minigames(ctx, username, AccountType.HARDCORE_IRONMAN, AccountTypeName.HARDCORE_IRONMAN) @commands.command('07hs-uim-minigames') async def ultimate_ironman_minigames(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches ultimate ironman minigame hiscores for the given username""" - + """Fetch ultimate ironman minigame hiscores for the given username.""" await self.reply_with_minigames(ctx, username, AccountType.ULTIMATE_IRONMAN, AccountTypeName.ULTIMATE_IRONMAN) @commands.command('07hs-skiller-minigames') async def skiller_minigames(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches skiller minigame hiscores for the given username""" - + """Fetch skiller minigame hiscores for the given username.""" await self.reply_with_minigames(ctx, username, AccountType.SKILLER, AccountTypeName.SKILLER) @commands.command('07hs-def-minigames') async def defence_pure_minigames(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches 1 Defence minigame hiscores for the given username""" - + """Fetch 1 Defence minigame hiscores for the given username.""" await self.reply_with_minigames(ctx, username, AccountType.DEFENCE_PURE, AccountTypeName.DEFENCE_PURE) @commands.command('07hs-bosses') async def default_bosses(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches default boss hiscores for the given username""" - + """Fetch default boss hiscores for the given username.""" await self.reply_with_bosses(ctx, username, AccountType.NORMAL, AccountTypeName.NORMAL) @commands.command('07hs-im-bosses') async def ironman_bosses(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches ironman boss hiscores for the given username""" - + """Fetch ironman boss hiscores for the given username.""" await self.reply_with_bosses(ctx, username, AccountType.IRONMAN, AccountTypeName.IRONMAN) @commands.command('07hs-hcim-bosses') async def hardcore_ironman_bosses(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches hardcore ironman boss hiscores for the given username""" - + """Fetch hardcore ironman boss hiscores for the given username.""" await self.reply_with_bosses(ctx, username, AccountType.HARDCORE_IRONMAN, AccountTypeName.HARDCORE_IRONMAN) @commands.command('07hs-uim-bosses') async def ultimate_ironman_bosses(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches ultimate ironman boss hiscores for the given username""" - + """Fetch ultimate ironman boss hiscores for the given username.""" await self.reply_with_bosses(ctx, username, AccountType.ULTIMATE_IRONMAN, AccountTypeName.ULTIMATE_IRONMAN) @commands.command('07hs-skiller-bosses') async def skiller_bosses(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches skiller boss hiscores for the given username""" - + """Fetch skiller boss hiscores for the given username.""" await self.reply_with_bosses(ctx, username, AccountType.SKILLER, AccountTypeName.SKILLER) @commands.command('07hs-def-bosses') async def defence_pure_bosses(self: Hiscores, ctx: commands.Context, *, username: str | None = None) -> None: - """Fetches 1 Defence boss hiscores for the given username""" - + """Fetch 1 Defence boss hiscores for the given username.""" await self.reply_with_bosses(ctx, username, AccountType.DEFENCE_PURE, AccountTypeName.DEFENCE_PURE) @classmethod @@ -140,8 +122,7 @@ async def reply_with_hiscores(cls: type[Hiscores], username: str | None, account_type: AccountType, account_type_name: AccountTypeName) -> Message: - """Replies to the chat with the given username's hiscores""" - + """Reply to the chat with the given username's hiscores.""" result = "Hiscores not found." if username is None: @@ -160,8 +141,7 @@ async def reply_with_minigames(cls: type[Hiscores], username: str | None, account_type: AccountType, account_type_name: AccountTypeName) -> Message: - """Replies to the chat with the given username's hiscores""" - + """Reply to the chat with the given username's hiscores.""" result = "Hiscores not found." if username is None: @@ -180,8 +160,7 @@ async def reply_with_bosses(cls: type[Hiscores], username: str | None, account_type: AccountType, account_type_name: AccountTypeName) -> Message | None: - """Replies to the chat with the given username's hiscores""" - + """Reply to the chat with the given username's hiscores.""" result = "Hiscores not found." if username is None: @@ -207,8 +186,7 @@ async def reply_with_bosses(cls: type[Hiscores], @staticmethod async def _fetch_hiscores(username: str, account_type: AccountType) -> list[list[str]] | None: - """Handles fetching the hiscores for RuneScape accounts""" - + """Handle fetching the hiscores for RuneScape accounts.""" url: str = RUNESCAPE_HISCORES_LITE_URL.format( hiscores='_oldschool', gamemode=account_type, diff --git a/src/growlery/config.py b/src/growlery/config.py index 8f21e6f..1c2ba34 100644 --- a/src/growlery/config.py +++ b/src/growlery/config.py @@ -1,4 +1,4 @@ -"""This file contains the global configuration settings for the Discord bot""" +"""Global configuration settings for the Discord bot.""" import os from enum import Enum @@ -135,7 +135,7 @@ class AccountType(str, Enum): - """Specifies different supported account types""" + """Specify different supported account types.""" NORMAL = '' IRONMAN = '_ironman' @@ -146,7 +146,7 @@ class AccountType(str, Enum): class AccountTypeName(str, Enum): - """Specifies names for different supported account types""" + """Specify names for different supported account types.""" NORMAL = '' IRONMAN = 'Ironman' diff --git a/src/growlery/http_request.py b/src/growlery/http_request.py index a7b5386..1e3466d 100644 --- a/src/growlery/http_request.py +++ b/src/growlery/http_request.py @@ -1,4 +1,4 @@ -"""Code for sending and handling HTTP requests to external services""" +"""Code for sending and handling HTTP requests to external services.""" import logging from http import HTTPStatus @@ -9,8 +9,7 @@ async def fetch_page_content(url: str, status_message_override: dict[HTTPStatus, str] | None = None) -> str: - """Handles fetching the content from a given web address""" - + """Fetch the content from a given web address.""" result = '' status_message = { HTTPStatus.NOT_FOUND: "Could not find resource.", @@ -33,7 +32,7 @@ async def fetch_page_content(url: str, status_message_override: dict[HTTPStatus, ), ) - except aiohttp.ClientConnectionError as err: - logger.error("Connection error: %s", err) + except aiohttp.ClientConnectionError: + logger.exception("Connection error") return result diff --git a/src/growlery/main.py b/src/growlery/main.py index 776f094..8d47209 100644 --- a/src/growlery/main.py +++ b/src/growlery/main.py @@ -1,4 +1,4 @@ -"""Implements the core of the bot""" +"""Implement the core of the bot.""" from __future__ import annotations @@ -21,11 +21,10 @@ class MyBot(commands.Bot): - """Logs events related to the bot""" + """Log events related to the bot.""" async def on_ready(self: MyBot) -> None: - """Message indicating that the bot is online""" - + """Message indicating that the bot is online.""" logger.info("Installing cogs...") for cog in cog_list: @@ -34,8 +33,7 @@ async def on_ready(self: MyBot) -> None: logger.info("Logged in as %s", self.user) async def on_message(self: MyBot, message: discord.message.Message) -> None: # pylint: disable=W0221 - """New message detected""" - + """Handle message.""" if message.author == self.user: return diff --git a/src/growlery/table.py b/src/growlery/table.py index 8ced76c..e1c0a10 100644 --- a/src/growlery/table.py +++ b/src/growlery/table.py @@ -1,4 +1,4 @@ -"""Contains code for creating tables out of arbitrary data""" +"""Create tables out of arbitrary data.""" from __future__ import annotations @@ -6,7 +6,7 @@ class Table: - """Used to generate ASCII tables""" + """Used to generate ASCII tables.""" def __init__(self: Table, # pylint: disable=R0913 header_text: str, @@ -14,8 +14,7 @@ def __init__(self: Table, # pylint: disable=R0913 row_names: tuple[str, ...], col_names: tuple[str, ...], cols_with_commas: tuple[str, ...] = ()) -> None: - """Initialises a table""" - + """Initialise a table.""" self.header_text = header_text self.table_data = table_data self.row_names = row_names @@ -29,8 +28,7 @@ def __init__(self: Table, # pylint: disable=R0913 self.preprocess_data() def preprocess_data(self: Table) -> None: - """The data needs to be formatted to better suit our purposes""" - + """Format the data to better suit our purposes.""" for row_name, row_data in zip(self.row_names, self.table_data, strict=False): if len(row_name) > self.longest_cells_per_col[self.col_names[0]]: @@ -47,8 +45,7 @@ def preprocess_data(self: Table) -> None: self.longest_cells_per_col[col] += comma_count def columns_row_content(self: Table) -> str: - """Formats the column header row""" - + """Format the column header row.""" return ' | '.join( f'{col:^{length}}' for col, length in self.longest_cells_per_col.items() @@ -56,13 +53,11 @@ def columns_row_content(self: Table) -> str: @property def column_lengths(self: Table) -> list[int]: - """Returns the lengths of the longest cells in each column""" - + """Return the lengths of the longest cells in each column.""" return list(self.longest_cells_per_col.values()) def generate_header(self: Table) -> list[str]: - """Generates the table header rows""" - + """Generate the table header rows.""" table_width = len(self.columns_row_content()) + 4 column_row_content = '─┬─'.join( '─' * column_length @@ -79,7 +74,7 @@ def generate_header(self: Table) -> list[str]: ] def generate_body(self: Table) -> tuple[list[str], list[str], list[str]]: - """Generates the table body""" + """Generate the table body.""" # There is a current max boss limit of 51, so rows per page can be set to 17. max_row_per_page = 17 body = [] @@ -107,8 +102,7 @@ def generate_body(self: Table) -> tuple[list[str], list[str], list[str]]: return body, second_row, third_row def generate_footer(self: Table) -> str: - """Generates the footer of the table""" - + """Generate the footer of the table.""" content = '═╧═'.join( '═' * column_length for column_length in self.column_lengths @@ -116,7 +110,7 @@ def generate_footer(self: Table) -> str: return f'╚═{content}═╝' def render_table(self: Table) -> str | tuple[str, ...]: - """Returns the full table with formatting""" + """Return the full table with formatting.""" # Checks if there is another page of data # In this case the second element in the tuple, which would be the second list of rows or page. # If there is another page present, this code creates a table_rows with the first page. @@ -166,15 +160,14 @@ def render_table(self: Table) -> str | tuple[str, ...]: class SkillsTable(Table): - """Used to create ASCII tables for skill hiscores""" + """Used to create ASCII tables for skill hiscores.""" def __init__(self: SkillsTable, username: str, account_type: AccountType, account_type_name: AccountTypeName, table_data: list[list[str]]) -> None: - """Handles converting the data for the parent class""" - + """Handle converting the data for the parent class.""" header_text = f"STATS FOR {username.replace('_', ' ').upper()}" if account_type != AccountType.NORMAL: header_text += f" [{account_type_name.upper()}]" @@ -191,15 +184,14 @@ def __init__(self: SkillsTable, class MinigamesTable(Table): - """Used to create ASCII tables for minigame hiscores""" + """Used to create ASCII tables for minigame hiscores.""" def __init__(self: MinigamesTable, username: str, account_type: AccountType, account_type_name: AccountTypeName, table_data: list[list[str]]) -> None: - """Handles converting the data for the parent class""" - + """Handle converting the data for the parent class.""" sliced_data = table_data[len(SKILL_NAMES):] header_text = f"MINIGAMES FOR {username.replace('_', ' ').upper()}" if account_type != AccountType.NORMAL: @@ -217,15 +209,14 @@ def __init__(self: MinigamesTable, class BossesTable(Table): - """Used to create ASCII tables for boss hiscores""" + """Used to create ASCII tables for boss hiscores.""" def __init__(self: BossesTable, username: str, account_type: AccountType, account_type_name: AccountTypeName, table_data: list[list[str]]) -> None: - """Handles converting the data for the parent class""" - + """Handle converting the data for the parent class.""" sliced_data = table_data[len(SKILL_NAMES)+len(MINIGAME_NAMES):] header_text = f"BOSS KILLS FOR {username.replace('_', ' ').upper()}" if account_type != AccountType.NORMAL: diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/conftest.py b/tests/conftest.py index 1ab9170..af110b5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,4 @@ -"""Contains global fixtures for unit tests""" +"""Global fixtures for unit tests.""" import discord import pytest_asyncio @@ -13,8 +13,7 @@ @pytest_asyncio.fixture async def bot(): - """Creates a bot instance for testing""" - + """Create a bot instance for testing.""" intents = discord.Intents.default() intents.members = True intents.message_content = True @@ -33,7 +32,6 @@ async def bot(): @pytest_asyncio.fixture(autouse=True) async def cleanup(): - """Performs cleanup after every test, emptying the message queue""" - + """Perform cleanup after every test, emptying the message queue.""" yield await dpytest.empty_queue() diff --git a/tests/test_hiscores.py b/tests/test_hiscores.py index 2ad4e31..4a2dba9 100644 --- a/tests/test_hiscores.py +++ b/tests/test_hiscores.py @@ -1,4 +1,4 @@ -"""Tests hiscores functionality""" +"""Test hiscores functionality.""" import discord.ext.test as dpytest import pytest @@ -46,8 +46,7 @@ @pytest.mark.asyncio() async def test_no_name_given(bot): # pylint: disable=W0613 - """Tests commands without name input""" - + """Test commands without name input.""" await dpytest.message(f"{COMMAND_PREFIX}07hs") assert dpytest.verify().message().content("Username assigning to Discord profile not implemented yet.") @@ -60,8 +59,7 @@ async def test_no_name_given(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_normal_success(bot): # pylint: disable=W0613 - """Tests posting the stats of a regular account""" - + """Test posting the stats of a regular account.""" for user in TEST_USERS: await dpytest.message(f"{COMMAND_PREFIX}07hs {user}") assert dpytest.verify().message().contains().content(f"STATS FOR {user.upper()}") @@ -69,16 +67,14 @@ async def test_normal_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_normal_failure(bot): # pylint: disable=W0613 - """Tests posting the stats of a nonexistent regular account""" - + """Test posting the stats of a nonexistent regular account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_ironman_success(bot): # pylint: disable=W0613 - """Tests posting the stats of an ironman account""" - + """Test posting the stats of an ironman account.""" for user in TEST_USERNAMES_IRONMAN: await dpytest.message(f"{COMMAND_PREFIX}07hs-im {user}") assert dpytest.verify().message().contains().content(f"STATS FOR {user.upper()}") @@ -86,16 +82,14 @@ async def test_ironman_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_ironman_failure(bot): # pylint: disable=W0613 - """Tests posting the stats of a nonexistent ironman account""" - + """Test posting the stats of a nonexistent ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-im {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_hardcore_ironman_success(bot): # pylint: disable=W0613 - """Tests posting the stats of a hardcore ironman account""" - + """Test posting the stats of a hardcore ironman account.""" for user in TEST_USERNAMES_HARDCORE: await dpytest.message(f"{COMMAND_PREFIX}07hs-hcim {user}") assert dpytest.verify().message().contains().content(f"STATS FOR {user.upper()}") @@ -103,16 +97,14 @@ async def test_hardcore_ironman_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_hardcore_ironman_failure(bot): # pylint: disable=W0613 - """Tests posting the stats of a nonexistent hardcore ironman account""" - + """Test posting the stats of a nonexistent hardcore ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-hcim {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_ultimate_ironman_success(bot): # pylint: disable=W0613 - """Tests posting the stats of an ultimate ironman account""" - + """Test posting the stats of an ultimate ironman account.""" for user in TEST_USERNAMES_ULTIMATE: await dpytest.message(f"{COMMAND_PREFIX}07hs-uim {user}") assert dpytest.verify().message().contains().content(f"STATS FOR {user.upper()}") @@ -120,16 +112,14 @@ async def test_ultimate_ironman_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_ultimate_ironman_failure(bot): # pylint: disable=W0613 - """Tests posting the stats of a nonexistent ultimate ironman account""" - + """Test posting the stats of a nonexistent ultimate ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-uim {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_skiller_success(bot): # pylint: disable=W0613 - """Tests posting the stats of a skiller account""" - + """Test posting the stats of a skiller account.""" for user in TEST_USERNAMES_SKILLER: await dpytest.message(f"{COMMAND_PREFIX}07hs-skiller {user}") assert dpytest.verify().message().contains().content(f"STATS FOR {user.upper()}") @@ -137,16 +127,14 @@ async def test_skiller_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_skiller_failure(bot): # pylint: disable=W0613 - """Tests posting the stats of a nonexistent skiller account""" - + """Test posting the stats of a nonexistent skiller account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-skiller {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_1def_pure_success(bot): # pylint: disable=W0613 - """Tests posting the stats of a 1-Defence pure account""" - + """Test posting the stats of a 1-Defence pure account.""" for user in TEST_USERNAMES_1DEF_PURE: await dpytest.message(f"{COMMAND_PREFIX}07hs-def {user}") assert dpytest.verify().message().contains().content(f"STATS FOR {user.upper()}") @@ -154,16 +142,14 @@ async def test_1def_pure_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_1def_pure_failure(bot): # pylint: disable=W0613 - """Tests posting the stats of a nonexistent 1-Defence pure account""" - + """Test posting the stats of a nonexistent 1-Defence pure account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-def {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_normal_minigames_success(bot): # pylint: disable=W0613 - """Tests posting the minigames of a regular account""" - + """Test posting the minigames of a regular account.""" for user in TEST_USERS: await dpytest.message(f"{COMMAND_PREFIX}07hs-minigames {user}") assert dpytest.verify().message().contains().content(f"MINIGAMES FOR {user.upper()}") @@ -171,16 +157,14 @@ async def test_normal_minigames_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_normal_minigames_failure(bot): # pylint: disable=W0613 - """Tests posting the minigames of a nonexistent regular account""" - + """Test posting the minigames of a nonexistent regular account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-minigames {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_ironman_minigames_success(bot): # pylint: disable=W0613 - """Tests posting the minigames of an ironman account""" - + """Test posting the minigames of an ironman account.""" for user in TEST_USERNAMES_IRONMAN: await dpytest.message(f"{COMMAND_PREFIX}07hs-im-minigames {user}") assert dpytest.verify().message().contains().content(f"MINIGAMES FOR {user.upper()}") @@ -188,16 +172,14 @@ async def test_ironman_minigames_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_ironman_minigames_failure(bot): # pylint: disable=W0613 - """Tests posting the minigames of a nonexistent ironman account""" - + """Test posting the minigames of a nonexistent ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-im-minigames {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_hardcore_ironman_minigames_success(bot): # pylint: disable=W0613 - """Tests posting the minigames of a hardcore ironman account""" - + """Test posting the minigames of a hardcore ironman account.""" for user in TEST_USERNAMES_HARDCORE: await dpytest.message(f"{COMMAND_PREFIX}07hs-hcim-minigames {user}") assert dpytest.verify().message().contains().content(f"MINIGAMES FOR {user.upper()}") @@ -205,16 +187,14 @@ async def test_hardcore_ironman_minigames_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_hardcore_ironman_minigames_failure(bot): # pylint: disable=W0613 - """Tests posting the minigames of a nonexistent hardcore ironman account""" - + """Test posting the minigames of a nonexistent hardcore ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-hcim-minigames {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_ultimate_ironman_minigames_success(bot): # pylint: disable=W0613 - """Tests posting the minigames of an ultimate ironman account""" - + """Test posting the minigames of an ultimate ironman account.""" for user in TEST_USERNAMES_ULTIMATE: await dpytest.message(f"{COMMAND_PREFIX}07hs-uim-minigames {user}") assert dpytest.verify().message().contains().content(f"MINIGAMES FOR {user.upper()}") @@ -222,16 +202,14 @@ async def test_ultimate_ironman_minigames_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_ultimate_ironman_minigames_failure(bot): # pylint: disable=W0613 - """Tests posting the minigames of a nonexistent ultimate ironman account""" - + """Test posting the minigames of a nonexistent ultimate ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-uim-minigames {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_skiller_minigames_success(bot): # pylint: disable=W0613 - """Tests posting the minigames of a skiller account""" - + """Test posting the minigames of a skiller account.""" for user in TEST_USERNAMES_SKILLER: await dpytest.message(f"{COMMAND_PREFIX}07hs-skiller-minigames {user}") assert dpytest.verify().message().contains().content(f"MINIGAMES FOR {user.upper()}") @@ -239,16 +217,14 @@ async def test_skiller_minigames_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_skiller_minigames_failure(bot): # pylint: disable=W0613 - """Tests posting the minigames of a nonexistent skiller account""" - + """Test posting the minigames of a nonexistent skiller account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-skiller-minigames {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_1def_pure_minigames_success(bot): # pylint: disable=W0613 - """Tests posting the minigames of a 1-Defence pure account""" - + """Test posting the minigames of a 1-Defence pure account.""" for user in TEST_USERNAMES_1DEF_PURE: await dpytest.message(f"{COMMAND_PREFIX}07hs-def-minigames {user}") assert dpytest.verify().message().contains().content(f"MINIGAMES FOR {user.upper()}") @@ -256,16 +232,14 @@ async def test_1def_pure_minigames_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_1def_pure_minigames_failure(bot): # pylint: disable=W0613 - """Tests posting the minigames of a nonexistent 1-Defence pure account""" - + """Test posting the minigames of a nonexistent 1-Defence pure account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-def-minigames {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_normal_bosses_success(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a regular account""" - + """Test posting the boss kills of a regular account.""" for user in TEST_USERS: await dpytest.message(f"{COMMAND_PREFIX}07hs-bosses {user}") assert dpytest.verify().message().contains().content(f"BOSS KILLS FOR {user.upper()}") @@ -273,16 +247,14 @@ async def test_normal_bosses_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_normal_bosses_failure(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a nonexistent regular account""" - + """Test posting the boss kills of a nonexistent regular account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-bosses {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_ironman_bosses_success(bot): # pylint: disable=W0613 - """Tests posting the boss kills of an ironman account""" - + """Test posting the boss kills of an ironman account.""" for user in TEST_USERNAMES_IRONMAN: await dpytest.message(f"{COMMAND_PREFIX}07hs-im-bosses {user}") assert dpytest.verify().message().contains().content(f"BOSS KILLS FOR {user.upper()}") @@ -290,16 +262,14 @@ async def test_ironman_bosses_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_ironman_bosses_failure(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a nonexistent ironman account""" - + """Test posting the boss kills of a nonexistent ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-im-bosses {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_hardcore_ironman_bosses_success(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a hardcore ironman account""" - + """Test posting the boss kills of a hardcore ironman account.""" for user in TEST_USERNAMES_HARDCORE: await dpytest.message(f"{COMMAND_PREFIX}07hs-hcim-bosses {user}") assert dpytest.verify().message().contains().content(f"BOSS KILLS FOR {user.upper()}") @@ -307,16 +277,14 @@ async def test_hardcore_ironman_bosses_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_hardcore_ironman_bosses_failure(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a nonexistent hardcore ironman account""" - + """Test posting the boss kills of a nonexistent hardcore ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-hcim-bosses {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_ultimate_ironman_bosses_success(bot): # pylint: disable=W0613 - """Tests posting the boss kills of an ultimate ironman account""" - + """Test posting the boss kills of an ultimate ironman account.""" for user in TEST_USERNAMES_ULTIMATE: await dpytest.message(f"{COMMAND_PREFIX}07hs-uim-bosses {user}") assert dpytest.verify().message().contains().content(f"BOSS KILLS FOR {user.upper()}") @@ -324,16 +292,14 @@ async def test_ultimate_ironman_bosses_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_ultimate_ironman_bosses_failure(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a nonexistent ultimate ironman account""" - + """Test posting the boss kills of a nonexistent ultimate ironman account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-uim-bosses {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_skiller_bosses_success(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a skiller account""" - + """Test posting the boss kills of a skiller account.""" for user in TEST_USERNAMES_SKILLER: await dpytest.message(f"{COMMAND_PREFIX}07hs-skiller-bosses {user}") assert dpytest.verify().message().contains().content(f"BOSS KILLS FOR {user.upper()}") @@ -341,16 +307,14 @@ async def test_skiller_bosses_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_skiller_bosses_failure(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a nonexistent skiller account""" - + """Test posting the boss kills of a nonexistent skiller account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-skiller-bosses {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") @pytest.mark.asyncio() async def test_1def_pure_bosses_success(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a 1-Defence pure account""" - + """Test posting the boss kills of a 1-Defence pure account.""" for user in TEST_USERNAMES_1DEF_PURE: await dpytest.message(f"{COMMAND_PREFIX}07hs-def-bosses {user}") assert dpytest.verify().message().contains().content(f"BOSS KILLS FOR {user.upper()}") @@ -358,7 +322,6 @@ async def test_1def_pure_bosses_success(bot): # pylint: disable=W0613 @pytest.mark.asyncio() async def test_1def_pure_bosses_failure(bot): # pylint: disable=W0613 - """Tests posting the boss kills of a nonexistent 1-Defence pure account""" - + """Test posting the boss kills of a nonexistent 1-Defence pure account.""" await dpytest.message(f"{COMMAND_PREFIX}07hs-def-bosses {NONEXISTENT_USER}") assert dpytest.verify().message().content("Hiscores not found.") diff --git a/tests/test_http_request.py b/tests/test_http_request.py index 449475d..e1390db 100644 --- a/tests/test_http_request.py +++ b/tests/test_http_request.py @@ -1,4 +1,4 @@ -"""Tests hiscores functionality""" +"""Test hiscores functionality.""" import pytest @@ -8,8 +8,7 @@ @pytest.mark.asyncio() async def test_fetch_page_content_default_status(): - """Tests fetching page content with defalt status messages""" - + """Test fetching page content with defalt status messages.""" assert await fetch_page_content( url=RUNESCAPE_HISCORES_LITE_URL.format( hiscores='_oldschool', @@ -21,13 +20,11 @@ async def test_fetch_page_content_default_status(): @pytest.mark.asyncio() async def test_fetch_page_content_bad_url(): - """Tests error handling""" - + """Test error handling.""" assert not await fetch_page_content(url="http://totallybrokenurlthisshouldnotwork.com") @pytest.mark.asyncio() async def test_fetch_page_content_non_ok_status(): - """Tests fetching page content and handing a non-OK status""" - + """Test fetching page content and handing a non-OK status.""" assert not await fetch_page_content(url="https://httpstat.us/404")