def __init__(self, chainspec, chainname): self.actionchain = actionchain.ActionChain(**chainspec) self.chainname = chainname if not self.actionchain.default: default = self._get_default(self.actionchain) self.actionchain.default = default LOG.debug('Using %s as default for %s.', self.actionchain.default, self.chainname) if not self.actionchain.default: raise Exception('Failed to find default node in %s.' % (self.chainname)) self.vars = {}
def __init__(self, chainspec, chainname): self.actionchain = actionchain.ActionChain(**chainspec) self.chainname = chainname if not self.actionchain.default: default = self._get_default(self.actionchain) self.actionchain.default = default LOG.debug('Using %s as default for %s.', self.actionchain.default, self.chainname) if not self.actionchain.default: raise Exception('Failed to find default node in %s.' % (self.chainname)) # finalize the vars and save them around to be used at execution time. self.vars = self._get_rendered_vars( self.actionchain.vars) if self.actionchain.vars else {}
def test_actionchain_schema_invalid(self): with self.assertRaises(ValidationError): actionchain.ActionChain(**MALFORMED_CHAIN)
def test_actionchain_with_publish(self): chain = actionchain.ActionChain(**CHAIN_WITH_PUBLISH) self.assertEqual(len(chain.chain), len(CHAIN_WITH_PUBLISH["chain"])) self.assertEqual(len(chain.chain[0].publish), len(CHAIN_WITH_PUBLISH["chain"][0]["publish"]))
def test_actionchain_with_vars(self): chain = actionchain.ActionChain(**CHAIN_WITH_VARS) self.assertEqual(len(chain.chain), len(CHAIN_WITH_VARS["chain"])) self.assertEqual(len(chain.vars), len(CHAIN_WITH_VARS["vars"]))
def test_actionchain_no_default(self): chain = actionchain.ActionChain(**NO_DEFAULT_CHAIN) self.assertEqual(len(chain.chain), len(NO_DEFAULT_CHAIN["chain"])) self.assertEqual(chain.default, None)
def test_actionchain_schema_valid(self): chain = actionchain.ActionChain(**CHAIN_1) self.assertEqual(len(chain.chain), len(CHAIN_1["chain"])) self.assertEqual(chain.default, CHAIN_1["default"])
def test_actionchain_with_publish(self): chain = actionchain.ActionChain(**CHAIN_WITH_PUBLISH) self.assertEquals(len(chain.chain), len(CHAIN_WITH_PUBLISH['chain'])) self.assertEquals(len(chain.chain[0].publish), len(CHAIN_WITH_PUBLISH['chain'][0]['publish']))
def test_actionchain_with_vars(self): chain = actionchain.ActionChain(**CHAIN_WITH_VARS) self.assertEquals(len(chain.chain), len(CHAIN_WITH_VARS['chain'])) self.assertEquals(len(chain.vars), len(CHAIN_WITH_VARS['vars']))
def test_actionchain_schema_valid(self): chain = actionchain.ActionChain(**CHAIN_1) self.assertEquals(len(chain.chain), len(CHAIN_1['chain'])) self.assertEquals(chain.default, CHAIN_1['default'])