@@ -1491,6 +1491,10 @@ testthat::test_that(
14911491 " with expected columns on valid XML"
14921492 ),
14931493 code = {
1494+ testthat :: skip_if_not(
1495+ condition = there_is_provider(),
1496+ message = " The Entso-e API cannot be reached"
1497+ )
14941498 xml_fixture <- readLines(
14951499 con = testthat :: test_path(" fixtures" , " get_allocated_eic_min.xml" ),
14961500 encoding = " UTF-8"
@@ -1537,6 +1541,10 @@ testthat::test_that(
15371541 desc =
15381542 " get_all_allocated_eic() joins doc_status from message_types correctly" ,
15391543 code = {
1544+ testthat :: skip_if_not(
1545+ condition = there_is_provider(),
1546+ message = " The Entso-e API cannot be reached"
1547+ )
15401548 xml_fixture <- readLines(
15411549 con = testthat :: test_path(" fixtures" , " get_allocated_eic_min.xml" ),
15421550 encoding = " UTF-8"
@@ -1567,6 +1575,10 @@ testthat::test_that(
15671575 desc =
15681576 " get_all_allocated_eic() stops with HTTP error message and request URL" ,
15691577 code = {
1578+ testthat :: skip_if_not(
1579+ condition = there_is_provider(),
1580+ message = " The Entso-e API cannot be reached"
1581+ )
15701582 httr2 :: local_mocked_responses(
15711583 mock = function (req ) {
15721584 httr2 :: response(
@@ -1596,6 +1608,10 @@ testthat::test_that(
15961608testthat :: test_that(
15971609 desc = " get_all_allocated_eic() stops on empty response body" ,
15981610 code = {
1611+ testthat :: skip_if_not(
1612+ condition = there_is_provider(),
1613+ message = " The Entso-e API cannot be reached"
1614+ )
15991615 httr2 :: local_mocked_responses(
16001616 mock = function (req ) {
16011617 httr2 :: response(
@@ -1613,6 +1629,10 @@ testthat::test_that(
16131629testthat :: test_that(
16141630 desc = " get_all_allocated_eic() stops on XML with unexpected tree structure" ,
16151631 code = {
1632+ testthat :: skip_if_not(
1633+ condition = there_is_provider(),
1634+ message = " The Entso-e API cannot be reached"
1635+ )
16161636 minimal_xml <- charToRaw(x = paste0(
16171637 ' <?xml version="1.0" encoding="UTF-8"?>' ,
16181638 " <root>" ,
@@ -1641,6 +1661,10 @@ testthat::test_that(
16411661 desc =
16421662 " get_all_allocated_eic() returns one row per EICCode_MarketDocument node" ,
16431663 code = {
1664+ testthat :: skip_if_not(
1665+ condition = there_is_provider(),
1666+ message = " The Entso-e API cannot be reached"
1667+ )
16441668 multi_eic_xml <- readLines(
16451669 con = testthat :: test_path(" fixtures" , " get_allocated_eic_min.xml" ),
16461670 encoding = " UTF-8"
@@ -1670,6 +1694,10 @@ testthat::test_that(
16701694 desc =
16711695 " get_all_allocated_eic() collapses duplicate Function_Names with ' - '" ,
16721696 code = {
1697+ testthat :: skip_if_not(
1698+ condition = there_is_provider(),
1699+ message = " The Entso-e API cannot be reached"
1700+ )
16731701 dupl_fn_xml <- readLines(
16741702 con = testthat :: test_path(" fixtures" , " get_allocated_eic_min.xml" ),
16751703 encoding = " UTF-8"
@@ -1704,6 +1732,10 @@ testthat::test_that(
17041732 " and URL on no internet connection"
17051733 ),
17061734 code = {
1735+ testthat :: skip_if_not(
1736+ condition = there_is_provider(),
1737+ message = " The Entso-e API cannot be reached"
1738+ )
17071739 curl_err <- structure(
17081740 class = c(" curl_error" , " error" , " condition" ),
17091741 list (message = paste(
@@ -1758,6 +1790,14 @@ testthat::test_that(
17581790 " Function_Names elements with ' - '"
17591791 ),
17601792 code = {
1793+ testthat :: skip_if_not(
1794+ condition = nchar(Sys.getenv(" ENTSOE_PAT" )) > 0L ,
1795+ message = " No ENTSOE_PAT environment variable set"
1796+ )
1797+ testthat :: skip_if_not(
1798+ condition = there_is_provider(),
1799+ message = " The Entso-e API cannot be reached"
1800+ )
17611801 xml_fixture <- readLines(
17621802 con = testthat :: test_path(" fixtures" , " get_allocated_eic_dupl.xml" ),
17631803 encoding = " UTF-8"
@@ -1787,6 +1827,43 @@ testthat::test_that(
17871827)
17881828
17891829
1830+ testthat :: test_that(
1831+ desc = paste(
1832+ " get_all_allocated_eic() stops with 'unexpected tree structure'" ,
1833+ " when bind_cols raises an error"
1834+ ),
1835+ code = {
1836+ testthat :: skip_if_not(
1837+ condition = there_is_provider(),
1838+ message = " The Entso-e API cannot be reached"
1839+ )
1840+ xml_fixture <- readLines(
1841+ con = testthat :: test_path(" fixtures" , " get_allocated_eic_min.xml" ),
1842+ encoding = " UTF-8"
1843+ ) | >
1844+ paste(collapse = " \n " ) | >
1845+ charToRaw()
1846+ httr2 :: local_mocked_responses(
1847+ mock = function (req ) {
1848+ httr2 :: response(
1849+ status_code = 200L ,
1850+ headers = list (" content-type" = " application/xml" ),
1851+ body = xml_fixture
1852+ )
1853+ }
1854+ )
1855+ testthat :: local_mocked_bindings(
1856+ bind_cols = function (... ) stop(" simulated incompatible dimensions" ),
1857+ .package = " dplyr"
1858+ )
1859+ testthat :: expect_error(
1860+ object = get_all_allocated_eic(),
1861+ regexp = " unexpected tree structure"
1862+ )
1863+ }
1864+ )
1865+
1866+
17901867testthat :: test_that(
17911868 desc = " add_eic_names() adds names for additional domain mrid columns" ,
17921869 code = {
@@ -1912,6 +1989,14 @@ testthat::test_that(
19121989testthat :: test_that(
19131990 desc = " api_req() stops on unknown 200 response content-type" ,
19141991 code = {
1992+ testthat :: skip_if_not(
1993+ condition = nchar(Sys.getenv(" ENTSOE_PAT" )) > 0L ,
1994+ message = " No ENTSOE_PAT environment variable set"
1995+ )
1996+ testthat :: skip_if_not(
1997+ condition = there_is_provider(),
1998+ message = " The Entso-e API cannot be reached"
1999+ )
19152000 httr2 :: local_mocked_responses(
19162001 mock = function (req ) {
19172002 httr2 :: response(
@@ -1936,6 +2021,14 @@ testthat::test_that(
19362021testthat :: test_that(
19372022 desc = " api_req() stops on HTML error response" ,
19382023 code = {
2024+ testthat :: skip_if_not(
2025+ condition = nchar(Sys.getenv(" ENTSOE_PAT" )) > 0L ,
2026+ message = " No ENTSOE_PAT environment variable set"
2027+ )
2028+ testthat :: skip_if_not(
2029+ condition = there_is_provider(),
2030+ message = " The Entso-e API cannot be reached"
2031+ )
19392032 httr2 :: local_mocked_responses(
19402033 mock = function (req ) {
19412034 httr2 :: response(
@@ -1964,6 +2057,14 @@ testthat::test_that(
19642057testthat :: test_that(
19652058 desc = " api_req() stops on XML error with unexpected Reason structure" ,
19662059 code = {
2060+ testthat :: skip_if_not(
2061+ condition = nchar(Sys.getenv(" ENTSOE_PAT" )) > 0L ,
2062+ message = " No ENTSOE_PAT environment variable set"
2063+ )
2064+ testthat :: skip_if_not(
2065+ condition = there_is_provider(),
2066+ message = " The Entso-e API cannot be reached"
2067+ )
19672068 xml_body <- paste0(
19682069 ' <?xml version="1.0" encoding="UTF-8"?>' ,
19692070 " <Acknowledgement_MarketDocument>" ,
@@ -1996,6 +2097,14 @@ testthat::test_that(
19962097testthat :: test_that(
19972098 desc = " api_req() stops with code:text message on non-999 XML error code" ,
19982099 code = {
2100+ testthat :: skip_if_not(
2101+ condition = nchar(Sys.getenv(" ENTSOE_PAT" )) > 0L ,
2102+ message = " No ENTSOE_PAT environment variable set"
2103+ )
2104+ testthat :: skip_if_not(
2105+ condition = there_is_provider(),
2106+ message = " The Entso-e API cannot be reached"
2107+ )
19992108 xml_body <- paste0(
20002109 ' <?xml version="1.0" encoding="UTF-8"?>' ,
20012110 " <Acknowledgement_MarketDocument>" ,
@@ -2031,6 +2140,14 @@ testthat::test_that(
20312140testthat :: test_that(
20322141 desc = " api_req() stops with curl error message on no internet connection" ,
20332142 code = {
2143+ testthat :: skip_if_not(
2144+ condition = nchar(Sys.getenv(" ENTSOE_PAT" )) > 0L ,
2145+ message = " No ENTSOE_PAT environment variable set"
2146+ )
2147+ testthat :: skip_if_not(
2148+ condition = there_is_provider(),
2149+ message = " The Entso-e API cannot be reached"
2150+ )
20342151 curl_err <- structure(
20352152 class = c(" curl_error" , " error" , " condition" ),
20362153 list (message = " Could not resolve host: web-api.tp.entsoe.eu" )
@@ -2067,6 +2184,14 @@ testthat::test_that(
20672184testthat :: test_that(
20682185 desc = " api_req() stops with HTTP 503 message on service unavailable" ,
20692186 code = {
2187+ testthat :: skip_if_not(
2188+ condition = nchar(Sys.getenv(" ENTSOE_PAT" )) > 0L ,
2189+ message = " No ENTSOE_PAT environment variable set"
2190+ )
2191+ testthat :: skip_if_not(
2192+ condition = there_is_provider(),
2193+ message = " The Entso-e API cannot be reached"
2194+ )
20702195 httr2 :: local_mocked_responses(
20712196 mock = function (req ) {
20722197 httr2 :: response(
0 commit comments