Skip to content

Commit

Permalink
Static tests: Move the dir list parsing to StaticServer
Browse files Browse the repository at this point in the history
This way all of the directory lookups are done in a single place.

Signed-off-by: Jussi Kukkonen <[email protected]>
  • Loading branch information
jku committed Aug 20, 2024
1 parent 56c2327 commit dcfcd76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 9 additions & 0 deletions tuf_conformance/simulator_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ class StaticServer(ThreadingHTTPServer):

data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static_data")

@classmethod
def static_test_names(cls) -> list[str]:
"""Return list of static test names (subdirectories of 'static_data/')."""
static_tests = []
for static_dir in os.listdir(StaticServer.data_dir):
if os.path.isdir(os.path.join(StaticServer.data_dir, static_dir)):
static_tests.append(static_dir)
return static_tests

def __init__(self) -> None:
class _StaticReqHandler(BaseHTTPRequestHandler):
def do_GET(self) -> None: # noqa: N802
Expand Down
9 changes: 1 addition & 8 deletions tuf_conformance/test_static_repositories.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import os

import pytest

from tuf_conformance.client_runner import ClientRunner
from tuf_conformance.simulator_server import StaticServer

static_repos = []
for static_dir in os.listdir(StaticServer.data_dir):
if os.path.isdir(os.path.join(StaticServer.data_dir, static_dir)):
static_repos.append(static_dir)


@pytest.mark.parametrize("static_repo", static_repos)
@pytest.mark.parametrize("static_repo", StaticServer.static_test_names())
def test_static_repository(
static_client: ClientRunner, static_server: StaticServer, static_repo: str
) -> None:
Expand Down

0 comments on commit dcfcd76

Please sign in to comment.