Skip to content

Commit

Permalink
Fixed tests, working playerstats_to_dict_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaszanas committed Aug 21, 2024
1 parent 38a54c0 commit cfe5e40
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tests/test_cases/transforms/pandas/playerstats_to_dict_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path
from typing import List
import unittest

import pandas as pd
Expand All @@ -22,21 +24,20 @@ class PlayerStatsToDictTest(unittest.TestCase):
def setUpClass(cls) -> None:
list_of_test_filenames = ["test_replay.json", "test_replay_victory_defeat.json"]

cls.test_replays = []
cls.test_replays: List[Path] = []
for filename in list_of_test_filenames:
cls.test_replays.append(
test_utils.get_specific_asset_path(filename=filename)
)

cls.sc2_replays_data = []
cls.sc2_replays_data: List[SC2ReplayData] = []
for replay in cls.test_replays:
sc2_replay = SC2ReplayData.from_file(replay_filepath=replay)
cls.sc2_replays_data.append(sc2_replay)

def test_playerstats_to_dict(self):
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):
with self.subTest(str(sc2_replay.filepath)):
res_dict = playerstats_to_dict(sc2_replay=sc2_replay)

# Type assertions for data:
Expand All @@ -53,9 +54,9 @@ def test_playerstats_to_dict_additional_data(self):
"2": {"outcome": 2},
}
for sc2_replay in self.sc2_replays_data:
with self.subTest(sc2_replay=sc2_replay):
with self.subTest(str(sc2_replay.filepath)):
res_dict = playerstats_to_dict(
sc2_replay=self.sc2_replays_data,
sc2_replay=sc2_replay,
additional_data_dict=additional_data,
)

Expand All @@ -71,8 +72,8 @@ def test_playerstats_to_dict_additional_data(self):

def test_playerstats_average_to_dict(self):
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)
with self.subTest(str(sc2_replay.filepath)):
res_dict = playerstats_average_to_dict(sc2_replay=sc2_replay)

# Type assertions for data:
self.assertIsInstance(res_dict, dict)
Expand All @@ -82,12 +83,14 @@ def test_playerstats_average_to_dict(self):

def test_average_playerstats_dataframe(self):
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)
with self.subTest(str(sc2_replay.filepath)):
ps_dict = playerstats_to_dict(sc2_replay=sc2_replay)
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)
dict_average_repr = average_playerstats_dataframe(
playerstats_df=dataframe
)

# Type assertions for the data:
self.assertIsInstance(playerID, str)
Expand Down

0 comments on commit cfe5e40

Please sign in to comment.