Skip to content

Commit 88093f6

Browse files
committed
test_app_generator tests passing
1 parent 72d7ae3 commit 88093f6

1 file changed

Lines changed: 18 additions & 26 deletions

File tree

‎tests/test_app_generator.py‎

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import time
1616
import datetime
1717
import signal
18+
import socket
19+
1820
from pathlib import Path
1921

2022

@@ -41,8 +43,8 @@ def setUp(self):
4143

4244
def tearDown(self):
4345
"""Clean up test environment"""
44-
# if self.test_dir.exists():
45-
# shutil.rmtree(self.test_dir)
46+
if self.test_dir.exists():
47+
shutil.rmtree(self.test_dir)
4648

4749
def test_generate_py_app(self):
4850
"""Test generating py app from test-gen.yaml and verify structure"""
@@ -256,9 +258,9 @@ def test_generate_both_apps(self):
256258

257259
# Create .env file required by server.sh
258260
env_file = py_dir / ".env"
259-
with open(env_file, 'w') as f:
260-
f.write("# Environment variables for test server\n")
261-
f.write("DEBUG=1\n")
261+
# with open(env_file, 'w') as f:
262+
# f.write("# Environment variables for test server\n")
263+
# f.write("DEBUG=1\n")
262264

263265
self.assertTrue(env_file.exists(), "Expected .env file not found in py directory")
264266

@@ -298,9 +300,9 @@ def test_generate_both_apps(self):
298300
raise RuntimeError(f"Server failed to start. stdout: {stdout_content}, stderr: {stderr_content}")
299301

300302
# Try to verify server is responding by attempting a simple connection
301-
import socket
303+
302304
server_responding = False
303-
for attempt in range(10): # Try for up to 5 seconds
305+
for _ in range(10): # Try for up to 5 seconds
304306
try:
305307
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
306308
sock.settimeout(1)
@@ -347,29 +349,19 @@ def test_generate_both_apps(self):
347349
# Don't fail the test just because of timeout - server might be working
348350
print("Test timeout - this might indicate server deadlock issue is resolved")
349351

350-
# Check that Python tests can at least be discovered and run without hanging
351-
# The main goal is to ensure server doesn't deadlock
352-
if python_test_result is not None:
353-
# Tests ran to completion - good sign
354-
print("Python tests completed (may have passed or failed, but didn't hang)")
355-
else:
356-
print("Python tests may have timed out, but server process management worked")
352+
if python_test_result.returncode != 0:
353+
raise RuntimeError(f"Python tests failed: {python_test_result.stderr}")
357354

358355
# Run browser1 tests: npm run test in browser1 directory
359-
# print(f"Running Browser1 tests with command: npm run test")
360-
# browser_test_result = subprocess.run([
361-
# "npm", "run", "test"
362-
# ], capture_output=True, text=True, cwd=str(browser1_dir), timeout=60, env=dict(os.environ, VIRTUAL_ENV=venv_dir.as_posix(), PATH=f"{venv_dir / 'bin'}:{os.environ.get('PATH', '')}"))
356+
print(f"Running Browser1 tests with command: npm run test")
357+
browser_test_result = subprocess.run([
358+
"npm", "run", "test"
359+
], capture_output=True, text=True, cwd=str(browser1_dir), timeout=60, env=dict(os.environ, VIRTUAL_ENV=venv_dir.as_posix(), PATH=f"{venv_dir / 'bin'}:{os.environ.get('PATH', '')}"))
363360

364-
# print(browser_test_result.stdout + browser_test_result.stderr)
361+
print(browser_test_result.stdout + browser_test_result.stderr)
365362

366-
# # Check that browser tests can be discovered and run
367-
# # Don't fail if tests fail, just ensure they can be discovered
368-
# self.assertTrue(
369-
# "test" in browser_test_result.stderr.lower() + browser_test_result.stdout.lower() or
370-
# "playwright" in browser_test_result.stderr.lower() + browser_test_result.stdout.lower(),
371-
# f"Browser tests should be discoverable. Output: {browser_test_result.stdout} {browser_test_result.stderr}"
372-
# )
363+
if browser_test_result.returncode != 0:
364+
raise RuntimeError(f"Browser1 tests failed: {browser_test_result.stderr}")
373365

374366
print("Terminating server process")
375367
if server_process:

0 commit comments

Comments
 (0)