Skip to content

Commit

Permalink
added skip_on_ci()s
Browse files Browse the repository at this point in the history
  • Loading branch information
mustberuss committed Dec 22, 2024
1 parent aae887d commit 1c1eba5
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/testthat/test-api-bugs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-cast-pv-data.R
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-check-query.R
Original file line number Diff line number Diff line change
@@ -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)),
Expand Down Expand Up @@ -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))

Expand All @@ -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")),
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-get-fields.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("get_fields works as expected", {
skip_on_cran()
skip_on_ci()

expect_error(
get_fields("bogus endpoint"),
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-print.R
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-query-dsl.R
Original file line number Diff line number Diff line change
@@ -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"))

Expand All @@ -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(
Expand All @@ -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")),
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-search-pv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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",
Expand All @@ -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 = ""),
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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/",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"]'
Expand All @@ -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")

Expand All @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-unnest-pv-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-validate-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit 1c1eba5

Please sign in to comment.