Skip to content

Commit

Permalink
updating tests to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
robbriers committed Feb 8, 2019
1 parent 80a1554 commit 9315786
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
3 changes: 0 additions & 3 deletions appveyor.yml

This file was deleted.

9 changes: 8 additions & 1 deletion tests/testthat/test-status_plot.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
library(cde)
context("status_plot")
context("testing status plots")

test_that("invalid column specified returns an error", {
# retrieve data for column "Aardvark"
Expand Down Expand Up @@ -35,3 +35,10 @@ test_that("end date outside available range returns an error", {
# retrieve data for years outside possible range
expect_error(status_plot("Avon Hampshire", "MC", startyr=2012, endyr=2018))
})

test_that("function returns a vector of given length", {
# plot for Avon Warwickshire MC chemical status
test_plot<-status_plot("Avon Warwickshire", "MC", level="Chemical")
# check that the vector has a length of 8
expect_true(length(test_plot)== 8)
})
6 changes: 2 additions & 4 deletions tests/testthat/test-wfd_status.r
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
library(cde)
context("wfd_status")
context("testing wfd status downloads")

test_that("wfd_status returns a dataframe", {
# retrieve data for specific waterbody
testframe<-wfd_status("GB520804714300", "WBID")
# check that it outputs a dataframe object
expect_true(is.data.frame(testframe))

})

test_that("dimensions of dataframe are as expected", {
# retrieve data for Avon Warwickshire MC
test_mc_avon<-wfd_status("Avon Warwickshire", "MC")
# check that the dimensions are 516 rows, 17 cols
# check that the dimensions are 516 rows, 18 cols
expect_true(all(dim(test_mc_avon)== c(594, 18)))

})

test_that("invalid column specified returns an error", {
Expand Down
8 changes: 6 additions & 2 deletions tests/testthat/test_download_functions.r
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ test_that("download_ea returns a dataframe", {
testframe<-download_ea("GB520804714300", "WBID")
# check that it outputs a dataframe object
expect_true(is.data.frame(testframe))

})


Expand All @@ -16,5 +15,10 @@ test_that("zip_download returns a dataframe", {
testframe<-zip_download(test_url)
# check that it outputs a dataframe object
expect_true(is.data.frame(testframe))

})


test_that("tryingto download a nonsense column returns an error", {
# retrieve data for impossible year range
expect_error(download_ea("GB520804714300", "Aardvark"))
})

0 comments on commit 9315786

Please sign in to comment.