Add CI pytest job

This commit is contained in:
JelNiSław 2022-06-04 00:35:48 +02:00
parent a1f7d87a2e
commit 013e326a30
No known key found for this signature in database
GPG key ID: EA41571A0A88E97E
5 changed files with 36 additions and 4 deletions

24
.github/workflows/pytest.yml vendored Normal file
View file

@ -0,0 +1,24 @@
name: Test with pytest
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Set up Python 3
uses: actions/setup-python@main
with:
python-version: "3.x"
- name: Install Poetry
run: curl https://install.python-poetry.org | python -
- name: Install dependencies
run: poetry install
- name: Run pytest
run: poetry run python -m pytest

View file

@ -18,7 +18,7 @@ def is_ios_request(text: str, /) -> bool:
# the text is longer and doesn't look like just a simple question
return False
words = set(remove_diacritics(text.replace("?", "").replace("!", "")).lower().split())
words = set(remove_diacritics(text.replace("?", "").replace("!", "")).casefold().split())
if "ios" not in words:
return False

View file

@ -29,7 +29,7 @@ class FAQ(commands.Cog):
return [
app_commands.Choice(name=question, value=question)
for question in self.questions
if current.lower() in question.lower()
if current.casefold() in question.casefold()
]
@app_commands.command()

View file

@ -155,7 +155,8 @@ class GitHub(commands.Cog):
if message.author.bot:
return
words = message.content.split()
# `dict.fromkeys` allows us to deduplicate the list whilst preserving order
words = dict.fromkeys(message.content.casefold().split()).keys()
embeds = []
try:
@ -193,6 +194,7 @@ class GitHub(commands.Cog):
view = DeleteButton(message.author)
reply = await message.reply(embeds=embeds[:3], view=view)
view.message = reply
print(reply.embeds)
async def setup(bot: bot.Wulkabot):

View file

@ -8,11 +8,17 @@ class DeleteButton(discord.ui.View):
self.message: discord.Message | None = None
async def interaction_check(self, interaction: discord.Interaction) -> bool:
return (
if (
interaction.user == self.invoker
or isinstance(interaction.user, discord.Member)
and interaction.user.resolved_permissions.manage_messages
):
return True
await interaction.response.send_message(
"Tylko osoba która wywołała bota może usunąć tę wiadomość", ephemeral=True
)
return False
@discord.ui.button(label="Usuń", style=discord.ButtonStyle.danger)
async def confirm(self, interaction: discord.Interaction, button: discord.ui.Button) -> None: