Skip to content
Permalink
Browse files

tests: add tests for `_get_droplets`

  • Loading branch information...
etienne-napoleone committed Dec 20, 2018
1 parent 961c5ef commit 8835fdb7da947c268aad947b8e3164a74dcc13a3
Showing with 22 additions and 0 deletions.
  1. +8 −0 tests/mock.py
  2. +14 −0 tests/test_goutte.py
@@ -35,6 +35,9 @@ def __init__(self, name=None, snapshot_ids=None):
self.name = name
self.snapshot_ids = snapshot_ids

def take_snapshot(self, name):
pass


class Manager:
def __init__(self, token=None):
@@ -44,3 +47,8 @@ def get_all_volumes(self):
return [
Volume(name='testvol')
]

def get_all_droplets(self):
return [
Droplet(name='testdroplet')
]
@@ -9,6 +9,20 @@ def test_version():
assert __version__ == '1.0.0'


def test_get_droplets(monkeypatch):
monkeypatch.setattr(digitalocean, 'Manager', mock.Manager)
assert 'testdroplet' in main._get_droplets(['testdroplet'])[0].name


def test_snapshot_droplet(caplog):
droplet = mock.Droplet(name='testdroplet')
with caplog.at_level('INFO'):
main._snapshot_droplet(droplet)
assert len(caplog.records) == 1
assert caplog.records[0].levelname == 'INFO'
assert 'testdroplet' in caplog.records[0].message


def test_prune_droplet_snapshots(caplog, monkeypatch):
monkeypatch.setattr(digitalocean, 'Snapshot', mock.Snapshot)
droplet = mock.Droplet(name='testdroplet', snapshot_ids=['3', '2', '1'])

0 comments on commit 8835fdb

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