Belle II Software  release-05-01-25
TestJob Class Reference
Inheritance diagram for TestJob:
Collaboration diagram for TestJob:

Public Member Functions

def setUp (self)
 
def test_dict_setup (self)
 
def test_job_json_serialise (self)
 
def test_status (self)
 
def test_path_object_conversion (self)
 
def test_subjob_splitting (self)
 
def test_input_sandbox_copy (self)
 
def tearDown (self)
 

Public Attributes

 job1
 
 job2_dict
 
 job2
 
 maxDiff
 

Detailed Description

UnitTest for the `caf.backends.Job` class

Definition at line 27 of file test_backends.py.

Member Function Documentation

◆ setUp()

def setUp (   self)
Create useful objects for each test and the teardown

Definition at line 32 of file test_backends.py.

32  def setUp(self):
33  """
34  Create useful objects for each test and the teardown
35  """
36  # We will deliberately use strings and not Path objects for the job attributes so that we can later
37  # check that they are converted to Paths by the class itself.
38  name1 = 'TestJob1'
39  job1 = Job(name1) # Set up this one manually setting attributes
40  job1.working_dir = Path(test_dir, job1.name, "working_dir").absolute().as_posix()
41  job1.output_dir = Path(test_dir, job1.name, "output_dir").absolute().as_posix()
42  job1.cmd = ["bash", test_script.name]
43  job1.input_sandbox_files = [test_script.as_posix()]
44  self.job1 = job1
45 
46  name2 = 'TestJob2'
47  job_dict = {}
48  job_dict["name"] = name2
49  job_dict["working_dir"] = Path(test_dir, name2, "working_dir").as_posix()
50  job_dict["output_dir"] = Path(test_dir, name2, "output_dir").as_posix()
51  job_dict["output_patterns"] = []
52  job_dict["cmd"] = ["bash", test_script.name]
53  job_dict["args"] = []
54  job_dict["input_sandbox_files"] = [test_script.as_posix()]
55  job_dict["input_files"] = []
56  job_dict["setup_cmds"] = []
57  job_dict["backend_args"] = {}
58  job_dict["subjobs"] = [{"id": i, "input_files": [], "args": [str(i)]} for i in range(4)]
59  self.job2_dict = job_dict
60  self.job2 = Job(name2, job_dict=job_dict) # Set up this one from a dictionary
61 
62  # Create a directory just in case we need it for each test so that we can delete everything easily at the end
63  test_dir.mkdir(parents=True, exist_ok=False)
64 

◆ tearDown()

def tearDown (   self)
Removes files/directories that were created during these tests

Definition at line 194 of file test_backends.py.

◆ test_input_sandbox_copy()

def test_input_sandbox_copy (   self)
Does the copy of files/directories for the input sandbox work correctly?

Definition at line 166 of file test_backends.py.

◆ test_path_object_conversion()

def test_path_object_conversion (   self)
Make sure that the two ways of setting up Job objects correctly converted attributes to be Paths instead of strings.

Definition at line 95 of file test_backends.py.

◆ test_status()

def test_status (   self)
The Jobs haven't been run so they should be in the 'init' status.
They also shouldn't throw exceptions due to missing result objects.

Definition at line 79 of file test_backends.py.

◆ test_subjob_splitting()

def test_subjob_splitting (   self)
Test the creation of SubJobs and assignment of input data files via splitter classes.

Definition at line 117 of file test_backends.py.


The documentation for this class was generated from the following file: