Skip to content

Commit

Permalink
add time_downloaded as attribute to bcdc_sf (#206)
Browse files Browse the repository at this point in the history
* add time_downloaded as attribute to bcdc_sf

* add some attribute tests

* update NEWS

* check if time_downloaded in POSIXlt
  • Loading branch information
boshek authored Jun 2, 2020
1 parent bc9e97e commit 4ba6cef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
* Provide `as_tibble` as an alias for `collect` in line with `dbplyr` behaviour (#166)
* When reading in excel files, `bcdc_get_data` now outputs a messages indicating the presence and names of any sheets (#190)
* `bcdc_get_data()` & `bcdc_query_geodata()` will now work with full B.C. data catalogue url including resource (#125, #196)
* `bcdc_sf` objects now have an `time_downloaded` attribute

### BUG FIXES
* Fix `select`, `filter` and `mutate` roxygen so that bcdata specific documentation to these methods is available
* Add tests for attributes

# bcdata 0.1.2

Expand Down
2 changes: 1 addition & 1 deletion R/utils-classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ as.bcdc_sf <- function(x, query_list, url, full_url) {
structure(x,
class = c("bcdc_sf", setdiff(class(x), "bcdc_sf")),
query_list = query_list,
url = url, full_url = full_url)
url = url, full_url = full_url, time_downloaded = Sys.time())
}


Expand Down
7 changes: 6 additions & 1 deletion tests/testthat/test-query-geodata-collect.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ test_that("collect() returns a bcdc_sf object",{
expect_s3_class(sf_obj, "bcdc_sf")
})

test_that("bcdc_sf objects have a url as an attributes",{
test_that("bcdc_sf objects has attributes",{
skip_on_cran()
skip_if_net_down()
sf_obj <- bcdc_query_geodata("76b1b7a3-2112-4444-857a-afccf7b20da8") %>%
filter(LOCALITY == "Terrace") %>%
select(LATITUDE) %>%
collect()

expect_identical(names(attributes(sf_obj)),
c("names", "row.names", "class", "sf_column", "agr", "query_list",
"url", "full_url", "time_downloaded"))
expect_true(nzchar(attributes(sf_obj)$url))
expect_true(nzchar(attributes(sf_obj)$full_url))
expect_is(attributes(sf_obj)$time_downloaded, "POSIXt")
})

0 comments on commit 4ba6cef

Please sign in to comment.