Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Install Python Dependencies
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: uv sync --locked --extra dev
run: uv sync --no-build --no-install-project --locked --extra dev

- name: Test with pytest
id: test
Expand All @@ -84,7 +84,7 @@ jobs:
REDDIT_USERNAME: ${{ vars.REDDIT_USERNAME }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
shell: bash
run: uv run --locked --extra dev pytest tests
run: uv run --no-build --no-sync python -m pytest tests

- name: Upload test coverage
# any except canceled or skipped
Expand Down
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@ rm -rf /var/lib/apt/lists/*
useradd -m -u 1000 -s /bin/bash supportbot

# write the version to the version file
cat > src/common/version.py <<EOF
"""Version information for support-bot."""

__version__ = "${BUILD_VERSION}"
EOF
printf '%s\n' '"""Version information for support-bot."""' '' "__version__ = \"${BUILD_VERSION}\"" \
> src/common/version.py

# install python dependencies
uv sync --frozen --no-dev --no-install-project --python python --no-python-downloads
uv sync --frozen --no-build --no-dev --no-install-project --python python --no-python-downloads

# set ownership of app and data directories
mkdir -p /data
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def discord_bot():
globals.DISCORD_BOT = None


@pytest.fixture(scope='function')
@pytest.fixture
def discord_db_users(discord_bot):
with discord_bot.db as db:
users_table = db.table('discord_users')
Expand All @@ -57,7 +57,7 @@ def discord_db_users(discord_bot):
discord_bot.oauth_states.clear()


@pytest.fixture(scope='function')
@pytest.fixture
def no_github_token():
og_token = os.getenv('GITHUB_TOKEN')
del os.environ['GITHUB_TOKEN']
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/common/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ def setup_certificates():
os.remove(KEY_FILE)


@pytest.fixture(scope='function')
@pytest.fixture
def clear_certificates():
os.remove(CERT_FILE)
os.remove(KEY_FILE)
yield


def test_check_expiration(setup_certificates):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/common/test_logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ def test_log_format_includes_file_and_line_number(self, tmp_path):
log_content = log_file.read_text()

# Check format includes file and line number
assert "[" in log_content and "]" in log_content
assert "[" in log_content
assert "]" in log_content
assert "test_format" in log_content
assert "Test message" in log_content

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/common/test_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from src.common import webapp


@pytest.fixture(scope='function')
@pytest.fixture
def test_client():
"""Create a test client for testing webapp endpoints"""
app = webapp.app
Expand Down
26 changes: 11 additions & 15 deletions tests/unit/discord/test_rank_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,20 @@ async def test_build_leaderboard_embed_discord(mocker):


@pytest.mark.asyncio
async def test_build_leaderboard_embed_reddit(mocker):
async def test_build_leaderboard_embed_reddit(mocker, monkeypatch):
cog = rank_cog(mocker)
original_reddit_bot = globals.REDDIT_BOT
globals.REDDIT_BOT = SimpleNamespace(
monkeypatch.setattr(globals, 'REDDIT_BOT', SimpleNamespace(
subreddit=SimpleNamespace(community_icon='https://example.com/reddit.png'),
)
))

try:
embed = await cog.build_leaderboard_embed(
platform='reddit',
leaderboard_data=[{'user_id': 'abc', 'username': 'reddit_user', 'xp': 0}],
page=1,
total_pages=1,
total_users=1,
ctx=SimpleNamespace(guild=SimpleNamespace(icon=None)),
)
finally:
globals.REDDIT_BOT = original_reddit_bot
embed = await cog.build_leaderboard_embed(
platform='reddit',
leaderboard_data=[{'user_id': 'abc', 'username': 'reddit_user', 'xp': 0}],
page=1,
total_pages=1,
total_users=1,
ctx=SimpleNamespace(guild=SimpleNamespace(icon=None)),
)

assert embed.title == '🏆 Reddit XP Leaderboard'
assert '**u/reddit_user**' in embed.description
Expand Down