diff --git a/tests/test_combat_moves.py b/tests/test_combat_moves.py index 5878bc8..d4bd5e8 100644 --- a/tests/test_combat_moves.py +++ b/tests/test_combat_moves.py @@ -223,8 +223,8 @@ hit_time_ms = 800 load_move(toml_file) -def test_load_move_missing_hit_time(tmp_path): - """Test loading move without hit_time_ms defaults to 0.""" +def test_load_attack_missing_hit_time_raises(tmp_path): + """Test loading attack without hit_time_ms raises error.""" toml_content = """ name = "test" move_type = "attack" @@ -233,9 +233,87 @@ stamina_cost = 5.0 toml_file = tmp_path / "bad.toml" toml_file.write_text(toml_content) + with pytest.raises(ValueError, match="hit_time_ms"): + load_move(toml_file) + + +def test_load_attack_zero_hit_time_raises(tmp_path): + """Test loading attack with hit_time_ms = 0 raises error.""" + toml_content = """ +name = "test" +move_type = "attack" +stamina_cost = 5.0 +hit_time_ms = 0 +""" + toml_file = tmp_path / "bad.toml" + toml_file.write_text(toml_content) + + with pytest.raises(ValueError, match="hit_time_ms"): + load_move(toml_file) + + +def test_load_defense_missing_active_ms_raises(tmp_path): + """Test loading defense without active_ms raises error.""" + toml_content = """ +name = "test" +move_type = "defense" +stamina_cost = 3.0 +recovery_ms = 2000 +""" + toml_file = tmp_path / "bad.toml" + toml_file.write_text(toml_content) + + with pytest.raises(ValueError, match="active_ms"): + load_move(toml_file) + + +def test_load_defense_zero_active_ms_raises(tmp_path): + """Test loading defense with active_ms = 0 raises error.""" + toml_content = """ +name = "test" +move_type = "defense" +stamina_cost = 3.0 +active_ms = 0 +recovery_ms = 2000 +""" + toml_file = tmp_path / "bad.toml" + toml_file.write_text(toml_content) + + with pytest.raises(ValueError, match="active_ms"): + load_move(toml_file) + + +def test_load_attack_valid_passes(tmp_path): + """Test loading attack with valid hit_time_ms passes.""" + toml_content = """ +name = "test" +move_type = "attack" +stamina_cost = 5.0 +hit_time_ms = 500 +""" + toml_file = tmp_path / "valid.toml" + toml_file.write_text(toml_content) + moves = load_move(toml_file) assert len(moves) == 1 - assert moves[0].hit_time_ms == 0 + assert moves[0].hit_time_ms == 500 + + +def test_load_defense_valid_passes(tmp_path): + """Test loading defense with valid active_ms passes.""" + toml_content = """ +name = "test" +move_type = "defense" +stamina_cost = 3.0 +active_ms = 500 +recovery_ms = 2000 +""" + toml_file = tmp_path / "valid.toml" + toml_file.write_text(toml_content) + + moves = load_move(toml_file) + assert len(moves) == 1 + assert moves[0].active_ms == 500 def test_load_moves_from_directory(tmp_path):