-
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.
Additional tests for coverage and documentation
- Loading branch information
Showing
6 changed files
with
89 additions
and
34 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
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,56 @@ | ||
import pytest | ||
|
||
from protean.exceptions import ConfigurationError | ||
from protean.utils import convert_str_values_to_list, generate_identity | ||
|
||
|
||
def test_convert_str_values_to_list(): | ||
# Test when value is None | ||
assert convert_str_values_to_list(None) == [] | ||
|
||
# Test when value is an empty string | ||
assert convert_str_values_to_list("") == [] | ||
|
||
# Test when value is a non-empty string | ||
assert convert_str_values_to_list("test") == ["test"] | ||
|
||
# Test when value is a list of strings | ||
assert convert_str_values_to_list(["a", "b"]) == ["a", "b"] | ||
|
||
# Test when value is a list of integers | ||
assert convert_str_values_to_list([1, 2, 3]) == [1, 2, 3] | ||
|
||
# Test when value is a tuple | ||
assert convert_str_values_to_list((1, 2, 3)) == [1, 2, 3] | ||
|
||
# Test when value is a set | ||
assert convert_str_values_to_list({1, 2, 3}) == [1, 2, 3] | ||
|
||
# Test when value is a dictionary | ||
assert convert_str_values_to_list({"a": 1, "b": 2}) == ["a", "b"] | ||
|
||
# Test when value is an integer (not iterable) | ||
with pytest.raises(TypeError): | ||
convert_str_values_to_list(10) | ||
|
||
# Test when value is a float (not iterable) | ||
with pytest.raises(TypeError): | ||
convert_str_values_to_list(10.5) | ||
|
||
# Test when value is a boolean | ||
with pytest.raises(TypeError): | ||
convert_str_values_to_list(True) | ||
|
||
# Test when value is an object | ||
class TestObject: | ||
pass | ||
|
||
with pytest.raises(TypeError): | ||
convert_str_values_to_list(TestObject()) | ||
|
||
|
||
def test_unknown_identity_type_raises_exception(): | ||
with pytest.raises(ConfigurationError) as exc: | ||
generate_identity(identity_type="foo") | ||
|
||
assert str(exc.value) == "Unknown Identity Type 'foo'" |