From 1c1eba51d900d2846a31e2739935fd6ccf6c182f Mon Sep 17 00:00:00 2001 From: Russ Allen Date: Sun, 22 Dec 2024 17:11:11 -0600 Subject: [PATCH] added skip_on_ci()s --- tests/testthat/test-api-bugs.R | 9 +++++++++ tests/testthat/test-cast-pv-data.R | 2 ++ tests/testthat/test-check-query.R | 4 ++++ tests/testthat/test-get-fields.R | 2 ++ tests/testthat/test-print.R | 2 ++ tests/testthat/test-query-dsl.R | 3 +++ tests/testthat/test-search-pv.R | 17 +++++++++++++++++ tests/testthat/test-unnest-pv-data.R | 2 ++ tests/testthat/test-utils.R | 1 + tests/testthat/test-validate-args.R | 2 ++ 10 files changed, 44 insertions(+) diff --git a/tests/testthat/test-api-bugs.R b/tests/testthat/test-api-bugs.R index 2e5f222..a7e31df 100644 --- a/tests/testthat/test-api-bugs.R +++ b/tests/testthat/test-api-bugs.R @@ -80,6 +80,7 @@ test_that("there is case sensitivity on string equals", { test_that("string vs text operators behave differently", { skip_on_cran() + skip_on_ci() # # reported to the API team PVS-1147 query <- qry_funs$begins(assignee_organization = "johnson") @@ -161,6 +162,7 @@ eps <- (get_endpoints()) test_that("We can call all the legitimate HATEOAS endpoints", { skip_on_cran() + skip_on_ci() # these currently throw Error: Internal Server Error broken_single_item_queries <- c( @@ -182,6 +184,7 @@ test_that("We can call all the legitimate HATEOAS endpoints", { test_that("individual fields are still broken", { skip_on_cran() + skip_on_ci() # Sample fields that cause 500 errors when requested by themselves. # Some don't throw errors when included in get_fields() but they do if @@ -207,6 +210,7 @@ test_that("individual fields are still broken", { test_that("we can't sort by all fields", { skip_on_cran() + skip_on_ci() # PVS-1377 sorts_to_try <- c( @@ -250,6 +254,7 @@ test_that("we can't sort by all fields", { test_that("withdrawn patents are still present in the database", { skip_on_cran() + skip_on_ci() # PVS-1342 Underlying data issues # There are 8,000 patents that were in the bulk xml files patentsiew is based on. @@ -271,6 +276,7 @@ test_that("withdrawn patents are still present in the database", { test_that("missing patents are still missing", { skip_on_cran() + skip_on_ci() # PVS-1342 Underlying data issues # There are around 300 patents that aren't in the bulk xml files patentsiew is based on. @@ -291,6 +297,7 @@ test_that("missing patents are still missing", { test_that("we can't explicitly request assignee_ or inventor_years.num_patents", { skip_on_cran() + skip_on_ci() bad_eps <- c( "assignee", # Invalid field: assignee_years.num_patents. assignee_years is not a nested field @@ -313,6 +320,7 @@ test_that("we can't explicitly request assignee_ or inventor_years.num_patents", test_that("uspcs aren't right", { skip_on_cran() + skip_on_ci() # PVS-1615 @@ -333,6 +341,7 @@ test_that("uspcs aren't right", { test_that("endpoints are still broken", { skip_on_cran() + skip_on_ci() # this will fail when the api is fixed broken_endpoints <- c( diff --git a/tests/testthat/test-cast-pv-data.R b/tests/testthat/test-cast-pv-data.R index efcb1c5..63efe59 100644 --- a/tests/testthat/test-cast-pv-data.R +++ b/tests/testthat/test-cast-pv-data.R @@ -1,5 +1,6 @@ test_that("cast_pv_data casts patent fields as expected", { skip_on_cran() + skip_on_ci() pv_out <- search_pv( query = '{"patent_id":"5116621"}', fields = get_fields("patent") @@ -58,6 +59,7 @@ test_that("cast_pv_data casts assignee fields as expected", { test_that("we can cast a bool", { skip_on_cran() + skip_on_ci() # TODO(any): remove when the API returns this as a boolean fields <- c("rule_47_flag") diff --git a/tests/testthat/test-check-query.R b/tests/testthat/test-check-query.R index 8f84603..5b1bff8 100644 --- a/tests/testthat/test-check-query.R +++ b/tests/testthat/test-check-query.R @@ -1,6 +1,7 @@ test_that("errors are thrown on invalid queries", { skip_on_cran() + skip_on_ci() expect_error( search_pv(qry_funs$eq("shoe_size" = 11.5)), @@ -66,6 +67,7 @@ test_that("errors are thrown on invalid queries", { test_that("a valid nested field can be queried", { skip_on_cran() + skip_on_ci() results <- search_pv(qry_funs$eq("application.rule_47_flag" = FALSE)) @@ -74,6 +76,7 @@ test_that("a valid nested field can be queried", { test_that("the _eq message is thrown when appropriate", { skip_on_cran() + skip_on_ci() expect_message( search_pv(list(patent_date = "2007-03-06")), @@ -83,6 +86,7 @@ test_that("the _eq message is thrown when appropriate", { test_that("a query with an and operator returns results", { skip_on_cran() + skip_on_ci() patents_query <- with_qfuns( diff --git a/tests/testthat/test-get-fields.R b/tests/testthat/test-get-fields.R index 7eb316f..777569a 100644 --- a/tests/testthat/test-get-fields.R +++ b/tests/testthat/test-get-fields.R @@ -1,5 +1,6 @@ test_that("get_fields works as expected", { skip_on_cran() + skip_on_ci() expect_error( get_fields("bogus endpoint"), @@ -23,6 +24,7 @@ test_that("get_fields works as expected", { test_that("the endpoints are stable", { skip_on_cran() + skip_on_ci() # quick check of the endpoints - useful after an api update. We run fieldsdf.R # and do a build. This test would fail if an endpoint was added, moved or deleted diff --git a/tests/testthat/test-print.R b/tests/testthat/test-print.R index cc0d5f6..d8d7d01 100644 --- a/tests/testthat/test-print.R +++ b/tests/testthat/test-print.R @@ -1,5 +1,6 @@ test_that("We can print the returns from all endpoints ", { skip_on_cran() + skip_on_ci() eps <- get_endpoints() bad_eps <- c("cpc_subclass", "uspc_subclass", "uspc_mainclass", "wipo") @@ -20,6 +21,7 @@ test_that("We can print the returns from all endpoints ", { test_that("we can print a query, its request, and unnested data", { skip_on_cran() + skip_on_ci() x <- "patent" q <- qry_funs$eq(patent_id = "11530080") diff --git a/tests/testthat/test-query-dsl.R b/tests/testthat/test-query-dsl.R index 840ed78..2f44b3a 100644 --- a/tests/testthat/test-query-dsl.R +++ b/tests/testthat/test-query-dsl.R @@ -1,5 +1,6 @@ test_that("between works as expected", { skip_on_cran() + skip_on_ci() query <- qry_funs$in_range(patent_date = c("1976-01-06", "1976-01-13")) @@ -10,6 +11,7 @@ test_that("between works as expected", { test_that("with_qfuns() works as advertised", { skip_on_cran() # wouldn't necessarily have to skip! + skip_on_ci() # wouldn't necessarily have to skip! a <- with_qfuns( and( @@ -28,6 +30,7 @@ test_that("with_qfuns() works as advertised", { test_that("argument check works on in_range", { skip_on_cran() # wouldn't necessarily have to skip! + skip_on_ci() # wouldn't necessarily have to skip! expect_error( qq <- qry_funs$in_range("patent_id", c("10000000", "10000002")), diff --git a/tests/testthat/test-search-pv.R b/tests/testthat/test-search-pv.R index 494c330..0946f2a 100644 --- a/tests/testthat/test-search-pv.R +++ b/tests/testthat/test-search-pv.R @@ -7,6 +7,7 @@ endpoints <- get_endpoints() test_that("API returns expected df names for all endpoints", { skip_on_cran() + skip_on_ci() broken_endpoints <- c( "cpc_subclass", @@ -36,6 +37,7 @@ test_that("API returns expected df names for all endpoints", { test_that("DSL-based query returns expected results", { skip_on_cran() + skip_on_ci() query <- with_qfuns( and( @@ -52,6 +54,7 @@ test_that("DSL-based query returns expected results", { test_that("You can download up to 9,000+ records", { skip_on_cran() + skip_on_ci() # Should return 9,000+ rows query <- with_qfuns( @@ -66,6 +69,7 @@ test_that("You can download up to 9,000+ records", { test_that("search_pv can pull all fields for all endpoints", { skip_on_cran() + skip_on_ci() troubled_endpoints <- c( "cpc_subclass", "location", @@ -87,6 +91,7 @@ test_that("search_pv can pull all fields for all endpoints", { test_that("Sort option works as expected", { skip_on_cran() + skip_on_ci() out <- search_pv( qry_funs$neq(assignee_id = ""), @@ -101,6 +106,7 @@ test_that("Sort option works as expected", { test_that("search_pv properly URL encodes queries", { skip_on_cran() + skip_on_ci() # Covers https://github.com/ropensci/patentsview/issues/24 # need to use the assignee endpoint now @@ -129,6 +135,7 @@ test_that("search_pv properly URL encodes queries", { test_that("We won't expose the user's patentsview API key to random websites", { skip_on_cran() + skip_on_ci() # We will try to call the api that tells us who is currently in space in_space_now_url <- "http://api.open-notify.org/astros.json" @@ -138,6 +145,7 @@ test_that("We won't expose the user's patentsview API key to random websites", { test_that("We can call all the legitimate HATEOAS endpoints", { skip_on_cran() + skip_on_ci() single_item_queries <- c( "cpc_subclass/A01B/", @@ -207,6 +215,7 @@ test_that("We can call all the legitimate HATEOAS endpoints", { test_that("posts and gets return the same data", { skip_on_cran() + skip_on_ci() bad_eps <- c( "cpc_subclass" @@ -247,6 +256,7 @@ test_that("posts and gets return the same data", { test_that("nested shorthand produces the same results as fully qualified ones", { skip_on_cran() + skip_on_ci() # the API now allows a shorthand in the fields/f: parameter # just the group name will retrieve all that group's attributes @@ -264,6 +274,7 @@ test_that("nested shorthand produces the same results as fully qualified ones", test_that("the 'after' parameter works properly", { skip_on_cran() + skip_on_ci() sort <- c("patent_id" = "asc") big_query <- qry_funs$eq(patent_date = "2000-01-04") # 3003 total_hits @@ -300,6 +311,7 @@ test_that("the 'after' parameter works properly", { test_that("the documentation and Swagger UI URLs work properly", { skip_on_cran() + skip_on_ci() documentation_url <- 'https://search.patentsview.org/api/v1/patent/?q={"_text_any":{"patent_title":"COBOL cotton gin"}}&s=[{"patent_id": "asc" }]&o={"size":50}&f=["inventors.inventor_name_last","patent_id","patent_date","patent_title"]' @@ -316,6 +328,7 @@ test_that("the documentation and Swagger UI URLs work properly", { test_that("an error occurs if all_pages is TRUE and there aren't any results", { skip_on_cran() + skip_on_ci() too_early <- qry_funs$lt(patent_date = "1976-01-01") @@ -332,6 +345,7 @@ test_that("an error occurs if all_pages is TRUE and there aren't any results", { test_that("we can retrieve all_pages = TRUE without specifiying fields", { skip_on_cran() + skip_on_ci() query <- qry_funs$eq(patent_date = "1976-01-06") sort <- c("patent_type" = "asc", "patent_id" = "asc") @@ -348,6 +362,7 @@ test_that("we can retrieve all_pages = TRUE without specifiying fields", { # the two responses match, then we've correctly handled throttling errors. test_that("Throttled requests are automatically retried", { skip_on_cran() + skip_on_ci() res <- search_pv('{"_gte":{"patent_date":"2007-01-04"}}', size = 50) patent_ids <- res$data$patents$patent_id @@ -421,6 +436,7 @@ test_that("Throttled requests are automatically retried", { test_that("we can sort on an unrequested field across page boundaries", { skip_on_cran() + skip_on_ci() # total_hits = 5,352 query <- qry_funs$in_range(patent_date = c("1976-01-01", "1976-01-31")) @@ -451,6 +467,7 @@ test_that("we can sort on an unrequested field across page boundaries", { test_that("sort works across page boundaries", { skip_on_cran() + skip_on_ci() sort <- c("patent_type" = "desc", "patent_id" = "desc") results <- search_pv( diff --git a/tests/testthat/test-unnest-pv-data.R b/tests/testthat/test-unnest-pv-data.R index afe0fcb..1d9e1ad 100644 --- a/tests/testthat/test-unnest-pv-data.R +++ b/tests/testthat/test-unnest-pv-data.R @@ -2,6 +2,7 @@ eps <- get_endpoints() test_that("we can unnest all entities", { skip_on_cran() + skip_on_ci() # TODO(any): add back fields = get_fields(x) # API throws 500s if some nested fields are included @@ -48,6 +49,7 @@ test_that("we can unnest all entities", { test_that("endpoint's pks match their entity's pks", { skip_on_cran() + skip_on_ci() # the overloaded_entities endpoints return the same entity, rel_app_texts, # so we can't determine the endpoint from the entity like we can diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index f38200b..fcfaca1 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,5 +1,6 @@ test_that("we can cast the endpoints that return the same entity", { skip_on_cran() + skip_on_ci() endpoints <- c("patent/rel_app_text", "publication/rel_app_text") diff --git a/tests/testthat/test-validate-args.R b/tests/testthat/test-validate-args.R index 88e0e0e..5f0208b 100644 --- a/tests/testthat/test-validate-args.R +++ b/tests/testthat/test-validate-args.R @@ -4,6 +4,7 @@ test_that("validate_args throws errors for all bad args", { skip_on_cran() + skip_on_ci() # requesting the old plural endpoint should now throw an error expect_error( @@ -65,6 +66,7 @@ test_that("validate_args throws errors for all bad args", { test_that("group names can be requested as fields via new API shorthand", { skip_on_cran() + skip_on_ci() endpoint <- "patent" shorthand <- get_fields("patent", groups=c("application"))