-
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.
* add compression in code and tests * remvoed wrapper and some refactor * Lint * removes unused import * fixes type hinting * tests for compressioN * renamed fixture * minor version bump
- Loading branch information
Angelo
authored
Oct 28, 2019
1 parent
cc0b179
commit a747089
Showing
4 changed files
with
41 additions
and
8 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,26 @@ | ||
import gzip | ||
from base64 import b64encode | ||
|
||
import pytest | ||
|
||
from bluejay.backend import SNSBackend | ||
from bluejay.backend.encode import JSONEncoder | ||
|
||
|
||
@pytest.fixture | ||
def expected_payload(send_event_command): | ||
obj = send_event_command.payload | ||
|
||
return SNSBackend.compress(JSONEncoder().encode(obj)) | ||
|
||
|
||
def test_compression_duplicate_code(send_event_command, expected_payload): | ||
payload = send_event_command.payload | ||
|
||
json_payload = JSONEncoder().encode(payload) | ||
|
||
compressed_string = gzip.compress(json_payload.encode()) | ||
b64_payload = b64encode(compressed_string) | ||
compressed_payload = b64_payload.decode() | ||
|
||
assert compressed_payload == expected_payload |
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