forked from retoor/devplacepy
chore: reorganize test files into domain-specific subdirectories under tests/
Split the monolithic test directory into three tiers (unit, api, e2e) with a path-mirroring directory structure. Added corresponding Makefile targets (test-unit, test-api, test-e2e) and updated all documentation references (CLAUDE.md, README.md, testing-cicd.html, testing-framework.html, testing-make.html) to reflect the new layout and naming conventions.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import time
|
||||
import requests
|
||||
from tests.conftest import BASE_URL
|
||||
from devplacepy.database import get_table
|
||||
_counter_follow_api = [0]
|
||||
def _session_follow_api():
|
||||
_counter_follow_api[0] += 1
|
||||
name = f"flw{int(time.time() * 1000)}{_counter_follow_api[0]}"
|
||||
s = requests.Session()
|
||||
s.post(
|
||||
f"{BASE_URL}/auth/signup",
|
||||
data={
|
||||
"username": name,
|
||||
"email": f"{name}@t.dev",
|
||||
"password": "secret123",
|
||||
"confirm_password": "secret123",
|
||||
},
|
||||
allow_redirects=True,
|
||||
)
|
||||
return s, name
|
||||
def _uid_follow_api(username):
|
||||
return get_table("users").find_one(username=username)["uid"]
|
||||
|
||||
|
||||
def test_unfollow_removes_follow(app_server):
|
||||
s_a, a_name = _session_follow_api()
|
||||
_, b_name = _session_follow_api()
|
||||
a_uid, b_uid = _uid_follow_api(a_name), _uid_follow_api(b_name)
|
||||
|
||||
s_a.post(f"{BASE_URL}/follow/{b_name}", allow_redirects=False)
|
||||
s_a.post(f"{BASE_URL}/follow/unfollow/{b_name}", allow_redirects=False)
|
||||
assert (
|
||||
get_table("follows").count(
|
||||
follower_uid=a_uid, following_uid=b_uid, deleted_at=None
|
||||
)
|
||||
== 0
|
||||
)
|
||||
|
||||
r = s_a.post(f"{BASE_URL}/follow/unfollow/{b_name}", allow_redirects=False)
|
||||
assert r.status_code == 302
|
||||
Reference in New Issue
Block a user