def test_resume(self, pp, starts, resumes, plus, skips, exception=None, msg=None): pp.tree = ProcTree() for node in ProcTree.NODES.values(): node.proc.resume = '' pp.start(starts) helpers.log2sys() skip = 'skip+' if plus else 'skip' resume = 'resume+' if plus else 'resume' if exception: self.assertRaisesRegex(exception, msg, pp._resume, *resumes, plus=plus) else: pp._resume(*resumes, plus=plus) for r in resumes: self.assertEqual(r.resume, resume) for s in skips: self.assertEqual(s.resume, skip)
def testResume1(self, pp, start, procs): pp.tree = ProcTree() pp.start(start).resume(procs) if not procs: for node in ProcTree.NODES.values(): self.assertEqual(node.proc.resume, '') else: for node in ProcTree.NODES.values(): self.assertIn(node.proc.resume, ['', 'skip', 'resume'])
def testResume2(self, pp, start, procs): pp.tree = ProcTree() pp.start(start).resume2(procs) if not procs: for proc in ProcTree.NODES.keys(): if not proc.id.startswith('pResume2'): continue self.assertEqual(proc.resume, '') else: for proc in ProcTree.NODES.keys(): if not proc.id.startswith('pResume2'): continue self.assertIn(proc.resume, ['', 'skip+', 'resume+'])
def test_buildprops(tmpdir): from pyppl import ProcTree p9 = Proc() p91 = Proc(id='p9') ProcTree.register(p9) ProcTree.register(p91) with pytest.raises(ProcTreeProcExists): p91._buildProps() p9.id = 'p89' p9.template = TemplateLiquid p9.ppldir = Path(tmpdir / 'test_buildprops') p9.rc = '0,1' p9.workdir = tmpdir / 'p8' p9.exdir = tmpdir / 'p8.exdir' p9.echo = True p9.expect = 'ls' p9.expart = 'outfile' p9._buildProps() assert p9.template is TemplateLiquid assert p9.rc == [0, 1] assert p9.workdir.exists() assert fs.exists(p9.exdir) assert p9.echo == dict(jobs=[0], type=dict(stderr=None, stdout=None)) assert p9.expect.render() == 'ls' assert len(p9.expart) == 1 assert p9.expart[0].render() == 'outfile' p9.template = None p9.rc = 1 p9.sets.remove('workdir') p9.props.workdir = None p9.echo = False p9._buildProps() assert p9.template is TemplateLiquid assert p9.rc == [1] assert Path( p9.workdir) == Path(p9.ppldir) / ('PyPPL.p89.notag.%s' % p9.suffix) assert p9.echo == dict(jobs=[], type=dict(stderr=None, stdout=None)) p9.template = 'liquid' p9.rc = [0, 1, 2] p9.echo = 'stderr' p9._buildProps() assert p9.template is TemplateLiquid assert p9.rc == [0, 1, 2] assert p9.echo == dict(jobs=[0], type=dict(stderr=None)) fs.remove(p9.workdir) p9.resume = 'resume' with pytest.raises(ProcAttributeError): p9._buildProps() p9.echo = dict(type='stderr') p9.resume = '' p9._buildProps() assert p9.echo == dict(jobs=[0], type=dict(stderr=None)) p9.echo = dict(jobs='0,1') p9._buildProps() assert p9.echo == dict(jobs=[0, 1], type=dict(stderr=None, stdout=None)) p9.echo = dict(jobs='0,1', type=dict(all=r'^log')) p9._buildProps() assert p9.echo == dict(jobs=[0, 1], type=dict(stderr=r'^log', stdout=r'^log'))