Add CI pytest job
This commit is contained in:
parent
a1f7d87a2e
commit
013e326a30
5 changed files with 36 additions and 4 deletions
24
.github/workflows/pytest.yml
vendored
Normal file
24
.github/workflows/pytest.yml
vendored
Normal 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
|
|
@ -18,7 +18,7 @@ def is_ios_request(text: str, /) -> bool:
|
||||||
# the text is longer and doesn't look like just a simple question
|
# the text is longer and doesn't look like just a simple question
|
||||||
return False
|
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:
|
if "ios" not in words:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -29,7 +29,7 @@ class FAQ(commands.Cog):
|
||||||
return [
|
return [
|
||||||
app_commands.Choice(name=question, value=question)
|
app_commands.Choice(name=question, value=question)
|
||||||
for question in self.questions
|
for question in self.questions
|
||||||
if current.lower() in question.lower()
|
if current.casefold() in question.casefold()
|
||||||
]
|
]
|
||||||
|
|
||||||
@app_commands.command()
|
@app_commands.command()
|
||||||
|
|
|
@ -155,7 +155,8 @@ class GitHub(commands.Cog):
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
return
|
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 = []
|
embeds = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -193,6 +194,7 @@ class GitHub(commands.Cog):
|
||||||
view = DeleteButton(message.author)
|
view = DeleteButton(message.author)
|
||||||
reply = await message.reply(embeds=embeds[:3], view=view)
|
reply = await message.reply(embeds=embeds[:3], view=view)
|
||||||
view.message = reply
|
view.message = reply
|
||||||
|
print(reply.embeds)
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot: bot.Wulkabot):
|
async def setup(bot: bot.Wulkabot):
|
||||||
|
|
|
@ -8,11 +8,17 @@ class DeleteButton(discord.ui.View):
|
||||||
self.message: discord.Message | None = None
|
self.message: discord.Message | None = None
|
||||||
|
|
||||||
async def interaction_check(self, interaction: discord.Interaction) -> bool:
|
async def interaction_check(self, interaction: discord.Interaction) -> bool:
|
||||||
return (
|
if (
|
||||||
interaction.user == self.invoker
|
interaction.user == self.invoker
|
||||||
or isinstance(interaction.user, discord.Member)
|
or isinstance(interaction.user, discord.Member)
|
||||||
and interaction.user.resolved_permissions.manage_messages
|
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)
|
@discord.ui.button(label="Usuń", style=discord.ButtonStyle.danger)
|
||||||
async def confirm(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
|
async def confirm(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
|
||||||
|
|
Loading…
Reference in a new issue