This repository has been archived by the owner on Feb 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from jbasko/config-of-configs
Allow sections to be created on their own
- Loading branch information
Showing
10 changed files
with
135 additions
and
63 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 1.16.0 | ||
current_version = 1.17.0 | ||
commit = true | ||
tag = false | ||
|
||
|
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,4 +1,4 @@ | ||
__version__ = '1.16.0' | ||
__version__ = '1.17.0' | ||
|
||
from .managers import Config | ||
from .items import Item | ||
|
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
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,45 @@ | ||
""" | ||
Most section tests are in test_config. | ||
Here are tests just to test Section usage outside of Configs. | ||
""" | ||
from configmanager import Section | ||
|
||
|
||
def test_section_created_from_declaration(): | ||
uploads = Section({ | ||
'enabled': True, | ||
'threads': 1, | ||
}) | ||
|
||
assert uploads.is_section | ||
|
||
assert uploads.enabled.is_item | ||
assert uploads.enabled.value is True | ||
|
||
assert uploads.threads.is_item | ||
assert uploads.threads.value == 1 | ||
|
||
|
||
def test_nested_section_created_from_declaration(): | ||
config = Section({ | ||
'uploads': Section({ | ||
'db': Section({ | ||
'user': 'root' | ||
}) | ||
}) | ||
}) | ||
|
||
assert config.uploads.db._settings is config._settings | ||
assert config.uploads._settings is config._settings | ||
|
||
calls = [] | ||
|
||
@config.hooks.item_value_changed | ||
def value_changed(**kwargs): | ||
calls.append(1) | ||
|
||
assert len(calls) == 0 | ||
|
||
config.uploads.db.user.value = 'admin' | ||
|
||
assert len(calls) == 1 |