@@ -8,12 +8,11 @@ test_that("fetch and fetch_tbl", {
8
8
geo_values = " ca,fl"
9
9
)
10
10
11
- # This test compares the output of a tibble using fetch and fetch_tbl.
12
- with_mocked_bindings(
13
- {
14
- tbl_out <- epidata_call %> % fetch_tbl()
15
- out <- epidata_call %> % fetch()
16
- },
11
+ local_mocked_bindings(
12
+ request_impl = function (... ) NULL ,
13
+ .package = " epidatr"
14
+ )
15
+ local_mocked_bindings(
17
16
# RDS file generated with
18
17
# epidata_call %>%
19
18
# fetch_debug(format_type = "classic") %>%
@@ -22,6 +21,8 @@ test_that("fetch and fetch_tbl", {
22
21
.package = " httr"
23
22
)
24
23
24
+ tbl_out <- epidata_call %> % fetch_tbl()
25
+ out <- epidata_call %> % fetch()
25
26
expect_identical(out , tbl_out )
26
27
})
27
28
@@ -34,20 +35,27 @@ test_that("fetch_tbl warns on non-success", {
34
35
time_values = epirange(" 2020-06-01" , " 2020-08-01" ),
35
36
geo_values = " ca,fl"
36
37
)
37
- artificial_warning <- " * This is a warning with a leading asterisk and {braces} to make sure we don't have bulleting/glue bugs."
38
- debug_response_content_triplet <-
38
+
39
+ local_mocked_bindings(
40
+ request_impl = function (... ) NULL ,
41
+ .package = " epidatr"
42
+ )
43
+ local_mocked_bindings(
44
+ content = function (... ) NULL ,
45
+ .package = " httr"
46
+ )
47
+ artificial_warning <- " * This is a warning with a leading asterisk and {braces} to make sure we don't have bulleting/glue bugs."
48
+ debug_triplet <- readRDS(testthat :: test_path(" data/test-classic.rds" )) %> %
49
+ jsonlite :: fromJSON() %> %
50
+ `[[<-`(" message" , artificial_warning )
51
+ local_mocked_bindings(
39
52
# see generation code above
40
- readRDS(testthat :: test_path(" data/test-classic.rds" )) %> %
41
- jsonlite :: fromJSON() %> %
42
- `[[<-`(" message" , artificial_warning )
43
- with_mocked_bindings(
44
- {
45
- expect_warning(epidata_call %> % fetch_tbl(),
46
- regexp = paste0(" epidata warning: " , artificial_warning ),
47
- fixed = TRUE
48
- )
49
- },
50
- fromJSON = function (... ) debug_response_content_triplet ,
53
+ fromJSON = function (... ) debug_triplet ,
51
54
.package = " jsonlite"
52
55
)
56
+
57
+ expect_warning(epidata_call %> % fetch_tbl(),
58
+ regexp = paste0(" epidata warning: " , artificial_warning ),
59
+ fixed = TRUE
60
+ )
53
61
})
0 commit comments