Chicago/RSocrata

Resolve failing tests

tomschenkjr opened this issue · 4 comments

Received an email from the CRAN support team, noting that some RSocrata tests are failing on a regular basis. Below is an excerpt of the failing tests as of 2017-12-04:

Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
Not Found (HTTP 404).
1: read.socrata("https://data.cityofboston.gov/resource/awu8-dc52.csv?$where=case_enquiry_id< 101000295717") at testthat/test-all.R:239
2: getResponse(validUrl, email, password)
3: httr::stop_for_status(response)

2017-12-03 18:22:49.492 getResponse: Error in httr GET: 400 https://soda.demo.socrata.com/resource/4334-bgaj.csv?%24app_token=ew2rEMuESuzWPqMkyPfOSGJgE&$order=:id
2017-12-03 18:22:50.056 getResponse: Error in httr GET: 400 https://soda.demo.socrata.com/resource/4334-bgaj.csv?%24app_token=ew2rEMuESuzWPqMkyPfOSGJgE&$order=:id
2017-12-03 18:22:51.723 getResponse: Error in httr GET: 403 https://soda.demo.socrata.com/resource/a9g2-feh2.csv?$order=:id
2017-12-03 18:22:52.356 getResponse: Error in httr GET: 403 https://soda.demo.socrata.com/resource/a9g2-feh2.json?$order=:id
testthat results ================================================================
OK: 155 SKIPPED: 0 FAILED: 1

  1. Error: Read data with missing dates (@test-all.R#239)

The error pertains to #137 that we now need to resolve.

The 400 and 403 errors are more mysterious. Below is the output of https://soda.demo.socrata.com/resource/4334-bgaj.csv?%24app_token=ew2rEMuESuzWPqMkyPfOSGJgE&$order=:id

{
  "error" : true,
  "message" : "Unrecognized arguments [$app_token]"
}

I will email Socrata to determine the source of the error.

Fixes will need to be submitted by 2017-12-17.

Just a quick bit of research, appears that Socrata has changed the parameter from $app_token to $$app_token.

While looking at the errors, it appears another problem is the resource a9g2-feh2 used to test reading from private data sets is no longer accessible with the provided login credentials.

The test dataset lives on Socrata, so I've opened a ticket, 24165, with them to resolve this.

Oddly, those credentials do seem to work with the test dataset for writing data.

The authentication problem with a9g2-feh2 has been resolved by Socrata.

However, this test expects an error because it only uses $app_token instead of the correct $$app_token. While we use testthat::expect_error(), httr will still return an error:

getResponse: Error in httr GET: 400  https://soda.demo.socrata.com/resource/4334-bgaj.csv?%24app_token=ew2rEMuESuzWPqMkyPfOSGJgE&$order=:id

It's unclear why an error is being returned while an error is expect. Unclear whether this is an issue with testthat or httr. @geneorama indicated he may have a fix for this, so waiting on his input on a work-around.

The 400 errors are a consequence of #137. When encountering the latter errors, R will dump out messages generated by RSocrata's getResponse() function and will print alongside the 404 error (or any other error). By resolving #137, it also resolved this.