hello
", + media: list[dict] | None = None, locked=False): + gallery = "" + if media is not None: + gallery = ( + f'' + ) + lock = ' for-locked_content' if locked else "" + return ( + f'text only
"))) + post["_base"] = "https://subscribestar.adult" + assert client.extract_media(post, {}) == [] + assert "text only" in post["attributes"]["content"] + + +# -- client: gating + record key -------------------------------------------- + +def test_post_is_gated(): + client = SubscribeStarClient(None) + [open_post] = client._parse_posts(_feed_page(_post_html("1", media=[]))) + [locked] = client._parse_posts(_feed_page(_post_html("2", locked=True))) + assert client.post_is_gated(open_post) is False + assert client.post_is_gated(locked) is True + + +def test_post_record_key(): + assert SubscribeStarClient.post_record_key({"id": "55"}) == ("post:55", "55") + assert SubscribeStarClient.post_record_key({}) is None + + +# -- downloader -------------------------------------------------------------- + +class _FakeResponse: + def __init__(self, payload=_PNG_BYTES, status_code=200): + self._payload = payload + self.status_code = status_code + self.headers: dict = {} + + def raise_for_status(self): + if self.status_code >= 400: + raise requests.HTTPError(f"HTTP {self.status_code}") + + def iter_content(self, chunk_size=65536): + for i in range(0, len(self._payload), chunk_size): + yield self._payload[i:i + chunk_size] + + +class _FakeSession: + def __init__(self): + self.calls: list[str] = [] + + def get(self, url, stream=False, timeout=None, headers=None): + self.calls.append(url) + return _FakeResponse() + + +def _post(post_id="111", date="May 01, 2026 12:00 pm"): + return { + "id": post_id, + "attributes": { + "title": "", + "content": "