-
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 Unit test for convert_stream_to_dict_format
- Loading branch information
1 parent
86dfd28
commit ee3b806
Showing
4 changed files
with
51 additions
and
26 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 |
---|---|---|
@@ -1,9 +1,23 @@ | ||
import pytest | ||
from datetime import datetime | ||
|
||
from th2_data_services.data_source.lwdp import Stream, Streams | ||
from th2_data_services.data_source.lwdp.streams import _convert_stream_to_dict_format | ||
from th2_data_services.data_source.lwdp.utils import _check_timestamp | ||
|
||
|
||
def test_datetime_invalid_type(): | ||
with pytest.raises(Exception) as err: | ||
_check_timestamp(datetime.now().timestamp()) | ||
assert "Provided timestamp should be `datetime`, `str` or `int` object in UTC time" in str(err) | ||
|
||
|
||
def test_convert_stream_to_dict_format(): | ||
streams = ['s1:1', {'sessionAlias': 's2', 'direction': ['IN']}, Stream('s3', 2), Streams(['s4'])] | ||
expected = [ | ||
{'sessionAlias': 's1', 'direction': ['IN']}, | ||
{'sessionAlias': 's2', 'direction': ['IN']}, | ||
{'sessionAlias': 's3', 'direction': ['OUT']}, | ||
{'sessionAlias': 's4'} | ||
] | ||
assert _convert_stream_to_dict_format(streams) == expected |
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