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

Update tests to use internal sample .osm file #265

Open
mpadge opened this issue Jan 26, 2022 · 2 comments
Open

Update tests to use internal sample .osm file #265

mpadge opened this issue Jan 26, 2022 · 2 comments

Comments

@mpadge
Copy link
Member

mpadge commented Jan 26, 2022

Most of the tests could be run with no mocking at all, by just using an internal .osm file.

@mpadge
Copy link
Member Author

mpadge commented Feb 7, 2023

@jmaspons What are your thoughts on this issue? Mock tests are currently only in these four files:

  1. Single mock call only which could be replaced:

    res <- with_mock_dir ("mock_unname", {
    osmdata_sf (qry)
    })

  2. In test-features.R, which can't be replaced by an internal file.

  3. Single mock call only which could be replaced:

    doc <- with_mock_dir ("mock_elevation", {
    osmdata_xml (qry, file = f)
    })

  4. In test-getbb.R, with lots of mocked calls to nominatim which likely can't be replaced.

  5. Lots of calls in test-osmdata.R which likely could be replaced by using a local file instead of mocking:

    res <- with_mock_dir ("mock_osm_sp", {
    osmdata_sp (qry)
    })

That suggests this, which would be good to do for current (v0.1.2) release:


TODO

  • Replace single mock call in test-unname.R through using local file.
  • Replace single mock call in test-elevation.R through using local file.
  • Replace most (all?) mock calls in test-osmdata.R through using local file instead.

@jmaspons
Copy link
Collaborator

jmaspons commented Feb 7, 2023

Mock calls are cool! I would keep them in the places where we actually want to check the functionality, ie. test-osmdata.R to check overpass_query function. In other places such as test-elevation.R or test-unname.R it's not necessary because there we are testing other functions, but it doesn't hurt.

All in all, if the test coverage doesn't degrade, both approaches are fine. What can be interesting to reduce the package size is to reuse the mock calls. I don't see why we need different queries for each osmdata_* function. Perhaps different mock calls for different query types (adiff, diff, tags...) is enough if needed at all (.osm files also works for checking all the code paths).

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

No branches or pull requests

2 participants