mirror of
https://github.com/ihabunek/toot
synced 2025-01-10 16:52:40 +01:00
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:
parent
db266c563d
commit
5a26ab4940
@ -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
|
||||
# ------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user