-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrote some during a demo with Peter and co, and finished the last couple after.
- Loading branch information
Showing
5 changed files
with
126 additions
and
7 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,42 @@ | ||
import pytest | ||
import os | ||
#from unittest.mock import Mock | ||
|
||
import logging | ||
|
||
import sarracenia | ||
import sarracenia.identity | ||
|
||
#useful for debugging tests | ||
import pprint | ||
pretty = pprint.PrettyPrinter(indent=2, width=200).pprint | ||
|
||
|
||
def test_factory(): | ||
identity = sarracenia.identity.Identity().factory('foobar') | ||
assert identity == None | ||
|
||
identity = sarracenia.identity.Identity().factory() | ||
assert identity.registered_as() == 's' | ||
|
||
def test_get_method(): | ||
identity = sarracenia.identity.Identity().factory() | ||
assert identity.get_method() == 'sha512' | ||
|
||
|
||
def test_update_file(tmp_path): | ||
path1 = str(tmp_path) + os.sep + "file1.txt" | ||
open(path1, 'a').write('randomstring') | ||
identity = sarracenia.identity.Identity().factory() | ||
identity.update_file(path1) | ||
|
||
assert identity.filehash.name == "sha512" | ||
|
||
@pytest.mark.depends(on=['test_update_file']) | ||
def test___Property_value(tmp_path): | ||
path1 = str(tmp_path) + os.sep + "file1.txt" | ||
open(path1, 'a').write('randomstring') | ||
identity = sarracenia.identity.Identity().factory() | ||
identity.update_file(path1) | ||
|
||
assert identity.value == 'kkUPxxKfR72my8noS5yekWcdFnmIJSvDJIvtSF7uTyvnhtm0saERCXReIcNDAk2B7gET3o+tQY3gTbd36ynoDA==' |
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,47 @@ | ||
import pytest | ||
import os | ||
#from unittest.mock import Mock | ||
|
||
import logging | ||
|
||
import sarracenia | ||
import sarracenia.identity.arbitrary | ||
|
||
#useful for debugging tests | ||
import pprint | ||
pretty = pprint.PrettyPrinter(indent=2, width=200).pprint | ||
|
||
|
||
def test___init__(): | ||
hash = sarracenia.identity.arbitrary.Arbitrary() | ||
assert hash._value == 'None' | ||
|
||
|
||
def test_registered_as(): | ||
# Set 1 | ||
hash = sarracenia.identity.arbitrary.Arbitrary() | ||
assert hash.registered_as() == 'a' | ||
|
||
def test_set_path(tmp_path): | ||
path1 = str(tmp_path) + os.sep + "file1.txt" | ||
hash = sarracenia.identity.arbitrary.Arbitrary() | ||
hash.set_path(path1) | ||
assert True | ||
|
||
|
||
def test_update(): | ||
hash = sarracenia.identity.arbitrary.Arbitrary() | ||
hash.update('randomstring') | ||
assert True | ||
|
||
@pytest.mark.depends() | ||
def test___Property_value(): | ||
sarracenia.identity.arbitrary.set_default_value('default') | ||
|
||
hash = sarracenia.identity.arbitrary.Arbitrary() | ||
assert hash.value == 'default' | ||
|
||
# test the setter | ||
hash.value = 'new' | ||
assert hash.value == 'new' | ||
|
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,36 @@ | ||
import pytest | ||
import os | ||
#from unittest.mock import Mock | ||
|
||
import logging | ||
|
||
import sarracenia | ||
import sarracenia.identity.md5 | ||
|
||
#useful for debugging tests | ||
import pprint | ||
pretty = pprint.PrettyPrinter(indent=2, width=200).pprint | ||
|
||
|
||
def test_registered_as(): | ||
# Set 1 | ||
hash = sarracenia.identity.md5.Md5() | ||
assert hash.registered_as() == 'd' | ||
|
||
def test_set_path(tmp_path): | ||
path1 = str(tmp_path) + os.sep + "file1.txt" | ||
hash = sarracenia.identity.md5.Md5() | ||
hash.set_path(path1) | ||
assert hash.filehash.name == "md5" | ||
|
||
@pytest.mark.depends(on=['test_set_path']) | ||
def test_update(tmp_path): | ||
path1 = str(tmp_path) + os.sep + "file1.txt" | ||
# Set 1 | ||
hash = sarracenia.identity.md5.Md5() | ||
hash.set_path(path1) | ||
hash.update('randomstring') | ||
assert hash.value == 'tpDC1B4RAL5h8WAs1C1OFg==' | ||
hash.update(b'randombytes') | ||
assert hash.value == '+sILUpRAJFq9hB7p8kx1xA==' | ||
|
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