Skip to content

Commit e7b0a43

Browse files
committed
Produce an error message for deprecated behaviour
1 parent f6f54b5 commit e7b0a43

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

R/ANNUAL_STATISTICS.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
ANNUAL_STATISTICS <- function(hydat_path=NULL, STATION_NUMBER =NULL, PROV_TERR_STATE_LOC=NULL,
3838
start_year = "ALL", end_year = "ALL") {
3939

40+
if(!is.null(STATION_NUMBER) && STATION_NUMBER == "ALL"){
41+
stop("Deprecated behaviour.Omit the STATION_NUMBER = \"ALL\" argument. See ?ANNUAL_STATISTICS for examples.")
42+
}
43+
4044
if(is.null(hydat_path)){
4145
hydat_path = Sys.getenv("hydat")
4246
if(is.na(hydat_path)){

R/DLY_FLOWS.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737

3838
DLY_FLOWS <- function(hydat_path=NULL, STATION_NUMBER = NULL, PROV_TERR_STATE_LOC = NULL, start_date ="ALL", end_date = "ALL") {
3939

40+
if(!is.null(STATION_NUMBER) && STATION_NUMBER == "ALL"){
41+
stop("Deprecated behaviour.Omit the STATION_NUMBER = \"ALL\" argument. See ?DLY_FLOWS for examples.")
42+
}
43+
4044
if(start_date == "ALL" & end_date == "ALL"){
4145
message("No start and end dates specified. All dates available will be returned.")
4246
} else {

R/DLY_LEVELS.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535

3636
DLY_LEVELS <- function(hydat_path=NULL, STATION_NUMBER = NULL, PROV_TERR_STATE_LOC = NULL, start_date ="ALL", end_date = "ALL") {
3737

38+
if(!is.null(STATION_NUMBER) && STATION_NUMBER == "ALL"){
39+
stop("Deprecated behaviour.Omit the STATION_NUMBER = \"ALL\" argument. See ?DLY_LEVELS for examples.")
40+
}
41+
3842
if(start_date == "ALL" & end_date == "ALL"){
3943
message("No start and end dates specified. All dates available will be returned.")
4044
} else {

R/STATIONS.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141

4242
STATIONS <- function(hydat_path=NULL, STATION_NUMBER = NULL, PROV_TERR_STATE_LOC = NULL) {
4343

44-
#if(STATION_NUMBER == "ALL" | PROV_TERR_STATE_LOC == "ALL"){
45-
# stop("Specifying ALL for STATION_NUMBER OR PROV_TERR_STATE_LOC is deprecrated. See examples for usage.")
46-
#}
44+
if(!is.null(STATION_NUMBER) && STATION_NUMBER == "ALL"){
45+
stop("Deprecated behaviour.Omit the STATION_NUMBER = \"ALL\" argument. See ?download_realtime_dd for examples.")
46+
}
4747

4848
if(is.null(hydat_path)){
4949
hydat_path = Sys.getenv("hydat")

tests/testthat/test_DLY_FLOWS.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ test_that("DLY_FLOWS correctly parses leaps year",{
4141
start_date = "1988-02-29" ,
4242
end_date = "1988-02-29"), regexp = NA)
4343
})
44+
45+
46+
test_that("When DLY_FLOWS is ALL there is an error",{
47+
expect_error(DLY_FLOWS(STATION_NUMBER = "ALL"))
48+
})

tests/testthat/test_DLY_LEVELS.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ test_that("DLY_LEVELS correctly parses leaps year",{
4141
start_date = "1988-02-29" ,
4242
end_date = "1988-02-29"), regexp = NA)
4343
})
44+
45+
46+
test_that("When DLY_LEVELS is ALL there is an error",{
47+
expect_error(DLY_LEVELS(STATION_NUMBER = "ALL"))
48+
})

0 commit comments

Comments
 (0)