mirror of
https://github.com/bohd4nx/FragmentAPI.git
synced 2026-07-25 06:14:29 +00:00
refactor: enhance test workflow and integration tests with cookies handling and configuration checks
This commit is contained in:
@@ -21,7 +21,18 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt pytest pytest-asyncio
|
||||
|
||||
- name: Write cookies.json
|
||||
if: ${{ env.COOKIES_JSON != '' }}
|
||||
run: echo "$COOKIES_JSON" > cookies.json
|
||||
env:
|
||||
COOKIES_JSON: ${{ secrets.COOKIES_JSON }}
|
||||
|
||||
- name: Run tests
|
||||
if: github.ref != 'refs/heads/master'
|
||||
run: pytest --ignore=tests/003_test_integration.py
|
||||
|
||||
- name: Run tests (master — full suite)
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: pytest
|
||||
env:
|
||||
SEED: ${{ secrets.SEED }}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"""End-to-end integration test: buy 50 Stars for @bohd4nx.
|
||||
|
||||
Requires cookies.json and a valid .env (API_KEY + SEED).
|
||||
Auto-skipped when cookies are unavailable (e.g. local runs without secrets).
|
||||
Auto-skipped when cookies or config are unavailable (e.g. CI without secrets).
|
||||
"""
|
||||
|
||||
from app.methods.stars import buy_stars
|
||||
|
||||
|
||||
async def test_buy_stars_e2e(cookies):
|
||||
async def test_buy_stars_e2e(cookies, tests_config):
|
||||
result = await buy_stars("@bohd4nx", 50)
|
||||
assert result["success"] is True, result.get("error")
|
||||
assert result["data"]["transaction_id"]
|
||||
|
||||
+10
-1
@@ -1,13 +1,22 @@
|
||||
import pytest
|
||||
|
||||
from app.core.config import config
|
||||
from app.core.cookies import load_cookies
|
||||
from app.core.exceptions import CookiesError
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cookies():
|
||||
"""Load Fragment cookies, skip the test if they are unavailable."""
|
||||
"""Load Fragment cookies; skip the test if they are unavailable."""
|
||||
try:
|
||||
return load_cookies()
|
||||
except CookiesError as exc:
|
||||
pytest.skip(f"Cookies unavailable — {exc}")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tests_config():
|
||||
"""Require a fully configured environment (SEED + API_KEY); skip otherwise."""
|
||||
if config is None:
|
||||
pytest.skip("Config unavailable — set SEED and API_KEY in .env or environment")
|
||||
return config
|
||||
|
||||
Reference in New Issue
Block a user