Skip to content

Commit

Permalink
Merge pull request #200 from Chicago/issue196
Browse files Browse the repository at this point in the history
Fixes #196
  • Loading branch information
geneorama authored Sep 11, 2021
2 parents 7791891 + 4e3ffff commit 2e8802b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Description: Provides easier interaction with
format and manages throttling by 'Socrata'.
Users can upload data to 'Socrata' portals directly
from R.
Version: 1.7.10-6
Date: 2019-10-23
Version: 1.7.11-1
Date: 2021-09-10
Author: Hugh Devlin, Ph. D., Tom Schenk, Jr., Gene Leynes, Nick Lucius, John Malc, Mark Silverberg, and Peter Schmeideskamp
Maintainer: "Tom Schenk Jr." <[email protected]>
Depends:
Expand Down
18 changes: 11 additions & 7 deletions tests/testthat/test-all.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,30 @@ test_that("read Socrata CSV from New Backend (NBE) endpoint", {

test_that("Warn instead of fail if X-SODA2-* headers are missing", {

## Note: The examples with missing Soda2 headers are missing and need to be replaced
## or the issue should be fixed with Socrata / Tyler.
## See issue 196

## These data sets are identified in #118 as data sets with missing soda
## headers. The missing header should cause the data set to return character
## columns instead of columns cast into their appropriate classes.
## RSocrata should also warn the user when the header is missing.
url_csv_missing <- "https://data.healthcare.gov/resource/enx3-h2qp.csv?$limit=1000"
url_json_missing <- "https://data.healthcare.gov/resource/enx3-h2qp.json?$limit=1000"
# url_csv_missing <- "https://data.healthcare.gov/resource/enx3-h2qp.csv?$limit=1000"
# url_json_missing <- "https://data.healthcare.gov/resource/enx3-h2qp.json?$limit=1000"
## These URLs should have soda types in the header
url_csv_complete <- "https://odn.data.socrata.com/resource/pvug-y23y.csv"
url_json_complete <- "https://odn.data.socrata.com/resource/pvug-y23y.json"

msg <- "https://github.com/Chicago/RSocrata/issues/118"

## Check that the soda2 headers are missing
expect_null(RSocrata:::getResponse(url_csv_missing)$headers[['x-soda2-types']], info=msg)
expect_null(RSocrata:::getResponse(url_json_missing)$headers[['x-soda2-types']], info=msg)

# expect_null(RSocrata:::getResponse(url_csv_missing)$headers[['x-soda2-types']], info=msg)
# expect_null(RSocrata:::getResponse(url_json_missing)$headers[['x-soda2-types']], info=msg)
#
## Check for warning that the header is missing, which causes the column
## classes to be returned as character
expect_warning(dfCsv <- read.socrata(url_csv_missing), info=msg)
expect_warning(dfJson <- read.socrata(url_json_missing), info=msg)
# expect_warning(dfCsv <- read.socrata(url_csv_missing), info=msg)
# expect_warning(dfJson <- read.socrata(url_json_missing), info=msg)

## Check that the soda2 headers are present
expect_false(is.null(RSocrata:::getResponse(url_csv_complete)$headers[['x-soda2-types']]), info=msg)
Expand Down

0 comments on commit 2e8802b

Please sign in to comment.