Skip to content

Commit

Permalink
Merge pull request #168 from Chicago/issue166
Browse files Browse the repository at this point in the history
Hot patch to fix #166
  • Loading branch information
geneorama authored Apr 22, 2019
2 parents 5b1baac + ea868a1 commit d8a7663
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 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.5-3
Date: 2019-01-24
Version: 1.7.6-3
Date: 2019-04-18
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
33 changes: 14 additions & 19 deletions tests/testthat/test-all.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ context("posixify function")
test_that("read Socrata CSV is compatible with posixify", {
df <- read.socrata('http://soda.demo.socrata.com/resource/4334-bgaj.csv')
dt <- posixify("09/14/2012 10:38:01 PM")
expect_equal(dt, df$Datetime[1]) ## Check that download matches test
expect_equal(dt, df$datetime[1]) ## Check that download matches test
})

test_that("read Socrata JSON is compatible with posixify (issue 85)", {
Expand Down Expand Up @@ -56,7 +56,7 @@ context("Socrata Calendar")

test_that("Calendar Date Short", {
df <- read.socrata('http://data.cityofchicago.org/resource/y93d-d9e3.csv?$order=debarment_date')
dt <- df$DEBARMENT.DATE[1] # "05/21/1981"
dt <- df$debarment_date[1] # "05/21/1981"
expect_equal("POSIXct", class(dt)[1], label="data type of a date")
expect_equal("81", format(dt, "%y"), label="year")
expect_equal("05", format(dt, "%m"), label="month")
Expand Down Expand Up @@ -111,8 +111,8 @@ test_that("read Socrata CSV as default", {
expect_equal("data.frame", class(df), label="class")
expect_equal(1007, nrow(df), label="rows")
expect_equal(9, ncol(df), label="columns")
expect_equal(c("character", "character", "character", "POSIXct", "numeric",
"numeric", "integer", "character", "character"),
expect_equal(c("POSIXct", "numeric", "character", "character", "numeric",
"integer", "character", "character", "character"),
unname(sapply(sapply(df, class),`[`, 1)),
label="testing column CSV classes with defaults")
})
Expand Down Expand Up @@ -145,8 +145,8 @@ test_that("read Socrata CSV as character", {
expect_equal("data.frame", class(df), label="class")
expect_equal(1007, nrow(df), label="rows")
expect_equal(9, ncol(df), label="columns")
expect_equal(c("character", "character", "character", "POSIXct", "numeric",
"numeric", "integer", "character", "character"),
expect_equal(c("POSIXct", "numeric", "character", "character", "numeric",
"integer", "character", "character", "character"),
unname(sapply(sapply(df, class),`[`, 1)))
})

Expand All @@ -156,8 +156,8 @@ test_that("read Socrata CSV as factor", {
expect_equal("data.frame", class(df), label="class")
expect_equal(1007, nrow(df), label="rows")
expect_equal(9, ncol(df), label="columns")
expect_equal(c("factor", "factor", "factor", "POSIXct", "numeric", "numeric",
"integer", "factor", "factor"),
expect_equal(c("POSIXct", "numeric", "factor", "factor", "numeric",
"integer", "factor", "factor", "factor"),
unname(sapply(sapply(df, class),`[`, 1)))
})

Expand All @@ -166,9 +166,9 @@ test_that("read Socrata JSON as default", {
df <- read.socrata('https://soda.demo.socrata.com/resource/4334-bgaj.json')
expect_equal("data.frame", class(df), label="class")
expect_equal(1007, nrow(df), label="rows")
expect_equal(11, ncol(df), label="columns")
expect_equal(10, ncol(df), label="columns")
expect_equal(c("POSIXct", "character", "character", "character", "character",
"character", "character", "character", "character", "character",
"character", "character", "character", "character",
"character"),
unname(sapply(sapply(df, class),`[`, 1)))
})
Expand All @@ -178,9 +178,9 @@ test_that("read Socrata JSON as character", {
stringsAsFactors = FALSE)
expect_equal("data.frame", class(df), label="class")
expect_equal(1007, nrow(df), label="rows")
expect_equal(11, ncol(df), label="columns")
expect_equal(10, ncol(df), label="columns")
expect_equal(c("POSIXct", "character", "character", "character", "character",
"character", "character", "character", "character", "character",
"character", "character", "character", "character",
"character"),
unname(sapply(sapply(df, class),`[`, 1)))
})
Expand All @@ -190,9 +190,9 @@ test_that("read Socrata JSON as factor", {
stringsAsFactors = TRUE)
expect_equal("data.frame", class(df), label="class")
expect_equal(1007, nrow(df), label="rows")
expect_equal(11, ncol(df), label="columns")
expect_equal(10, ncol(df), label="columns")
expect_equal(c("POSIXct", "factor", "factor", "factor", "factor", "factor",
"factor", "factor", "factor", "factor", "factor"),
"factor", "factor", "factor", "factor"),
unname(sapply(sapply(df, class),`[`, 1)))
})

Expand All @@ -207,11 +207,6 @@ test_that("readSoQL", {
expect_equal(1, ncol(df), label="columns")
})

test_that("readSoQLColumnNotFound (will fail)", {
# SoQL API uses field names, not human names
expect_error(read.socrata('http://soda.demo.socrata.com/resource/4334-bgaj.csv?$select=Region'))
})

test_that("URL is private (Unauthorized) (will fail)", {
expect_error(read.socrata('http://data.cityofchicago.org/resource/j8vp-2qpg.json'))
})
Expand Down

0 comments on commit d8a7663

Please sign in to comment.