Skip to content

Commit 271e005

Browse files
committed
Coverage improvements and CI fixes
1 parent b59051b commit 271e005

7 files changed

Lines changed: 21 additions & 0 deletions

File tree

run_manual_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Manual test script for AST test extraction."""
2+
13
import libcst as cst
24
from openapi_client.tests.parse import ASTTestExtractor
35
from openapi_client.models import OpenAPI

scripts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Scripts package."""

scripts/build_wasm.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
"""Build script for WebAssembly bundle."""
2+
13
import os
24
import subprocess
35

46

57
def main():
8+
"""Build WASI output or fallback to zip bundle."""
69
os.makedirs("bin", exist_ok=True)
710
wasm_out = os.path.join("bin", "cdd-python-all.wasm")
811

scripts/doc_coverage.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
"""Module for calculating docstring coverage."""
2+
13
import ast
24
import os
35

46

57
def calculate_doc_coverage(directory):
8+
"""Calculate the percentage of functions, classes, and modules with docstrings."""
69
total = 0
710
with_docs = 0
811

scripts/run_generated_server_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Run generated server tests."""
2+
13
import os
24
import sys
35
import shutil
@@ -8,13 +10,15 @@
810

911

1012
def find_free_port():
13+
"""Find a free port on localhost."""
1114
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
1215
s.bind(("", 0))
1316
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
1417
return s.getsockname()[1]
1518

1619

1720
def main():
21+
"""Main execution of the server test."""
1822
test_harness_dir = os.environ.get(
1923
"TEST_HARNESS_DIR", os.path.expanduser("~/repos/cdd-openapi-test-harness")
2024
)

scripts/run_petstore_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Run tests against the Petstore server."""
2+
13
import os
24
import sys
35
import shutil
@@ -7,13 +9,15 @@
79

810

911
def find_free_port():
12+
"""Find a free port on localhost."""
1013
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
1114
s.bind(("", 0))
1215
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
1316
return s.getsockname()[1]
1417

1518

1619
def main():
20+
"""Main execution of the petstore test."""
1721
test_harness_dir = os.environ.get(
1822
"TEST_HARNESS_DIR", os.path.expanduser("~/repos/cdd-openapi-test-harness")
1923
)

scripts/update_badges.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Update test and doc coverage badges in README.md."""
2+
13
#!/usr/bin/env python3
24
import os
35
import re
@@ -6,6 +8,7 @@
68

79

810
def get_color(pct):
11+
"""Return a color for a given coverage percentage."""
912
if pct >= 90:
1013
return "brightgreen"
1114
if pct >= 80:
@@ -20,6 +23,7 @@ def get_color(pct):
2023

2124

2225
def main():
26+
"""Run tests, calculate coverage, and update badges in README.md."""
2327
readme_path = os.path.join(os.path.dirname(__file__), "..", "README.md")
2428
if not os.path.exists(readme_path):
2529
return

0 commit comments

Comments
 (0)