Skip to content

Commit

Permalink
Add some very basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Sep 21, 2018
1 parent af6fd1f commit 3e5c568
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
import pytest

from llconfig import Config


def test_basic():
c = Config(env_prefix='VIRTUAL_')
c = Config()
c.init('HOST', str, '0.0.0.0')
c.init('PORT', int, 8080)
c.load()

assert c['HOST'] == '0.0.0.0'
assert c['PORT'] == 8080


def test_case_sensitivity():
c = Config()
c.init('TEST', str, 'TEST')
with pytest.warns(UserWarning):
c.init('test', str, 'test')
c.load()

assert c['TEST'] == 'TEST'
assert c['test'] == 'test'


def test_basic_values_work_without_load():
c = Config()
c.init('TEST', str, 'TEST')
# no load!

assert c['TEST'] == 'TEST'


def test_nonexisting_config_is_missing():
c = Config()
c.init('TEST', str, 'TEST')
c.load()

assert 'TEST' in c
assert 'NOMNOMNOM' not in c

with pytest.raises(KeyError):
c['NOMNOMNOM']

0 comments on commit 3e5c568

Please sign in to comment.