Don't access the database in tests

This requires the mastodon instance to be patched so that email
confirmation is not required, but makes it possible to run tests on a
remote instance.
This commit is contained in:
Ivan Habunek 2024-01-02 21:56:51 +01:00
parent db266c563d
commit 5a26ab4940
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
1 changed files with 0 additions and 11 deletions

View File

@ -9,13 +9,11 @@ your test server and database:
```
export TOOT_TEST_BASE_URL="localhost:3000"
export TOOT_TEST_DATABASE_DSN="dbname=mastodon_development"
```
"""
import json
import os
import psycopg2
import pytest
import re
import typing as t
@ -36,7 +34,6 @@ def pytest_configure(config):
Run = t.Callable[..., Result]
# Mastodon database name, used to confirm user registration without having to click the link
DATABASE_DSN = os.getenv("TOOT_TEST_DATABASE_DSN")
TOOT_TEST_BASE_URL = os.getenv("TOOT_TEST_BASE_URL")
# Toot logo used for testing image upload
@ -56,17 +53,9 @@ def register_account(app: App):
email = f"{username}@example.com"
response = api.register_account(app, username, email, "password", "en")
confirm_user(email)
return User(app.instance, username, response["access_token"])
def confirm_user(email):
conn = psycopg2.connect(DATABASE_DSN)
cursor = conn.cursor()
cursor.execute("UPDATE users SET confirmed_at = now() WHERE email = %s;", (email,))
conn.commit()
# ------------------------------------------------------------------------------
# Fixtures
# ------------------------------------------------------------------------------