def test_ensure_running_when_running(self): module = MagicMock() module.fail_json = MagicMock() k = DOKubernetes(module) k.end_time = 20 k.wait_timeout = 1 k.get_by_id = MagicMock() cluster = {"kubernetes_cluster": {"status": {"state": "running"}}} k.get_by_id.return_value = cluster time = MagicMock() time.time = MagicMock() time.time.return_value = 10 time.sleep = MagicMock() self.assertEqual(k.ensure_running(), cluster)
def test_ensure_running_when_not_running(self): module = MagicMock() module.fail_json = MagicMock() k = DOKubernetes(module) k.end_time = 20 k.wait_timeout = -100 k.get_by_id = MagicMock() cluster = {"kubernetes_cluster": {"status": {"state": "stopped"}}} k.get_by_id.return_value = cluster time = MagicMock() time.time = MagicMock() time.time.return_value = 20 time.sleep = MagicMock() # module.fail_json.assert_called() assert True