Esempio n. 1
0
def test_delete_namespace(caplog):
    caplog.set_level(logging.INFO)
    mock_api = MagicMock()
    foo_ns = Namespace(mock_api, {'metadata': {'name': 'foo'}})
    delete(foo_ns, dry_run=False)
    assert 'Deleting Namespace foo..' in caplog.messages
    mock_api.delete.assert_called_once()
Esempio n. 2
0
def test_delete_namespace(caplog):
    caplog.set_level(logging.INFO)
    mock_api = MagicMock()
    foo_ns = Namespace(mock_api, {"metadata": {"name": "foo"}})
    delete(foo_ns, wait_after_delete=0, dry_run=False)
    assert "Deleting Namespace foo.." in caplog.messages
    mock_api.delete.assert_called_once()
Esempio n. 3
0
def test_wait_after_delete(monkeypatch):
    mock_sleep = MagicMock()
    monkeypatch.setattr("time.sleep", mock_sleep)
    mock_api = MagicMock()
    foo_ns = Namespace(mock_api, {"metadata": {"name": "foo"}})

    delete(foo_ns, wait_after_delete=123, dry_run=True)
    assert not mock_sleep.called

    delete(foo_ns, wait_after_delete=123, dry_run=False)
    mock_sleep.assert_called_once_with(123)