Skip to content

Commit 172cd7b

Browse files
committed
Test written
Test for Task 1 and Task 2 written
1 parent 099bc68 commit 172cd7b

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import subprocess
3+
4+
interfacing_ganga_path = "/home/uverma/Documents/code/My_Ganga/my_code/Interfacing_Ganga/create_pi_job.py"
5+
6+
7+
class TestInterfacingGangaExec(unittest.TestCase):
8+
9+
def test_ganga_job_submission(self):
10+
11+
"""Test if the create_pi_job is attempted in Ganga."""
12+
13+
# Run the create_pi_job script
14+
result = subprocess.run(["ganga", interfacing_ganga_path], capture_output=True, text=True)
15+
16+
# Check Ganga job list
17+
ganga_check = subprocess.run(["ganga", "--batch", "jobs"], capture_output=True, text=True)
18+
ganga_output = ganga_check.stdout.lower()
19+
20+
# Test will pass if command 'jobs' produces any output.
21+
self.assertTrue("job" in ganga_output or "submitted" in result.stdout.lower(),
22+
"Ganga job submission was not attempted.")
23+
24+
if __name__ == "__main__":
25+
unittest.main()

test/test_submit_jobs.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import unittest
2+
import subprocess
3+
import os
4+
5+
submit_script = "/home/uverma/Documents/code/My_Ganga/my_code/submit_jobs.py"
6+
7+
8+
class TestSubmitJobs(unittest.TestCase):
9+
10+
def test_submit_jobs(self):
11+
12+
"""Test if submit_jobs.py successfully creates and runs Ganga jobs."""
13+
14+
15+
# Run the job submission script
16+
result = subprocess.run(["ganga", submit_script], capture_output=True, text=True)
17+
18+
# Print output or error of jobs
19+
print("Ganga Output:", result.stdout)
20+
print("Ganga Error:", result.stderr)
21+
22+
# Test will pass if "total occurrences of 'it'" occurs in the output
23+
self.assertIn("total occurrences of 'it'", result.stdout.lower(), "Expected output not found.")
24+
25+
if __name__ == "__main__":
26+
unittest.main()

0 commit comments

Comments
 (0)