Skip to content

Commit

Permalink
cleaned NAMESPACE, added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daranzolin committed Sep 21, 2016
1 parent e851a36 commit 367568a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
22 changes: 22 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,29 @@ importFrom(httr,GET)
importFrom(httr,content)
importFrom(httr,stop_for_status)
importFrom(httr,user_agent)
importFrom(leaflet,addMarkers)
importFrom(leaflet,addTiles)
importFrom(leaflet,leaflet)
importFrom(leaflet,leafletOutput)
importFrom(leaflet,renderLeaflet)
importFrom(magrittr,"%>%")
importFrom(shiny,actionButton)
importFrom(shiny,column)
importFrom(shiny,eventReactive)
importFrom(shiny,fluidPage)
importFrom(shiny,fluidRow)
importFrom(shiny,htmlOutput)
importFrom(shiny,icon)
importFrom(shiny,renderTable)
importFrom(shiny,renderText)
importFrom(shiny,renderUI)
importFrom(shiny,selectInput)
importFrom(shiny,sidebarPanel)
importFrom(shiny,tabPanel)
importFrom(shiny,tableOutput)
importFrom(shiny,tabsetPanel)
importFrom(shiny,textInput)
importFrom(shiny,textOutput)
importFrom(tidyjson,as.tbl_json)
importFrom(tidyjson,enter_object)
importFrom(tidyjson,jstring)
Expand Down
5 changes: 4 additions & 1 deletion R/explore_cicero.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#' Shiny app for exploring Cicero data on elected officials
#'
#' @importFrom shiny fluidPage fluidRow sidebarPanel textInput selectInput actionButton column
#' @importFrom shiny tabsetPanel tabPanel tableOutput textOutput htmlOutput icon
#' @importFrom shiny eventReactive renderTable renderText renderUI
#' @importFrom leaflet leaflet addTiles addMarkers renderLeaflet leafletOutput
#' @export
#' @examples
#'
Expand Down
4 changes: 1 addition & 3 deletions R/get_official.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ get_official <- function(search_loc = NULL, lat = NULL, lon = NULL, first_name =
district_type = c("STATE_LOWER", "STATE_UPPER",
"NATIONAL_UPPER", "NATIONAL_LOWER", "NATIONAL_EXEC")) {
if (!is.null(valid_on)) {
valid_on <- try({
as.Date(valid_on, format = "%Y-%m-%d")
})
valid_on <- try(as.Date(valid_on, format = "%Y-%m-%d"))
if (class(valid_on) == "try-error" || is.na(valid_on)) {
stop("valid_on argument must be in %Y-%m-%d format")
}
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-nonlegislativedistrict.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
context("get_nonlegislative_district")

test_that("returns the correct", {

a <- get_nonlegislative_district(search_loc = "3175 Bowers Ave. Santa Clara, CA", type = "SCHOOL")
b <- get_nonlegislative_district(lat = 40, lon = -75.1)

# classes
expect_is(a, "tbl_df")
expect_is(b, "tbl_df")

# columns
expect_equal(names(a)[1], "address")
expect_equal(names(b)[1], "district_type")

# values
expect_equal(unique(a$district_type), "SCHOOL")
expect_equal(unique(b$district_type), "SCHOOL")

})
16 changes: 16 additions & 0 deletions tests/testthat/test-upcomingelections.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
context("get_upcoming_elections")

test_that("returns the correct", {

a <- get_upcoming_elections(is_state = TRUE, elections = 2)
b <- get_upcoming_elections(is_national = TRUE, elections = 5)

# classes
expect_is(a, "tbl_df")
expect_is(b, "tbl_df")

# columns
expect_equal(names(a)[1], "election_label")
expect_equal(names(b)[1], "election_label")

})

0 comments on commit 367568a

Please sign in to comment.