mirror of
https://github.com/bohd4nx/FragmentAPI.git
synced 2026-07-25 06:14:29 +00:00
d2d046a2b9
- Rename app/ → fragmentapi/ for proper package naming - Add FragmentClient class with gift_premium, gift_stars, topup_ton methods - Restructure core/ → types/ (exceptions, results, constants) - Merge utils/hash.py into utils/client.py - Replace _version.py with importlib.metadata - Add input validation with min/max bounds - Add unit tests: decode, client init/cookies - Rename 002_test_hash → 003_test_hash - Clean up pyproject.toml: pin deps, production classifiers
18 lines
576 B
Python
18 lines
576 B
Python
"""Tests for get_fragment_hash() — fetches a valid lowercase hex hash
|
|
from the fragment.com/stars/buy page source."""
|
|
|
|
import re
|
|
|
|
import pytest
|
|
|
|
from fragmentapi.types import BASE_HEADERS, STARS_PAGE
|
|
from fragmentapi.utils import get_fragment_hash
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_hash_is_valid_hex(cookies: dict) -> None:
|
|
result = await get_fragment_hash(cookies, BASE_HEADERS, STARS_PAGE)
|
|
assert isinstance(result, str)
|
|
assert len(result) >= 10, f"hash too short: {result!r}"
|
|
assert re.fullmatch(r"[a-f0-9]+", result), f"not a hex string: {result!r}"
|