Skip to content

Commit

Permalink
Fix tests (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaihoE authored Jun 28, 2024
1 parent 8eedf40 commit d09e467
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
pip install pytest maturin patchelf
maturin develop
pytest
python3 tests/signature_tests.py
14 changes: 0 additions & 14 deletions src/python/test_perf.py

This file was deleted.

25 changes: 13 additions & 12 deletions src/python/tests/signature_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,59 @@
import pandas as pd
from demoparser2 import DemoParser

demo_path = "../parser/test_demo.dem"

class SignatureTest(TestCase):
def test_parse_header_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
header = parser.parse_header()
self.assertIsInstance(header, dict)
for key, value in header.items():
self.assertIsInstance(key, str)
self.assertIsInstance(value, str)

def test_parse_convars_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
convars = parser.parse_convars()
self.assertIsInstance(convars, dict)
for key, value in convars.items():
self.assertIsInstance(key, str)
self.assertIsInstance(value, str)

def test_list_game_events_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
game_events = parser.list_game_events()
self.assertIsInstance(game_events, list)
for event in game_events:
self.assertIsInstance(event, str)

def test_parse_grenades_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
grenades = parser.parse_grenades()
self.assertIsInstance(grenades, pd.DataFrame)

def test_parse_chat_messages_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
chat_messages = parser.parse_chat_messages()
self.assertIsInstance(chat_messages, pd.DataFrame)

def test_parse_player_info_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
player_info = parser.parse_player_info()
self.assertIsInstance(player_info, pd.DataFrame)

def test_parse_item_drops_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
item_drops = parser.parse_item_drops()
self.assertIsInstance(item_drops, pd.DataFrame)

def test_parse_skins_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
skins = parser.parse_skins()
self.assertIsInstance(skins, pd.DataFrame)

def test_parse_event_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)

event = parser.parse_event("player_death")
self.assertIsInstance(event, pd.DataFrame)
Expand Down Expand Up @@ -86,7 +87,7 @@ def test_parse_event_signature(self):
parser.parse_event(5)

def test_parse_events_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)

events = parser.parse_events(["player_death"])
self.assertIsInstance(events, list)
Expand Down Expand Up @@ -124,15 +125,15 @@ def test_parse_events_signature(self):
parser.parse_events(5)

def test_parse_voice_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)
voice = parser.parse_voice()
self.assertIsInstance(voice, dict)
for key, value in voice.items():
self.assertIsInstance(key, str)
self.assertIsInstance(value, bytes)

def test_parse_ticks_signature(self):
parser = DemoParser("tests/data/test.dem")
parser = DemoParser(demo_path)

ticks = parser.parse_ticks(["X", "Y"])
self.assertIsInstance(ticks, pd.DataFrame)
Expand Down
5 changes: 0 additions & 5 deletions src/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,8 @@ pub fn parseTicks(
Ok(output) => output,
Err(e) => return Err(JsError::new(&format!("{}", e))),
};
real_names.push("tick".to_owned());
real_names.push("steamid".to_owned());
real_names.push("name".to_owned());

let mut prop_infos = output.prop_controller.prop_infos.clone();
prop_infos.sort_by_key(|x| x.prop_name.clone());
real_names.sort();

let helper = OutputSerdeHelperStruct {
prop_infos: prop_infos,
Expand Down

0 comments on commit d09e467

Please sign in to comment.