Replaced start up tests.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
45
release_tests/test_startup.py
Normal file
45
release_tests/test_startup.py
Normal 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)
|
||||
Reference in New Issue
Block a user