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

Instantiate Mock members by function #523

Merged
merged 2 commits into from
Feb 28, 2024
Merged

Conversation

sondreo
Copy link
Contributor

@sondreo sondreo commented Feb 27, 2024

Fixes bug in state machine tests due to class instance member being mutated across different tests.

Resolves #516

Format files

Make MockStep methods static
@sondreo sondreo marked this pull request as ready for review February 27, 2024 13:32
Copy link
Contributor

@tsundvoll tsundvoll left a comment

Choose a reason for hiding this comment

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

Well spotted that you found the cause of the issue. Some comments for naming:

tests/mocks/step.py Show resolved Hide resolved
tests/mocks/step.py Outdated Show resolved Hide resolved
return DriveToPose(pose=MockPose.default_pose)

@staticmethod
def take_image_in_coordinate_direction() -> TakeImage:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def take_image_in_coordinate_direction() -> TakeImage:
def get_dummy_take_image_step() -> TakeImage:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See below regarding naming. It is added as a separate issue.

@@ -5,7 +5,10 @@


class MockStep:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class MockStep:
class DummyStep:

Also consider using the naming "Stub" or "Fake", both may be representative of what we try to accomplish here. Relevant article: https://jesusvalerareales.com/testing-with-test-doubles/

Also, does not need to be solved here, you can make an issue for it and suggest a renaming for all similar "Mocks" that should be called "Dummy", "Stub", or "Fake"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, and great tip for a relevant resource. I will defer this to a separate issue, and have created one.

@sondreo sondreo changed the title Instantiate MockStep members by function Instantiate Mock members by function Feb 28, 2024
Copy link
Contributor

@tsundvoll tsundvoll left a comment

Choose a reason for hiding this comment

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

Good work 👍 Wise to delegate comments to a separate issue

@sondreo sondreo merged commit bd78423 into equinor:main Feb 28, 2024
3 checks passed
@sondreo sondreo deleted the mock-step-fix branch February 28, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"500: Internal Server Error - Failed to stop mission" in the tests
2 participants