tests-fix-1

This commit is contained in:
2025-08-27 02:45:15 +03:00
parent 90aece7a60
commit eef2ae1d5e
9 changed files with 413 additions and 115 deletions

View File

@@ -55,12 +55,74 @@ def test_delete_existing_community(api_base_url, auth_headers, test_user_credent
# Проверяем, что авторизация прошла успешно
if not login_data["data"]["login"]["token"] or not login_data["data"]["login"]["author"]:
print("⚠️ Авторизация не прошла - токен или author отсутствуют")
pytest.skip("Авторизация не прошла - возможно, проблемы с Redis")
token = login_data["data"]["login"]["token"]
author_id = login_data["data"]["login"]["author"]["id"]
print(f"🔑 Токен получен: {token[:50]}...")
print(f"👤 Author ID: {author_id}")
print("🔄 Пробуем альтернативный способ авторизации...")
# Пробуем создать пользователя и войти
try:
create_user_mutation = """
mutation CreateUser($input: AuthorInput!) {
create_author(input: $input) {
success
author {
id
email
name
}
error
}
}
"""
create_user_variables = {
"input": {
"email": "test-user-delete@example.com",
"name": "Test User Delete",
"password": "testpass123"
}
}
create_response = requests.post(
api_base_url,
json={"query": create_user_mutation, "variables": create_user_variables},
headers=auth_headers(),
timeout=10
)
if create_response.status_code == 200:
create_data = create_response.json()
if create_data.get("data", {}).get("create_author", {}).get("success"):
print("✅ Пользователь создан, пробуем войти...")
# Теперь пробуем войти с новым пользователем
login_response = requests.post(
api_base_url,
json={"query": login_mutation, "variables": create_user_variables},
headers=auth_headers(),
timeout=10
)
if login_response.status_code == 200:
new_login_data = login_response.json()
if new_login_data.get("data", {}).get("login", {}).get("token"):
token = new_login_data["data"]["login"]["token"]
author_id = new_login_data["data"]["login"]["author"]["id"]
print(f"✅ Авторизация с новым пользователем успешна")
print(f"🔑 Токен получен: {token[:50]}...")
print(f"👤 Author ID: {author_id}")
else:
pytest.skip("Не удалось авторизоваться даже с новым пользователем")
else:
pytest.skip("Ошибка при входе с новым пользователем")
else:
pytest.skip("Не удалось создать тестового пользователя")
else:
pytest.skip("Ошибка при создании пользователя")
except Exception as e:
pytest.skip(f"Не удалось создать пользователя: {e}")
else:
token = login_data["data"]["login"]["token"]
author_id = login_data["data"]["login"]["author"]["id"]
print(f"🔑 Токен получен: {token[:50]}...")
print(f"👤 Author ID: {author_id}")
# Теперь попробуем удалить существующее сообщество
delete_mutation = """