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

Add latitude/longitude coordinate requirements to test cases #251

Open
orangejulius opened this issue Jun 10, 2016 · 1 comment
Open

Add latitude/longitude coordinate requirements to test cases #251

orangejulius opened this issue Jun 10, 2016 · 1 comment

Comments

@orangejulius
Copy link
Member

orangejulius commented Jun 10, 2016

Thanks to the great work of @vesameskanen some time ago, we have the ability to write tests that require the results of a query to be within a certain distance of a given point!

What do we want?

More tests that check the lat/lon of results! 🌐

When do we want it?

Whenever it makes sense. At this point, we don't have any hard and fast rules for when a test should look at the lat/lon of results. However there are definitely cases where they aren't helpful. Many of our tests are specifically for labels, for example, and adding lat/lon requirements might be overspecification.

A great case is whenever we have had a bug where a result who's name, label, etc look correct but the result is not in the right place. This test for San Francisco's centroid being on land, not in the ocean is a great example.

Some ideas

  • We have tests for places like "Union Square", which are all over the place. We currently use the city name to differentiate, but coordinates could help as well.
  • Some of our tests deal with restaurant chains like McDonalds, of which there are many all over the place. A perfect case where lat/lon requirements might be helpful.

Test Syntax

As a reminder here's the syntax of a test with a lat/lon:

  {
      "id": 1,
      "status": "fail",
      "user": "Julian",
      "in": {
        "text": "san francisco",
        "boundary.country": "USA"
      },
      "expected": {
        "distanceThresh": 1000,
        "properties": [
          {
            "region": "California",
            "name": "San Francisco"
          }
        ],
        "coordinates": [
          [ -122.431272, 37.778008 ]
        ]
      }
    },

The coordinates section in the expected section is an array of coordinates (which themselves are arrays). The coordinates are in [longitude, latitude] format with each point represented as a number (no north/south/east/west or degrees/minutes/seconds needed). The distanceThresh value is the maximum distance allowed between the expected point and the result, in meters. distanceThresh can also go at the root level of the test case at the top of the file, and then it will apply to all tests that don't override it.

@missinglink
Copy link
Member

missinglink commented Aug 4, 2016

see: https://github.com/pelias/api/blob/master/test/unit/sanitizer/wrap.js for the corresponding unit tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants