Skip to content

Commit

Permalink
drafting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scmisa committed Aug 21, 2024
1 parent 68de7f1 commit 38a54c0
Showing 1 changed file with 49 additions and 41 deletions.
90 changes: 49 additions & 41 deletions tests/test_cases/transforms/pandas/playerstats_to_dict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,55 +34,63 @@ def setUpClass(cls) -> None:
cls.sc2_replays_data.append(sc2_replay)

def test_playerstats_to_dict(self):
res_dict = playerstats_to_dict(sc2_replay=self.sc2_replay_data)

# Type assertions for data:
for playerID, feature_dict in res_dict.items():
self.assertIsInstance(playerID, str)
self.assertIsInstance(feature_dict, dict)
for key, feature_list in feature_dict.items():
self.assertIsInstance(key, str)
self.assertIsInstance(feature_list, list)
res_dict = playerstats_to_dict(sc2_replay=self.sc2_replays_data)
for sc2_replay in self.sc2_replays_data:
with self.subTest(sc2_replay=sc2_replay):
res_dict = playerstats_to_dict(sc2_replay=sc2_replay)

# Type assertions for data:
for playerID, feature_dict in res_dict.items():
self.assertIsInstance(playerID, str)
self.assertIsInstance(feature_dict, dict)
for key, feature_list in feature_dict.items():
self.assertIsInstance(key, str)
self.assertIsInstance(feature_list, list)

def test_playerstats_to_dict_additional_data(self):
additional_data = {
"1": {"outcome": 1},
"2": {"outcome": 2},
}

res_dict = playerstats_to_dict(
sc2_replay=self.sc2_replay_data,
additional_data_dict=additional_data,
)

# Type assertions for data:
for playerID, feature_dict in res_dict.items():
self.assertIsInstance(playerID, str)
self.assertIsInstance(feature_dict, dict)
# Assertions for additional data:
self.assertTrue("outcome" in feature_dict)
for key, feature_list in feature_dict.items():
self.assertIsInstance(key, str)
self.assertIsInstance(feature_list, list)
for sc2_replay in self.sc2_replays_data:
with self.subTest(sc2_replay=sc2_replay):
res_dict = playerstats_to_dict(
sc2_replay=self.sc2_replays_data,
additional_data_dict=additional_data,
)

# Type assertions for data:
for playerID, feature_dict in res_dict.items():
self.assertIsInstance(playerID, str)
self.assertIsInstance(feature_dict, dict)
# Assertions for additional data:
self.assertTrue("outcome" in feature_dict)
for key, feature_list in feature_dict.items():
self.assertIsInstance(key, str)
self.assertIsInstance(feature_list, list)

def test_playerstats_average_to_dict(self):
res_dict = playerstats_average_to_dict(sc2_replay=self.sc2_replay_data)
for sc2_replay in self.sc2_replays_data:
with self.subTest(sc2_replay=sc2_replay):
res_dict = playerstats_average_to_dict(sc2_replay=self.sc2_replays_data)

# Type assertions for data:
self.assertIsInstance(res_dict, dict)
for key, value in res_dict.items():
self.assertIsInstance(key, str)
self.assertIsInstance(value, dict)
# Type assertions for data:
self.assertIsInstance(res_dict, dict)
for key, value in res_dict.items():
self.assertIsInstance(key, str)
self.assertIsInstance(value, dict)

def test_average_playerstats_dataframe(self):
ps_dict = playerstats_to_dict(sc2_replay=self.sc2_replay_data)
for playerID, df_repr in ps_dict.items():
# Initializing dataframe from dict:
dataframe = pd.DataFrame.from_dict(df_repr)
dict_average_repr = average_playerstats_dataframe(playerstats_df=dataframe)

# Type assertions for the data:
self.assertIsInstance(playerID, str)
for key, value in dict_average_repr.items():
self.assertIsInstance(key, str)
self.assertIsInstance(value, float)
for sc2_replay in self.sc2_replays_data:
with self.subTest(sc2_replay=sc2_replay):
ps_dict = playerstats_to_dict(sc2_replay=self.sc2_replays_data)
for playerID, df_repr in ps_dict.items():
# Initializing dataframe from dict:
dataframe = pd.DataFrame.from_dict(df_repr)
dict_average_repr = average_playerstats_dataframe(playerstats_df=dataframe)

# Type assertions for the data:
self.assertIsInstance(playerID, str)
for key, value in dict_average_repr.items():
self.assertIsInstance(key, str)
self.assertIsInstance(value, float)

0 comments on commit 38a54c0

Please sign in to comment.