-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change how required settings are handled
Certain settings are going to be required for the application to run. Currently `SECRET_KEY` is the only one, but the list will most likely grow over time. The application factory allows for the settings in `settings.py` to be overridden a couple of different ways. Required settings should be checked after all of the overrides have been processed. This is being implemented in the form of a helper function that checks for the required keys. Because `settings.py` will add the key to the configuration, `DOES_NOT_EXIST` is a value that can be assigned to a key that is intended to be required. `check_required_settings` will respect both the absence of the key and the value `DOES_NOT_EXIST`. Along with this change comes some tests. These two tests are the groundwork for the eventual suite of tests. `tox` can be used to run the tests. `tox` requires a `setup.py` in order to install the package into the virtualenv, so a minimal one is being added for that purpose. Fixes #32
- Loading branch information
Showing
10 changed files
with
77 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[run] | ||
branch = True | ||
|
||
[report] | ||
exclude_lines = | ||
if __name__ == '__main__: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Local/private stuffs | ||
instance | ||
settings.cfg | ||
|
||
# Frontend preprocessors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from setuptools import setup | ||
|
||
setup(name='nycpython', version='1.0.0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
|
||
from nycpython import utils | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def config(): | ||
return { | ||
'KEY1': 1, | ||
'KEY2': 2, | ||
} | ||
|
||
|
||
def test_check_required_settings(config): | ||
assert utils.check_required_settings(config, ('KEY1', 'KEY2')) is None | ||
|
||
|
||
def test_check_required_settings_missing_key(config): | ||
with pytest.raises(RuntimeError) as e: | ||
utils.check_required_settings(config, ('KEY1', 'KEY3')) | ||
assert 'KEY3' in e.value.args[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[tox] | ||
envlist = py33 | ||
|
||
[testenv] | ||
deps = | ||
coverage | ||
factory_boy | ||
pytest | ||
commands = | ||
coverage run --source nycpython -m pytest tests | ||
coverage report -m |