morethantext/release_tests/test_startup.py
Jeff Baskin e555acfdb4
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Replaced start up tests.
2025-06-22 17:04:37 -04:00

46 lines
1.6 KiB
Python

"""Test release startup conditions."""
from socket import gethostbyname, gethostname
from unittest import IsolatedAsyncioTestCase
from aiohttp import ClientSession
from release_tests.support import get_port
from release_tests.support.cluster import Cluster
LOCALHOST = "127.0.0.1"
DEFAULT_PORT = 3000
class MTTStartUp(IsolatedAsyncioTestCase):
"""Tests the server startup conditions."""
async def asyncSetUp(self):
"""Setup for server testing."""
self.cluster = Cluster()
self.addAsyncCleanup(self.cluster.cleanup)
async def test_default_startup(self):
"""Does the server start up on localhost:3000"""
url = f"http://{LOCALHOST}:{DEFAULT_PORT}"
await self.cluster.start_a_server()
async with ClientSession() as session:
async with session.get(url) as resp:
self.assertEqual(resp.status, 200)
async def test_address(self):
"""Can the address be set?"""
addr = gethostbyname(gethostname())
url = f"http://{addr}:{DEFAULT_PORT}"
await self.cluster.start_a_server("-a", addr)
async with ClientSession() as session:
async with session.get(url) as resp:
self.assertEqual(resp.status, 200)
async def test_port(self):
"""Can the port be changed?"""
port = get_port()
url = f"http://{LOCALHOST}:{port}"
await self.cluster.start_a_server("-p", port)
async with ClientSession() as session:
async with session.get(url) as resp:
self.assertEqual(resp.status, 200)