Skip to content

Fix usage of OrValidation in enemy_free_kick_play_test #3503

@suchirss

Description

@suchirss

Description of the task

High Level Overview

This task addresses the use of the OrValidation class in enemy_free_kick_play_test. OrValidation is used as a logical OR between validations of the same type. The current enemy_free_kick_play_test passes validations of different types (an always validation and eventually validation) to OrValidation.

This previously passed CI because same type checking was only added to OrValidation by #3123. The reason OrValidation is not able to act as a logical OR for tests of different test types is because it extends the Validation class, which classifies and runs always validations and eventually validations separately.

Detailed Description of Issue

The issue with enemy_free_kick_play_test is here:

    # Always Validation
    always_validation_sequence_set = [
        [
            OrValidation(
                [
                    RobotNeverEntersRegion(
                        regions=[tbots_cpp.Circle(ball_initial_pos, 0.05)]
                    ),
                    BallEventuallyMovesFromRest(position=ball_initial_pos),
                ]
            )
        ]
    ]

Above, we see an OrValidation passed both an always validation and eventually validation - this causes type checking within the OrValidation class to raise a TypeError. Further, this OrValidation is called within the always_validation_sequence_set, which cannot call an eventually validation.

The test is currently prevented from executing to stop CI from failing. This is done with the following code snippet:

@pytest.mark.skip(
    "Disabling this test because OrValidation is passed both an always validation and eventually validation"
)

To execute the test, the above code snippet needs to be removed so that CI runs the test again.

Potential Solutions
There are two main ways to address this issue:

  1. Rewrite enemy_kickoff_play_test so that always validations and eventually validations are separated and placed within their respectiive validation sets. Remove the OrValidation altogether.
  2. Modify OrValidation and/or Validation so that OrValidation can accept both eventually and always validations as parameters.

Acceptance criteria

  • enemy_free_kick_play_test ensures enemy free kick does not break any rules (can infer what these rules are based on the current code OR through the rulebook OR asking Andrew who wrote enemy_free_kick_play_test).
  • Add code comments to enemy_free_kick_play_test to explain what it's checking specifically
  • pytest.mark.skip is removed so the test can be executed again
  • OrValidation no longer throws TypeError
  • enemy_free_kick_play_test passes when executed (assuming the simulation behaviour is correct)

Blocked By

#3123

Metadata

Metadata

Assignees

No one assigned

    Labels

    GameplayTestingField testing, test infrastructure, robot tuning

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions