def test_apply(self, apply_items, NodeLock, ApplyResult): repo = Repository() n = Node("node1", {}) repo.add_node(n) result = MagicMock() ApplyResult.return_value = result NodeLock.__enter__ = lambda x: x NodeLock.__exit__ = lambda x: x self.assertEqual(n.apply(), result) self.assertEqual(apply_items.call_count, 1) ApplyResult.assert_called_once()
def test_run_stdout(self): n = Node('localhost', {}) r = n.run("echo -n 47") self.assertEqual(r.stdout, "47")
def test_password(self): n = Node("node1", {}) self.assertIsNone(n.password) n.password = "******" self.assertEqual(n.password, "foo")