Skip to content

Commit

Permalink
streamline tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mps9506 committed Aug 5, 2018
1 parent 38dfcc4 commit 0d0980d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
9 changes: 6 additions & 3 deletions tests/testthat/test-expected_errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ context("core functions return expected errors")

test_that("core functions returns expected errors", {
expect_error(echoAirGetFacilityInfo(), "No valid arguments supplied")
expect_error(echoAirGetFacilityInfo(p_pid = "NC0000003706500036", output = "JSON"))
expect_error(echoGetReports(program = "sdw"))
expect_error(echoSDWGetSystems())
expect_error(echoAirGetFacilityInfo(p_pid = "NC0000003706500036", output = "JSON"),
"output argument = JSON, when it should be either 'df' or 'sf'")
expect_error(echoGetReports(program = "sdw"),
"the argument 'program' must be specified as one of 'caa' or 'cwa'")
expect_error(echoSDWGetSystems(),
"No valid arguments supplied")

#echoWaterGetFacilityInto returns error when no args uses, or incorrect output specified
expect_error(echoWaterGetFacilityInfo(), "No valid arguments supplied")
Expand Down
63 changes: 29 additions & 34 deletions tests/testthat/test-expected_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,52 @@ test_that("core functions return tbl_df", {

skip_on_cran()

x <- echoAirGetFacilityInfo(p_pid = "NC0000003706500036", output = "df",
qcolumns = "3,4,5")
expect_s3_class(x, "tbl_df")
expect_is(echoAirGetFacilityInfo(p_pid = "NC0000003706500036", output = "df",
qcolumns = "3,4,5"), "tbl_df")

x <- echoSDWGetMeta(verbose = FALSE)
expect_s3_class(x, "tbl_df")
expect_is(echoSDWGetMeta(verbose = FALSE), "tbl_df")

x <- echoGetCAAPR(p_id = '110000350174')
expect_s3_class(x, "tbl_df")
expect_is(echoGetCAAPR(p_id = '110000350174'), "tbl_df")

x <- echoGetEffluent(p_id = "tx0119407", parameter_code = "50050")
expect_s3_class(x, "tbl_df")
expect_is(echoGetEffluent(p_id = "tx0119407", parameter_code = "50050"),
"tbl_df")

x <- echoGetReports(program = "caa",
p_id = '110000350174',
verbose = FALSE)
expect_s3_class(x, "tbl_df")
expect_is(echoGetReports(program = "caa",
p_id = '110000350174',
verbose = FALSE),
"tbl_df")

x <- echoGetReports(program = "cwa",
p_id = "tx0119407",
parameter_code = "50050",
verbose = FALSE)
expect_s3_class(x, "tbl_df")
expect_is(echoGetReports(program = "cwa",
p_id = "tx0119407",
parameter_code = "50050",
verbose = FALSE),
"tbl_df")

x <- echoSDWGetSystems(p_co = "Brazos", p_st = "tx", verbose = FALSE)
expect_s3_class(x, "tbl_df")
expect_is(echoSDWGetSystems(p_co = "Brazos", p_st = "tx", verbose = FALSE),
"tbl_df")

x <- echoWaterGetFacilityInfo(p_pid = "ALR040033", output = "df",
qcolumns = "3,4,5")
expect_s3_class(x, "tbl_df")
expect_is(echoWaterGetFacilityInfo(p_pid = "ALR040033", output = "df",
qcolumns = "3,4,5"),
"tbl_df")

x <- echoWaterGetParams(term = "Oxygen, dissolved")
expect_s3_class(x, "tbl_df")
expect_is(echoWaterGetParams(term = "Oxygen, dissolved"),
"tbl_df")

x <- echoWaterGetParams(code = "00300")
expect_s3_class(x, "tbl_df")
expect_is(echoWaterGetParams(code = "00300"), "tbl_df")

x <- echoGetFacilities(program = "cwa", p_pid = "ALR040033", output = "df",
qcolumns = "1,2,3")
expect_s3_class(x, "tbl_df")
expect_is(echoGetFacilities(program = "cwa", p_pid = "ALR040033", output = "df",
qcolumns = "1,2,3"), "tbl_df")

})

test_that("core functions return sf", {

skip_on_cran()

x <- echoAirGetFacilityInfo(p_pid = "NC0000003706500036", output = "sf", verbose = FALSE)
expect_s3_class(x, "sf")
expect_is(echoAirGetFacilityInfo(p_pid = "NC0000003706500036", output = "sf", verbose = FALSE),
"sf")

x <- echoWaterGetFacilityInfo(p_pid = "ALR040033", output = "sf")
expect_s3_class(x, "sf")
expect_is(echoWaterGetFacilityInfo(p_pid = "ALR040033", output = "sf"),
"sf")

})

0 comments on commit 0d0980d

Please sign in to comment.