Replaced start up tests.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s

This commit is contained in:
2025-06-22 17:04:37 -04:00
parent e69dbf58fa
commit e555acfdb4
6 changed files with 121 additions and 16 deletions

View File

@@ -0,0 +1,45 @@
"""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)