|
1 | 1 |
|
2 | 2 | # Tests from the other files in this directory that are masking API errors
|
3 |
| -# This file will be submitted to the API team |
| 3 | +# This file was submitted to the API team as PVS-1125 |
4 | 4 |
|
5 | 5 | eps <- (get_endpoints())
|
6 | 6 |
|
7 | 7 | add_base_url <- function(x) {
|
8 | 8 | paste0("https://search.patentsview.org/api/v1/", x)
|
9 | 9 | }
|
10 | 10 |
|
| 11 | +test_that("there is case sensitivity on string equals", { |
| 12 | + skip_on_cran() |
| 13 | + skip_on_ci() |
| 14 | + |
| 15 | + # reported to the API team PVS-1147 |
| 16 | + # not sure if this is a bug or feature - original API was case insensitive |
| 17 | + # using both forms of equals, impied and explicit |
| 18 | + |
| 19 | + assignee <- "Johnson & Johnson International" |
| 20 | + query1 <- sprintf('{"assignee_organization": \"%s\"}', assignee) |
| 21 | + a <- search_pv(query1, endpoint = "assignee") |
| 22 | + query2 <- qry_funs$eq(assignee_organization = assignee) |
| 23 | + b <- search_pv(query2, endpoint = "assignee") |
| 24 | + expect_equal(a$query_results$total_hits, 1) |
| 25 | + expect_equal(b$query_results$total_hits, 1) |
| 26 | + |
| 27 | + assignee <- tolower(assignee) |
| 28 | + query1 <- sprintf('{"assignee_organization": \"%s\"}', assignee) |
| 29 | + c <- search_pv(query1, endpoint = "assignee") |
| 30 | + query2 <- qry_funs$eq(assignee_organization = assignee) |
| 31 | + d <- search_pv(query2, endpoint = "assignee") |
| 32 | + expect_equal(c$query_results$total_hits, 0) |
| 33 | + expect_equal(d$query_results$total_hits, 0) |
| 34 | +}) |
| 35 | + |
| 36 | +test_that("string vs text operators behave differently", { |
| 37 | + # # reported to the API team PVS-1147 |
| 38 | + query <- qry_funs$begins(assignee_organization = "johnson") |
| 39 | + a <- search_pv(query, endpoint = "assignee") |
| 40 | + |
| 41 | + query <- qry_funs$text_any(assignee_organization = "johnson") |
| 42 | + b <- search_pv(query, endpoint = "assignee") |
| 43 | + |
| 44 | + expect_failure( |
| 45 | + expect_equal(a$query_results$total_hits, b$query_results$total_hits) |
| 46 | + ) |
| 47 | +}) |
| 48 | + |
| 49 | +test_that("the otherreferences endpoint is still broken", { |
| 50 | + skip_on_cran() |
| 51 | + skip_on_ci() |
| 52 | + |
| 53 | + query <- '{"_gte":{"patent_id":"1"}}' |
| 54 | + |
| 55 | + # reported to the API team PVS-1109 |
| 56 | + # otherreferences is listed in the OpenAPI object. It isn't in get_endpoints() |
| 57 | + # as it only throws errors. |
| 58 | + # This test will fail when the API does not throw an error |
| 59 | + |
| 60 | + # Currently throws a 404 |
| 61 | + expect_error( |
| 62 | + result <- retrieve_linked_data(add_base_url(paste0("patent/otherreference/?q=", query))) |
| 63 | + ) |
| 64 | +}) |
| 65 | + |
| 66 | + |
11 | 67 | # from test-api-returns.R
|
12 | 68 | test_that("API returns all requested groups", {
|
13 | 69 | skip_on_cran()
|
@@ -98,8 +154,7 @@ test_that("API returns all requested groups", {
|
98 | 154 | # in an entity matching the plural form of the unnested endpoint
|
99 | 155 | expected_groups <- replace(expected_groups, expected_groups == "", to_plural(x))
|
100 | 156 |
|
101 |
| - # better way to do this? want to expect_set_not_equal |
102 |
| - expect_error( |
| 157 | + expect_failure( |
103 | 158 | expect_setequal(actual_groups, expected_groups)
|
104 | 159 | )
|
105 | 160 | })
|
|
0 commit comments