Skip to content
Permalink
Browse files

tests: add tests for `_process_droplets`

  • Loading branch information...
etienne-napoleone committed Dec 20, 2018
1 parent 759d53d commit b72583373a69eeabf9e3e6dfba535b0415b30014
Showing with 37 additions and 0 deletions.
  1. +37 −0 tests/test_goutte.py
@@ -9,6 +9,43 @@ def test_version():
assert __version__ == '1.0.0'


def test_process_droplets(caplog, monkeypatch):
def get_droplets(names):
return [mock.Droplet(name='testdroplet')]
conf = {'retention': 1, 'droplets': {'names': ['testdroplet']}}
monkeypatch.setattr(main, '_get_droplets', get_droplets)
monkeypatch.setattr(main, '_prune_droplet_snapshots', mock.nothing)
monkeypatch.setattr(main, '_snapshot_droplet', mock.nothing)
with caplog.at_level('INFO'):
main._process_droplets(conf=conf, only=None)
assert len(caplog.records) == 0


def test_process_droplets_no_vol(caplog, monkeypatch):
def get_droplets(names):
return []
conf = {'retention': 1, 'droplets': {'names': ['testdroplet']}}
monkeypatch.setattr(main, '_get_droplets', get_droplets)
monkeypatch.setattr(main, '_prune_droplet_snapshots', mock.nothing)
monkeypatch.setattr(main, '_snapshot_droplet', mock.nothing)
with caplog.at_level('INFO'):
main._process_droplets(conf=conf, only=None)
assert len(caplog.records) == 1
assert caplog.records[0].levelname == 'WARNING'


def test_process_droplets_key_error(caplog, monkeypatch):
def get_droplets(names):
return [mock.Droplet(name='testdroplet')]
conf = {'retention': 1, 'droplets': {'names': ['testdroplet2']}}
monkeypatch.setattr(main, '_get_droplets', get_droplets)
monkeypatch.setattr(main, '_prune_droplet_snapshots', mock.nothing)
monkeypatch.setattr(main, '_snapshot_droplet', mock.nothing)
with caplog.at_level('INFO'):
main._process_droplets(conf=conf, only=None)
assert len(caplog.records) == 0


def test_process_volumes(caplog, monkeypatch):
def get_volumes(names):
return [mock.Volume(name='testvol')]

0 comments on commit b725833

Please sign in to comment.
You can’t perform that action at this time.