Skip to content
Permalink
Browse files

tests: add tests for `entrypoint`

  • Loading branch information...
etienne-napoleone committed Dec 20, 2018
1 parent 211ea16 commit badac8211cfc6af8eb72a8e906b9d3410cb490b8
Showing with 66 additions and 0 deletions.
  1. +66 −0 tests/test_goutte.py
@@ -1,3 +1,4 @@
from click.testing import CliRunner
import digitalocean
import pytest
import toml
@@ -11,6 +12,71 @@ def test_version():
assert __version__ == '1.0.0'


def test_entrypoint(caplog, monkeypatch):
def load_config(*args):
return {'retention': 2}
monkeypatch.setattr(main, '_load_config', load_config)
monkeypatch.setattr(main, '_process_droplets', mock.nothing)
monkeypatch.setattr(main, '_process_volumes', mock.nothing)
runner = CliRunner()
with runner.isolated_filesystem():
with caplog.at_level('INFO'):
with open('test.toml', 'w') as f:
f.write('Hello World!')
result = runner.invoke(main.entrypoint, [
'test.toml',
'token123',
])
assert result.exit_code == 0
assert len(caplog.records) == 1
assert caplog.records[0].levelname == 'INFO'


def test_entrypoint_debug(caplog, monkeypatch):
def load_config(*args):
return {'retention': 2}
monkeypatch.setattr(main, '_load_config', load_config)
monkeypatch.setattr(main, '_process_droplets', mock.nothing)
monkeypatch.setattr(main, '_process_volumes', mock.nothing)
monkeypatch.setattr(main.log, 'setLevel', mock.nothing)
runner = CliRunner()
with runner.isolated_filesystem():
with caplog.at_level('INFO'):
with open('test.toml', 'w') as f:
f.write('Hello World!')
result = runner.invoke(main.entrypoint, [
'test.toml',
'token123',
'--debug',
])
assert result.exit_code == 0
assert len(caplog.records) == 1
assert caplog.records[0].levelname == 'INFO'


def test_entrypoint_only(caplog, monkeypatch):
def load_config(*args):
return {'retention': 2}
monkeypatch.setattr(main, '_load_config', load_config)
monkeypatch.setattr(main, '_process_droplets', mock.nothing)
monkeypatch.setattr(main, '_process_volumes', mock.nothing)
monkeypatch.setattr(main.log, 'setLevel', mock.nothing)
runner = CliRunner()
with runner.isolated_filesystem():
with caplog.at_level('INFO'):
with open('test.toml', 'w') as f:
f.write('Hello World!')
result = runner.invoke(main.entrypoint, [
'test.toml',
'token123',
'--debug',
'--only', 'prune',
])
assert result.exit_code == 0
assert len(caplog.records) == 1
assert caplog.records[0].levelname == 'INFO'


def test_load_config(monkeypatch):
def load(file):
return {'retention': 2}

0 comments on commit badac82

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