Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorr task918 add unit test for split universe #996

Merged
merged 20 commits into from
Jun 6, 2024
Merged
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2e89757
Added test for _split_universe()
smitpatel49 May 21, 2024
6476255
update1
smitpatel49 May 21, 2024
2abb4e9
requirements
smitpatel49 May 21, 2024
d8fabff
Merge branch 'master' into SorrTask918_Add_unit_test_for_split_universe
smitpatel49 May 21, 2024
49aa798
Added the requested test
smitpatel49 May 24, 2024
e4b6acc
Updated according to the requested changes
smitpatel49 May 29, 2024
04f351a
Merge branch 'master' into SorrTask918_Add_unit_test_for_split_universe
smitpatel49 May 30, 2024
886f3f6
Corrected a minor mistake
smitpatel49 May 31, 2024
1a3d24e
Merge branch 'master' into SorrTask918_Add_unit_test_for_split_universe
smitpatel49 May 31, 2024
4a0c9ab
Merge branch 'SorrTask918_Add_unit_test_for_split_universe' of https:…
smitpatel49 May 31, 2024
796234d
Updated assertRaises explanation
smitpatel49 May 31, 2024
efb5bf9
Merge branch 'master' into SorrTask918_Add_unit_test_for_split_universe
smitpatel49 May 31, 2024
501c886
Updated according to the review
smitpatel49 May 31, 2024
fd319b2
Merge branch 'master' into SorrTask918_Add_unit_test_for_split_universe
smitpatel49 Jun 3, 2024
e61cd37
Merge branch 'master' into SorrTask918_Add_unit_test_for_split_universe
smitpatel49 Jun 3, 2024
350496f
Added a test and made changes according to the review
smitpatel49 Jun 3, 2024
523517f
Merge branch 'SorrTask918_Add_unit_test_for_split_universe' of https:…
smitpatel49 Jun 3, 2024
d7c0961
Added the missing code
smitpatel49 Jun 5, 2024
b681c5f
Fixed the typo and removed one test
smitpatel49 Jun 6, 2024
401c582
Merge branch 'master' into SorrTask918_Add_unit_test_for_split_universe
samarth9008 Jun 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions im_v2/common/data/extract/test/test_extract_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,62 @@ def test_download_and_resample_bid_ask_data(self) -> None:
not henv.execute_repo_config_code("is_CK_S3_available()"),
reason="Run only if CK S3 is available",
)
class TestSplitUniverse(hunitest.TestCase):
smitpatel49 marked this conversation as resolved.
Show resolved Hide resolved
# A universe list from the example.
universe = [
"ALICE_USDT",
"GALA_USDT",
"FLOW_USDT",
"HBAR_USDT",
"INJ_USDT",
"NEAR_USDT",
]

def test1(self) -> None:
"""
Test if both group_size and universe_part are 0.
smitpatel49 marked this conversation as resolved.
Show resolved Hide resolved
"""
universe_subset = imvcdeexut._split_universe(self.universe, 0, 0)
actual_str = " ".join([str(element) for element in universe_subset])
smitpatel49 marked this conversation as resolved.
Show resolved Hide resolved
expected_str = r"""

"""
self.assert_equal(actual_str, expected_str, fuzzy_match=True)
smitpatel49 marked this conversation as resolved.
Show resolved Hide resolved

def test2(self) -> None:
"""
Test if group_size is 6 and universe_part is 1.

(This returns the whole list in the 1st part)
smitpatel49 marked this conversation as resolved.
Show resolved Hide resolved
"""
universe_subset = imvcdeexut._split_universe(self.universe, 6, 1)
actual_str = " ".join([str(element) for element in universe_subset])
expected_str = r"""
ALICE_USDT GALA_USDT FLOW_USDT HBAR_USDT INJ_USDT NEAR_USDT
"""
self.assert_equal(actual_str, expected_str, fuzzy_match=True)

def test3(self) -> None:
"""
Test if roup_size is 6 and universe_part is 2.
smitpatel49 marked this conversation as resolved.
Show resolved Hide resolved

(This returns an empty list, since no groups in the part)
"""
universe_subset = imvcdeexut._split_universe(self.universe, 6, 2)
actual_str = " ".join([str(element) for element in universe_subset])
expected_str = r"""

"""
self.assert_equal(actual_str, expected_str, fuzzy_match=True)

def test4(self) -> None:
"""
Test to check for error.
smitpatel49 marked this conversation as resolved.
Show resolved Hide resolved
"""
with pytest.raises(RuntimeError):
smitpatel49 marked this conversation as resolved.
Show resolved Hide resolved
(imvcdeexut._split_universe(self.universe, 6, 6))


class TestDownloadHistoricalData1(hmoto.S3Mock_TestCase):
def call_download_historical_data(
self, incremental: bool, *, assert_on_missing_data: bool = False
Expand Down
Loading