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

[WIP] add test for AerodynamicSurface #283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CassianoMontibeller
Copy link
Collaborator

No description provided.

@rafaellehmkuhl
Copy link
Member

It took me a while, but I've found a solution to our problem:

def test_get_lift(mocker, aerodynamic_surface):
    mock_area = mocker.PropertyMock(return_value=2.1)
    AerodynamicSurface.area = mock_area

    mock_aerodynamic_center = mocker.PropertyMock(
        return_value=Vector2(-0.2, 0))
    AerodynamicSurface.aerodynamic_center = mock_aerodynamic_center

    lift_vector, lift_point = aerodynamic_surface.get_lift()

    print(lift_vector)
    print(lift_point)

    assert(lift_vector.x == -1)
    assert(lift_vector.y == -1)
    assert(lift_point.x == -1)
    assert(lift_point.y == -1)

Notice the mocker attribute passed on the test function and the mocker.PropertyMock we are using both the area and the aerodynamic_center properties. Mock means "imitar". What those special functions do is to allow us to "imitar" a function/property with another, for testing purposes.

The above code is fully functional. You can use it. Remember to fix the asserts and remove the prints.

@rafaellehmkuhl
Copy link
Member

@joaofoes take a look at my previous comment. You will need it when implementing tests for the Motor class, which is also an abstract class with some non-implemented methods.

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.

2 participants