morethantext/release_tests/support/test_translate.py
Jeff Baskin f6f8f0f205
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Beginning setup of new release testing.
2025-06-15 09:46:50 -04:00

34 lines
1.2 KiB
Python

"""Confirms translate moxcking is working."""
from unittest import IsolatedAsyncioTestCase
from uuid import uuid4
from aiohttp import ClientSession
from release_tests.support import ADDR
from release_tests.support.translate import Translate
class TranslateTC(IsolatedAsyncioTestCase):
"""Confirms the translate mocking is working."""
async def test_create_translater_server(self):
"""something"""
trans = Translate()
await trans.start()
async with ClientSession() as session:
async with session.get(f"http://{ADDR}:{trans.port}/") as resp:
text = await resp.text()
self.assertEqual(resp.status, 200, text)
async def test_url_reponses(self):
"""created url reponse the mocks"""
url = f"/{uuid4()}"
replies = [str(uuid4()), str(uuid4())]
trans = Translate(url=url, replies=replies)
await trans.start()
async with ClientSession() as session:
for reply in replies:
async with session.get(f"http://{ADDR}:{trans.port}{url}") as resp:
text = await resp.text()
self.assertEqual(resp.status, 200, text)
self.assertEqual(text, reply)