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

Approval tests #453

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Approval tests #453

wants to merge 2 commits into from

Conversation

matthiasschaub
Copy link
Collaborator

@matthiasschaub matthiasschaub commented May 2, 2024

  • for area calculation choose CRS valid world-wide not just UTM
  • Choose threshold for area ratio
  • Make approval tests work with parametrized fixtures

@matthiasschaub matthiasschaub marked this pull request as draft May 2, 2024 13:37
if not Path(approved_path).exists() or Path(approved_path).stat().st_size == 0:
return False

# TODO: find optimal UTM for every feature or different projection
Copy link

Choose a reason for hiding this comment

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

8857 seems to be an okay projection

Comment on lines +14 to +15
def vector_path(tmp_path_factory, uuid_digitize) -> bytes:
return tmp_path_factory.getbasetemp() / uuid_digitize / "vector.geojson"
Copy link

Choose a reason for hiding this comment

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

Where does tmp_path_factory come from? Do I just not see it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its pytest magic. Its a global fixture defined by pytest. No import needed.

(The other fixtures are also not imported but defined by us in conftest.py which is discovered and parsed by pytest magic as well)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

test_path_factory gives as a tmp dir unique to the current test run

@matthiasschaub
Copy link
Collaborator Author

For parametrized fixtures in a tests following error gets raised after the first test run (first parameter):

    def test_smt_approver(sketch_map_marked_path, vector_path):
        options = (
            Options()
            .with_reporter(SketchMapToolReporter(sketch_map=sketch_map_marked_path))
            .with_comparator(GeoJSONComparator())
        )
        with open(vector_path, "rb") as f:
>           verify_binary(f.read(), ".geojson", options=options)
E           approvaltests.approval_exception.ApprovalException: We noticed that you called verify more than once in the same test. 
E           This is the second call to verify:
E               approved_file: /home/matthias/work/smt/tests/integration/test_approval.test_smt_approver.approved.geojson
E           
E           By default, ApprovalTests only allows one verify() call per test.
E           To find out more, visit: 
E           https://github.com/approvals/ApprovalTests.Python/blob/main/docs/how_to/multiple_approvals_per_test.md
E           
E           # Possible Fixes
E           1. Separate your test into two tests
E           2. In your verify call, add `options=NamerFactory.with_parameters("your_paramater")`
E           3. In your test, call `approvals.settings().allow_multiple_verify_calls_for_this_method()`

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.

None yet

2 participants