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

Fix tests #185

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a straight up string path in a file is always relative to the location that you are calling the file from, not the path of the file.

Copy link
Owner Author

@LaihoE LaihoE Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be correct then? we are in src/python and want to refer to src/parser/test_demo.dem?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah. I didnt read it fully.

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
Loading