-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
ad['password'] = 'my_secret' | ||
print((ad.password)) | ||
print((ad['password'])) | ||
print(ad.password == "my_secret") |
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,41 @@ | ||
from secured.secure import Secure | ||
|
||
def test_secure_initialization(): | ||
"""Test the initialization and representation of Secure objects.""" | ||
secure = Secure("sensitive_data", "<Data Hidden>") | ||
assert str(secure) == "<Data Hidden>" | ||
assert repr(secure) == "<Data Hidden>" | ||
|
||
def test_secure_default_message(): | ||
"""Test the default message used when no custom message is provided.""" | ||
secure = Secure("sensitive_data") | ||
assert str(secure) == "<Sensitive data secured>" | ||
|
||
def test_to_int_success(): | ||
"""Test converting secured data to an integer successfully.""" | ||
secure = Secure("123") | ||
assert secure.to_int() == 123 | ||
|
||
def test_to_int_failure(): | ||
"""Test failing to convert secured data to an integer.""" | ||
secure = Secure("sensitive_data") | ||
assert secure.to_int() == "<Sensitive data secured>" | ||
|
||
def test_to_float_success(): | ||
"""Test converting secured data to a float successfully.""" | ||
secure = Secure("123.45") | ||
assert secure.to_float() == 123.45 | ||
|
||
def test_to_float_failure(): | ||
"""Test failing to convert secured data to a float.""" | ||
secure = Secure("sensitive_data") | ||
assert secure.to_float() == "<Sensitive data secured>" | ||
|
||
|
||
def test_key_success(): | ||
"""Test failing to convert secured data to a float.""" | ||
secure = Secure("sensitive_data") | ||
assert secure == "sensitive_data" | ||
secure = Secure("12345") | ||
assert secure == "12345" | ||
assert secure._original == "12345" |