Compare commits

...

7 Commits

Author SHA1 Message Date
stijndcl 257eae6fa7 Remove pytest-alembic 2022-06-23 12:09:54 +02:00
stijndcl ee03cf7d8c Try to fix tables fixture 2022-06-23 12:04:29 +02:00
stijndcl 36909f04bd Use alembic test package 2022-06-23 11:56:25 +02:00
stijndcl 85a7750d09 No longer run migrations in tests 2022-06-23 11:53:21 +02:00
stijndcl 6b91e792e6 Use event loop fixture again 2022-06-23 11:38:58 +02:00
stijndcl cc8f8b1ee4 Try to fix tests 2022-06-23 11:24:12 +02:00
stijndcl 3ce823f209 Stash 2022-06-23 11:09:43 +02:00
3 changed files with 10 additions and 17 deletions

View File

@ -36,7 +36,6 @@ class Owner(commands.Cog):
self.client.tree.copy_global_to(guild=guild)
await self.client.tree.sync(guild=guild)
else:
self.client.tree.clear_commands(guild=None)
await self.client.tree.sync()
await ctx.message.add_reaction("🔄")
@ -73,14 +72,14 @@ class Owner(commands.Cog):
@add_slash.command(name="custom", description="Add a custom command")
async def add_custom_slash(self, interaction: discord.Interaction):
"""Slash command to add a custom command"""
if not self.client.is_owner(interaction.user):
if not await self.client.is_owner(interaction.user):
return interaction.response.send_message(
"Je hebt geen toestemming om dit commando uit te voeren.", ephemeral=True
)
await interaction.response.defer(ephemeral=True)
# await interaction.response.defer(ephemeral=True)
modal = CreateCustomCommand()
await interaction.response.send_message(modal)
await interaction.response.send_modal(modal)
@commands.group(name="Edit")
async def edit(self, ctx: commands.Context):

View File

@ -6,10 +6,10 @@ import discord
class CreateCustomCommand(discord.ui.Modal, title="Custom Command"):
"""Modal shown to visually create custom commands"""
name: discord.ui.TextInput = discord.ui.TextInput(label="Name", placeholder="Name of the command...")
name: discord.ui.TextInput = discord.ui.TextInput(label="Name", placeholder="Name of the command")
response: discord.ui.TextInput = discord.ui.TextInput(
label="Response", style=discord.TextStyle.long, placeholder="Response of the command...", max_length=2000
label="Response", style=discord.TextStyle.long, placeholder="Response of the command", max_length=2000
)
async def on_submit(self, interaction: discord.Interaction) -> None:

View File

@ -3,11 +3,10 @@ from typing import AsyncGenerator, Generator
from unittest.mock import MagicMock
import pytest
from alembic import command, config
from sqlalchemy.ext.asyncio import AsyncSession
from database.engine import engine
from database.models import Base
from didier import Didier
@ -19,15 +18,10 @@ def event_loop() -> Generator:
@pytest.fixture(scope="session")
def tables(event_loop):
"""Initialize a database before the tests, and then tear it down again
Starts from an empty database and runs through all the migrations to check those as well
while we're at it
"""
alembic_config = config.Config("alembic.ini")
command.upgrade(alembic_config, "head")
yield
command.downgrade(alembic_config, "base")
async def tables(event_loop):
"""Initialize a database before the tests, and then tear it down again"""
async with engine.begin() as connection:
await connection.run_sync(Base.metadata.create_all)
@pytest.fixture