-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setting type mismatch test + exceptions + log update
- Loading branch information
Showing
6 changed files
with
90 additions
and
28 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
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,50 @@ | ||
import logging | ||
import unittest | ||
|
||
import pytest | ||
|
||
from configcatclient.config import get_value, SETTING_TYPE | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
|
||
|
||
class ConfigTests(unittest.TestCase): | ||
def test_value_setting_type_is_missing(self): | ||
value_dictionary = { | ||
't': 6, # unsupported setting type | ||
'v': { | ||
'b': True | ||
} | ||
} | ||
setting_type = value_dictionary.get(SETTING_TYPE) | ||
with pytest.raises(ValueError) as e: | ||
get_value(value_dictionary, setting_type) | ||
assert str(e.value) == "Unsupported setting type" | ||
|
||
def test_value_setting_type_is_valid_but_return_value_is_missing(self): | ||
value_dictionary = { | ||
't': 0, # boolean | ||
'v': { | ||
's': True # the wrong property is set ("b" should be set) | ||
} | ||
} | ||
setting_type = value_dictionary.get(SETTING_TYPE) | ||
with pytest.raises(ValueError) as e: | ||
get_value(value_dictionary, setting_type) | ||
assert str(e.value) == "Setting value is not of the expected type <type 'bool'>" | ||
|
||
def test_value_setting_type_is_valid_and_the_return_value_is_present_but_it_is_invalid(self): | ||
value_dictionary = { | ||
't': 0, # boolean | ||
'v': { | ||
'b': 'True' # the value is a string instead of a boolean | ||
} | ||
} | ||
setting_type = value_dictionary.get(SETTING_TYPE) | ||
with pytest.raises(ValueError) as e: | ||
get_value(value_dictionary, setting_type) | ||
assert str(e.value) == "Setting value is not of the expected type <type 'bool'>" | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.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