Skip to content

Commit 1ba92bb

Browse files
committed
Test fixes
1 parent 172cd7b commit 1ba92bb

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

.github/workflows/testing.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ jobs:
2727
run: |
2828
. ~/venv/bin/activate
2929
python -m pytest test
30+
- name: Setup Ganga Config
31+
run: echo "[GangaDefaults]\ncreate_config = no" > ~/.gangarc
32+
33+
- name: Run Tests
34+
run: |
35+
GANGA_DEBUG=1 timeout 60s python -m unittest test/test_submit_jobs.py
36+

test/test_submit_jobs.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,45 @@
11
import unittest
22
import subprocess
3-
import os
3+
import time
44

55
submit_script = "/home/uverma/Documents/code/My_Ganga/my_code/submit_jobs.py"
66

77

88
class TestSubmitJobs(unittest.TestCase):
99

10-
def test_submit_jobs(self):
10+
def setUp(self):
11+
"""Ensure a clean Ganga job list before running tests."""
12+
subprocess.run(["ganga", "-e", "jobs.clear()"], capture_output=True, text=True)
1113

14+
def test_submit_jobs(self):
15+
1216
"""Test if submit_jobs.py successfully creates and runs Ganga jobs."""
1317

14-
1518
# Run the job submission script
16-
result = subprocess.run(["ganga", submit_script], capture_output=True, text=True)
19+
result = subprocess.run(
20+
["ganga", submit_script],
21+
capture_output=True, text=True
22+
)
1723

18-
# Print output or error of jobs
1924
print("Ganga Output:", result.stdout)
2025
print("Ganga Error:", result.stderr)
2126

22-
# Test will pass if "total occurrences of 'it'" occurs in the output
27+
# Ensure the job was submitted
28+
self.assertIn("submitted", result.stdout.lower(), "Job was not submitted.")
29+
30+
# Wait for jobs to complete
31+
time.sleep(30)
32+
33+
# Check job list
34+
ganga_jobs = subprocess.run(
35+
["ganga", "-e", "jobs"],
36+
capture_output=True, text=True
37+
)
38+
39+
print("🔹 Jobs Output:", ganga_jobs.stdout)
40+
print("🔹 Jobs Error:", ganga_jobs.stderr)
41+
42+
# Verify if expected output exists
2343
self.assertIn("total occurrences of 'it'", result.stdout.lower(), "Expected output not found.")
2444

2545
if __name__ == "__main__":

0 commit comments

Comments
 (0)