From 21f2424895e7189daa5fd8ff95cba9977c678dac Mon Sep 17 00:00:00 2001 From: csills01 Date: Thu, 14 Nov 2024 17:31:22 +0000 Subject: [PATCH 1/4] don`t retry on 409 status --- R/phs_GET.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/phs_GET.R b/R/phs_GET.R index 0af0702..2918784 100644 --- a/R/phs_GET.R +++ b/R/phs_GET.R @@ -11,6 +11,7 @@ phs_GET <- function(action, query, verbose = FALSE) { response <- httr::RETRY( verb = "GET", url = url, + terminate_on = c(409), user_agent = httr::user_agent( "https://github.com/Public-Health-Scotland/phsmethods" ) From 52d496499068bbf3ab84e0e5d8d20e6a2c76b5de Mon Sep 17 00:00:00 2001 From: csills01 Date: Thu, 14 Nov 2024 17:46:13 +0000 Subject: [PATCH 2/4] correct user agent --- R/phs_GET.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/phs_GET.R b/R/phs_GET.R index 2918784..8a89c6c 100644 --- a/R/phs_GET.R +++ b/R/phs_GET.R @@ -13,7 +13,7 @@ phs_GET <- function(action, query, verbose = FALSE) { url = url, terminate_on = c(409), user_agent = httr::user_agent( - "https://github.com/Public-Health-Scotland/phsmethods" + "phsopendata (https://github.com/Public-Health-Scotland/phsopendata)" ) ) From 822e74258de9fdfed82e536685e15f53f697d8af Mon Sep 17 00:00:00 2001 From: csills01 Date: Mon, 18 Nov 2024 09:49:04 +0000 Subject: [PATCH 3/4] add test for col_select error --- tests/testthat/test-get_dataset.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/testthat/test-get_dataset.R b/tests/testthat/test-get_dataset.R index 34ddbca..3b9b9d1 100644 --- a/tests/testthat/test-get_dataset.R +++ b/tests/testthat/test-get_dataset.R @@ -44,3 +44,9 @@ test_that("get_dataset errors properly", { regexp = "Did you mean .+?gp-practice-populations.+?\\?" ) }) + +test_that("get_dataset filters error properly", { + expect_error(get_dataset("gp-practice-populations", col_select = "Non-existent column"), + regexp = "API error" + ) +}) From d8a4263bad6deb84a67e7b3986fbe98755a8e76f Mon Sep 17 00:00:00 2001 From: csillasch Date: Mon, 18 Nov 2024 09:50:28 +0000 Subject: [PATCH 4/4] Style code (GHA) --- tests/testthat/test-get_dataset.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-get_dataset.R b/tests/testthat/test-get_dataset.R index 3b9b9d1..4bf1139 100644 --- a/tests/testthat/test-get_dataset.R +++ b/tests/testthat/test-get_dataset.R @@ -47,6 +47,6 @@ test_that("get_dataset errors properly", { test_that("get_dataset filters error properly", { expect_error(get_dataset("gp-practice-populations", col_select = "Non-existent column"), - regexp = "API error" + regexp = "API error" ) })