"""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() url = f"http://{ADDR}:{trans.port}" async with ClientSession() as session: async with session.get(url) as resp: text = await resp.text() self.assertEqual(resp.status, 200, text) self.assertEqual(trans.baseurl, url) 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)