-
Notifications
You must be signed in to change notification settings - Fork 60
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 #51 from tinymanorg/app-call-notes
Add transaction note for integrations
- Loading branch information
Showing
31 changed files
with
330 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from base64 import b64encode | ||
from unittest import TestCase | ||
|
||
from tinyman.utils import generate_app_call_note, parse_app_call_note | ||
|
||
|
||
class BaseTestCase(TestCase): | ||
maxDiff = None | ||
|
||
def test_app_call_note(self): | ||
note = generate_app_call_note( | ||
version="v2", client_name="unit-test", extra_data={"extra": "some text"} | ||
) | ||
expected_result = { | ||
"version": "v2", | ||
"data": {"extra": "some text", "origin": "unit-test"}, | ||
} | ||
|
||
# test possible versions | ||
string_note = note | ||
bytes_note = string_note.encode() | ||
base64_note = b64encode(bytes_note).decode() | ||
|
||
result = parse_app_call_note(string_note) | ||
self.assertDictEqual( | ||
result, | ||
expected_result, | ||
) | ||
|
||
result = parse_app_call_note(base64_note) | ||
self.assertDictEqual( | ||
result, | ||
expected_result, | ||
) | ||
|
||
result = parse_app_call_note(base64_note) | ||
self.assertDictEqual( | ||
result, | ||
expected_result, | ||
) | ||
|
||
result = parse_app_call_note("invalid format") | ||
self.assertEqual(result, None) | ||
result = parse_app_call_note( | ||
"INVALID+dGlueW1hbi92MjpqeyJvcmlnaW4iOiJ0aW55bWFuLXB5dGhvbi1zZGsifQ==" | ||
) | ||
self.assertEqual(result, None) | ||
result = parse_app_call_note(b"invalid format") | ||
self.assertEqual(result, None) | ||
result = parse_app_call_note( | ||
b'INVALID+tinyman/v2:j{"origin":"tinyman-python-sdk"}' | ||
) | ||
self.assertEqual(result, None) |
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
Oops, something went wrong.