Skip to content

Commit aae887d

Browse files
committed
test: updatng tests for new api version
1 parent 8d7f7d1 commit aae887d

File tree

1 file changed

+33
-39
lines changed

1 file changed

+33
-39
lines changed

tests/testthat/test-validate-args.R

+33-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# make sure deprecated warnings are always thrown- bypass 8 hour suppression
2-
rlang::local_options(lifecycle_verbosity = "warning")
1+
# We can't use expect_warning() without adding a dependency to rlang
2+
# to bypass 8 hour warning suppression
3+
# rlang::local_options(lifecycle_verbosity = "warning")
34

45
test_that("validate_args throws errors for all bad args", {
56
skip_on_cran()
@@ -13,36 +14,40 @@ test_that("validate_args throws errors for all bad args", {
1314
search_pv('{"patent_date":["1976-01-06"]}', method = "Post"),
1415
"method"
1516
)
16-
expect_warning(
17-
search_pv('{"patent_date":["1976-01-06"]}', subent_cnts = TRUE),
18-
class = "lifecycle_warning_deprecated"
19-
)
20-
expect_warning(
21-
search_pv('{"patent_date":["1976-01-06"]}', subent_cnts = 7),
22-
class = "lifecycle_warning_deprecated"
23-
)
24-
expect_warning(
25-
search_pv('{"patent_date":["1976-01-06"]}', mtchd_subent_only = NULL),
26-
class = "lifecycle_warning_deprecated"
27-
)
28-
expect_warning(
29-
search_pv('{"patent_date":["1976-01-06"]}', error_browser = "chrome"),
30-
class = "lifecycle_warning_deprecated"
31-
)
17+
suppressWarnings({
18+
result <- search_pv('{"patent_date":["1976-01-06"]}', subent_cnts = TRUE)
19+
# class = "lifecycle_warning_deprecated"
20+
expect_gt(result$query_results$total_hits, 0)
21+
})
22+
suppressWarnings({
23+
result <- search_pv('{"patent_date":["1976-01-06"]}', subent_cnts = 7)
24+
# class = "lifecycle_warning_deprecated"
25+
expect_gt(result$query_results$total_hits, 0)
26+
})
27+
suppressWarnings({
28+
result <- search_pv('{"patent_date":["1976-01-06"]}', mtchd_subent_only = NULL)
29+
# class = "lifecycle_warning_deprecated"
30+
expect_gt(result$query_results$total_hits, 0)
31+
})
32+
suppressWarnings({
33+
result <- search_pv('{"patent_date":["1976-01-06"]}', error_browser = "chrome")
34+
#class = "lifecycle_warning_deprecated"
35+
expect_gt(result$query_results$total_hits, 0)
36+
})
3237

3338
per_page <- 17
34-
expect_warning(
35-
results <- search_pv('{"patent_date":["1976-01-06"]}', per_page = per_page),
36-
class = "lifecycle_warning_deprecated"
37-
)
39+
suppressWarnings({
40+
results <- search_pv('{"patent_date":["1976-01-06"]}', per_page = per_page)
3841

39-
# make sure the size attribute was set from the per_page parameter
40-
expect_equal(per_page, nrow(results$data$patents))
42+
# make sure the size attribute was set from the per_page parameter
43+
expect_equal(per_page, nrow(results$data$patents))
44+
})
4145

42-
expect_warning(
43-
search_pv('{"patent_date":["1976-01-06"]}', page = 2),
44-
class = "lifecycle_warning_deprecated" # unsupported page parameter
45-
)
46+
suppressWarnings({
47+
result <- search_pv('{"patent_date":["1976-01-06"]}', page = 2)
48+
# class = "lifecycle_warning_deprecated" # unsupported page parameter
49+
expect_gt(result$query_results$total_hits, 0)
50+
})
4651
expect_error(
4752
search_pv(
4853
'{"patent_date":["1976-01-06"]}',
@@ -58,17 +63,6 @@ test_that("validate_args throws errors for all bad args", {
5863
)
5964
})
6065

61-
test_that("per_page parameter warns but still works", {
62-
skip_on_cran()
63-
64-
expect_warning(
65-
results <- search_pv('{"patent_date":["1976-01-06"]}', per_page = 23),
66-
class = "lifecycle_warning_deprecated"
67-
)
68-
69-
expect_equal(23, nrow(results$data$patents))
70-
})
71-
7266
test_that("group names can be requested as fields via new API shorthand", {
7367
skip_on_cran()
7468

0 commit comments

Comments
 (0)