Skip to content

Commit

Permalink
fix tests for downloading non-existent dates
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jul 13, 2017
1 parent 486bbc2 commit 2f51583
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
0.0.3
===================
- Minor changes only
- More informative messages when data for specified dates not available

0.0.2
===================
Expand Down
2 changes: 1 addition & 1 deletion R/dl-bikedata.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ dl_bikedata <- function (city, data_dir = tempdir(), dates = NULL,
dl_files <- get_bike_files (city)
files <- file.path (data_dir, basename (dl_files))

dates_exist <- TRUE # set to F is requested dates do not exist
if (is.null (dates))
indx <- which (!file.exists (files))
else
{
dates <- bike_convert_dates (dates) %>%
expand_dates_to_range %>%
convert_dates_to_filenames (city = city)
dates_exist <- TRUE
indx <- which (grepl (paste (dates, collapse = "|"), files))
if (length (indx) == 0)
dates_exist <- FALSE
Expand Down
2 changes: 1 addition & 1 deletion R/store-bikedata.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ store_bikedata <- function (bikedb, city, data_dir, create_index = TRUE,
if (missing (data_dir))
{
if (!quiet)
message ('Downloading data for ', city)
message ('Checking data for ', city)
for (ci in city)
dl_bikedata (city = ci, dates = dates, quiet = quiet)
data_dir <- tempdir ()
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-download-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test_that ('dl_bikedata dc', {
expect_message (dl_bikedata (city = 'dc',
data_dir = tempdir (),
dates = d),
'All data files already exist')
'There are no dc files for those dates')
chk <- tryCatch (file.remove (files),
warning = function (w) NULL,
error = function (e) NULL)
Expand Down

0 comments on commit 2f51583

Please sign in to comment.