From ef85189f7e50896550afd1094c169af9fd0c9602 Mon Sep 17 00:00:00 2001 From: Jylpah Date: Wed, 4 Nov 2020 19:07:47 +0200 Subject: [PATCH 1/5] Create requirements.txt List required Python packages --- requirements.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0e16002 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +motor +aiohttp +aioconsole +aiofiles +aiosqlite +beautifulsoup4 +lxml +xmltodict +progress \ No newline at end of file From d5fd2a81e79f56c5c6e35c6810dae9c0a14fc4e8 Mon Sep 17 00:00:00 2001 From: Jylpah Date: Thu, 5 Nov 2020 21:13:13 +0200 Subject: [PATCH 2/5] Update requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0e16002..a6b3d9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ aiosqlite beautifulsoup4 lxml xmltodict -progress \ No newline at end of file +progress +pytest-asyncio \ No newline at end of file From 2d7de038aef09a0a8f55fcf3909c1553a5a55c74 Mon Sep 17 00:00:00 2001 From: Jylpah Date: Thu, 5 Nov 2020 23:30:37 +0200 Subject: [PATCH 3/5] py_test-asyncio: testing --- upload_wotb_replays.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/upload_wotb_replays.py b/upload_wotb_replays.py index ce0d09e..ccb026a 100755 --- a/upload_wotb_replays.py +++ b/upload_wotb_replays.py @@ -270,7 +270,7 @@ def getTitle_old(replayfile: str, title: str, i : int) -> str: return title -def getTitle(replayfile: str, title: str, i : int) -> str: +def getTitle(replayfile: str, title: str = None, i : int = 0) -> str: global wg if title == None: try: @@ -302,6 +302,32 @@ def getTitle(replayfile: str, title: str, i : int) -> str: bu.debug('Returning: ' + title) return title +### UNIT TESTS - pytest + +class TestClass: + # def test_getTitle(self): + # #player = "jylpah" + # WG_appID = '81381d3f45fa4aa75b78a7198eb216ad' + # wg = WG(WG_appID, 'tanks.json', 'maps.json') + # tank_name = "T28 Defender" # "A68_T28D" + # map_name = "Yukon" # "idle" + # replay = './test/' + '20201030_2358__jylpah_A_1157485188135816346.wotbreplay' + # res = tank_name + ' @ ' + map_name + + # assert getTitle(replay) == res + + @pytest.mark.asyncio + async def test_getTitle(self): + #player = "jylpah" + WG_appID = '81381d3f45fa4aa75b78a7198eb216ad' + wg = WG(WG_appID, 'tanks.json', 'maps.json') + tank_name = "T28 Defender" # "A68_T28D" + map_name = "Yukon" # "idle" + replay = './test/' + '20201030_2358__jylpah_A_1157485188135816346.wotbreplay' + res = tank_name + ' @ ' + map_name + + assert getTitle(replay) == res + ### main() ------------------------------------------- if __name__ == "__main__": # To avoid 'Event loop is closed' RuntimeError due to compatibility issue with aiohttp From 61b69e75a84abae5e333243bae235a19d1fe1f0f Mon Sep 17 00:00:00 2001 From: Jylpah Date: Thu, 5 Nov 2020 23:33:08 +0200 Subject: [PATCH 4/5] calc_team_stats(): minor reorg --- analyze_wotb_replays.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/analyze_wotb_replays.py b/analyze_wotb_replays.py index a8d582a..90c651b 100755 --- a/analyze_wotb_replays.py +++ b/analyze_wotb_replays.py @@ -1316,7 +1316,9 @@ def calc_team_stats(results: list, player_stats : dict, stat_id_map : dict, arg n_players = len(result['allies']) + len(result['enemies']) n_allies = collections.defaultdict(def_value_zero) allies_stats = collections.defaultdict(def_value_zero) - + n_enemies = collections.defaultdict(def_value_zero) + enemies_stats = collections.defaultdict(def_value_zero) + #bu.debug('Processing Allies') for ally in result['allies']: # Player itself is not in 'allies': see read_replay_JSON() @@ -1330,8 +1332,6 @@ def calc_team_stats(results: list, player_stats : dict, stat_id_map : dict, arg n_allies[stat] += 1 #bu.debug('Processing Enemies') - n_enemies = collections.defaultdict(def_value_zero) - enemies_stats = collections.defaultdict(def_value_zero) for enemy in result['enemies']: enemy_mapped = stat_id_map[enemy] if enemy_mapped not in player_stats: From a475dd18a2196d8a6f2c61c48a2de397ec484247 Mon Sep 17 00:00:00 2001 From: Jylpah Date: Thu, 5 Nov 2020 23:33:18 +0200 Subject: [PATCH 5/5] comment py_test out --- upload_wotb_replays.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/upload_wotb_replays.py b/upload_wotb_replays.py index ccb026a..38b8db3 100755 --- a/upload_wotb_replays.py +++ b/upload_wotb_replays.py @@ -304,7 +304,7 @@ def getTitle(replayfile: str, title: str = None, i : int = 0) -> str: ### UNIT TESTS - pytest -class TestClass: +# class TestClass: # def test_getTitle(self): # #player = "jylpah" # WG_appID = '81381d3f45fa4aa75b78a7198eb216ad' @@ -316,17 +316,17 @@ class TestClass: # assert getTitle(replay) == res - @pytest.mark.asyncio - async def test_getTitle(self): - #player = "jylpah" - WG_appID = '81381d3f45fa4aa75b78a7198eb216ad' - wg = WG(WG_appID, 'tanks.json', 'maps.json') - tank_name = "T28 Defender" # "A68_T28D" - map_name = "Yukon" # "idle" - replay = './test/' + '20201030_2358__jylpah_A_1157485188135816346.wotbreplay' - res = tank_name + ' @ ' + map_name + # @pytest.mark.asyncio + # async def test_getTitle(self): + # #player = "jylpah" + # WG_appID = '81381d3f45fa4aa75b78a7198eb216ad' + # wg = WG(WG_appID, 'tanks.json', 'maps.json') + # tank_name = "T28 Defender" # "A68_T28D" + # map_name = "Yukon" # "idle" + # replay = './test/' + '20201030_2358__jylpah_A_1157485188135816346.wotbreplay' + # res = tank_name + ' @ ' + map_name - assert getTitle(replay) == res + # assert getTitle(replay) == res ### main() ------------------------------------------- if __name__ == "__main__":