def test_21_stdio(self): """Test getter/setter methods for stdio properties""" jobspec = Jobspec.from_yaml_stream(self.basic_jobspec) for stream in ("stderr", "stdout", "stdin"): self.assertEqual(getattr(jobspec, stream), None) for path in ("foo.txt", "bar.md", "foo.json"): setattr(jobspec, stream, path) self.assertEqual(getattr(jobspec, stream), path)
def test_09_valid_duration(self): """Test setting Jobspec duration to various valid values""" jobspec = Jobspec.from_yaml_stream(self.basic_jobspec) for duration in (100, 100.5): delta = datetime.timedelta(seconds=duration) for x in [duration, delta, "{}s".format(duration)]: jobspec.duration = x # duration setter converts value to a float self.assertEqual(jobspec.duration, float(duration))
def test_10_invalid_duration(self): """Test setting Jobspec duration to various invalid values and types""" jobspec = Jobspec.from_yaml_stream(self.basic_jobspec) for duration in (-100, -100.5, datetime.timedelta(seconds=-5), "10h5m"): with self.assertRaises(ValueError): jobspec.duration = duration for duration in ([], {}): with self.assertRaises(TypeError): jobspec.duration = duration
def test_12_environment(self): jobspec = Jobspec.from_yaml_stream(self.basic_jobspec) new_env = {"HOME": "foo", "foo": "bar"} jobspec.environment = new_env self.assertEqual(jobspec.environment, new_env)
def test_08_jobspec_submit(self): jobspec = Jobspec.from_yaml_stream(self.basic_jobspec) jobid = job.submit(self.fh, jobspec) self.assertGreater(jobid, 0)