Files
pravda/tests/test_database.py
Steve Dudenhoeffer c75856ff44
Some checks failed
Build and Push Docker Image / build (push) Failing after 1m59s
Implement Pravda: Truth Social to Discord relay service
- Add core modules: database (SQLite), media (ffmpeg), discord (webhook), poller (truthbrush), server (FastAPI)
- Support video transcoding to H.264/AAC with automatic size management
- Handle message splitting for Discord limits (2000 chars, 10 attachments)
- Include interactive buttons (Delete, View Raw, Original Post)
- Add Dockerfile with ffmpeg and entrypoint script
- Add Gitea Actions workflow for CI/CD
- Configure code style tools (black, ruff, mypy)
- Include basic unit tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 01:01:59 -05:00

42 lines
1.1 KiB
Python

"""Tests for the database module."""
import os
import tempfile
import pytest
def test_database_operations() -> None:
"""Test basic database operations."""
# Use a temporary database for testing
with tempfile.TemporaryDirectory() as tmpdir:
db_path = os.path.join(tmpdir, "test.db")
os.environ["DB_PATH"] = db_path
# Import after setting env var
from src.database import init_db, is_post_seen, mark_post_seen, get_seen_count
init_db()
# Initially, no posts are seen
assert not is_post_seen("123")
assert get_seen_count() == 0
# Mark a post as seen
mark_post_seen("123")
assert is_post_seen("123")
assert get_seen_count() == 1
# Mark the same post again (should be idempotent)
mark_post_seen("123")
assert is_post_seen("123")
assert get_seen_count() == 1
# Mark another post
mark_post_seen("456")
assert is_post_seen("456")
assert get_seen_count() == 2
# Original post still seen
assert is_post_seen("123")