From 5a26ab4940f7b5214c9c3c55a3c8c5ef1f0f7332 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Tue, 2 Jan 2024 21:56:51 +0100 Subject: [PATCH] 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. --- tests/integration/conftest.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 8e3f3be..fbb04f5 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -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 # ------------------------------------------------------------------------------