improved quickstart:

* respective default answers will be written to config if user provided
   no answer
 * added tests for quickstart
This commit is contained in:
Bastian Venthur
2022-06-28 21:02:51 +02:00
parent 3bd7125873
commit 877c47c391
5 changed files with 98 additions and 28 deletions

24
tests/test_quickstart.py Normal file
View File

@@ -0,0 +1,24 @@
from blag.quickstart import get_input, quickstart
def test_get_input_default_answer(monkeypatch):
monkeypatch.setattr('builtins.input', lambda x: '')
answer = get_input("foo", "bar")
assert answer == 'bar'
def test_get_input(monkeypatch):
monkeypatch.setattr('builtins.input', lambda x: 'baz')
answer = get_input("foo", "bar")
assert answer == 'baz'
def test_quickstart(cleandir, monkeypatch):
monkeypatch.setattr('builtins.input', lambda x: 'foo')
quickstart(None)
with open('config.ini', 'r') as fh:
data = fh.read()
assert 'base_url = foo' in data
assert 'title = foo' in data
assert 'description = foo' in data
assert 'author = foo' in data