diff --git a/R/utils.R b/R/utils.R index 4868bd4c..50b5f84f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1022,7 +1022,7 @@ get_all_allocated_eic <- function() { error = \(e) { cli::cli_abort( "The XML document has an unexpected tree structure! {e}" - ) # nocov + ) } ) diff --git a/README.Rmd b/README.Rmd index dacbcf04..e3546fb7 100644 --- a/README.Rmd +++ b/README.Rmd @@ -162,6 +162,7 @@ For some of the data you need to translate the generation codes. ```{r example 2} if (!require("knitr", quietly = TRUE)) install.packages("knitr", quiet = TRUE) entsoeapi::asset_types |> + head(n = 12L) |> knitr::kable(format = "html") ``` diff --git a/README.md b/README.md index beae8353..a63ad56f 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,7 @@ For some of the data you need to translate the generation codes. ``` r if (!require("knitr", quietly = TRUE)) install.packages("knitr", quiet = TRUE) entsoeapi::asset_types |> + head(n = 12L) |> knitr::kable(format = "html") ``` @@ -472,1572 +473,6 @@ Flexible Alternating Current Transmission System - - - - -A13 - - - - -Production unit - - - - -A production unit is a composition of one or several generation units. - - - - - - - - -A14 - - - - -Internal tie line - - - - -An internal tie line is a line between two scheduling areas within the -same bidding zone. - - - - - - - - -B01 - - - - -Biomass - - - - -A resource using biomass for energy. - - - - - - - - -B02 - - - - -Fossil Brown coal/Lignite - - - - -A resource using Fossil Brown coal/Lignite for energy. - - - - - - - - -B03 - - - - -Fossil Coal-derived gas - - - - -A resource using Fossil Coal-derived gas for energy. - - - - - - - - -B04 - - - - -Fossil Gas - - - - -A resource using Fossil Gas for energy. - - - - - - - - -B05 - - - - -Fossil Hard coal - - - - -A resource using Fossil Hard coal for energy. - - - - - - - - -B06 - - - - -Fossil Oil - - - - -A resource using Fossil Oil for energy. - - - - - - - - -B07 - - - - -Fossil Oil shale - - - - -A resource using Fossil Oil shale for energy. - - - - - - - - -B08 - - - - -Fossil Peat - - - - -A resource using Fossil Peat for energy. - - - - - - - - -B09 - - - - -Geothermal - - - - -A resource using Geothermal for energy. - - - - - - - - -B10 - - - - -Hydro-electric pure pumped storage head installation - - - - -Unit in which moving water energy is converted to electricity using -flowing water to generate electricity with a large dam and reservoirs. -Pure pumped storage plants store water in an upper reservoir with no -natural inflows. - - - - - - - - -B11 - - - - -Hydro Run-of-river head installation - - - - -Unit in which moving water energy is converted to electricity using -flowing water to generate electricity in the absence of a large dam and -reservoirs. - - - - - - - - -B12 - - - - -Hydro-electric storage head installation - - - - -Unit in which moving water energy is converted to electricity using -flowing water to generate electricity with a large dam and reservoirs. - - - - - - - - -B13 - - - - -Marine unspecified - - - - -Unit in which marine energy is converted to electricity with -equipment/devices not specified. - - - - - - - - -B14 - - - - -Nuclear unspecified - - - - -A unit in which the heat source is a nuclear reactor of type that is not -specified in other nuclear types. - - - - - - - - -B15 - - - - -Other renewable - - - - -A resource using Other renewable for energy. - - - - - - - - -B16 - - - - -Solar unspecified - - - - -Unit in which solar energy is converted to electricity with -equipment/devices not specified. - - - - - - - - -B17 - - - - -Waste - - - - -A resource using Waste for energy. - - - - - - - - -B18 - - - - -Wind Offshore - - - - -Unit in which wind energy is converted to electricity using wind farms -constructed in bodies of water, usually in the ocean. - - - - - - - - -B19 - - - - -Wind Onshore - - - - -Unit in which wind energy is converted to electricity using wind farms -constructed on land. - - - - - - - - -B20 - - - - -Other unspecified - - - - -Other unspecified technology. - - - - - - - - -B21 - - - - -AC Link - - - - -Overhead line or cable which is used to transmit electrical power via -Alternative Current. - - - - - - - - -B22 - - - - -DC Link - - - - -Overhead line or cable which is used to transmit electrical power via -Direct Current. - - - - - - - - -B23 - - - - -Substation - - - - -An assembly of equipment in an electric power system through which -electric energy is passed for transmission, transformation, distribution -or switching. - - - - - - - - -B24 - - - - -Transformer - - - - -Electrical device that transfers energy from one voltage level to -another voltage level. - - - - - - - - -B25 - - - - -Energy storage - - - - -A resource that stores energy. It could be gas, electricity, etc. - - - - - - - - -B26 - - - - -Demand Side Response - - - - -A resource that change its electricity consumption patterns in response -to a signal or incentive. - - - - - - - - -B27 - - - - -Dispatchable hydro resource - - - - -A resource referring to dispatchable hydro generation. - - - - - - - - -B28 - - - - -Solar photovoltaic - - - - -Unit in which solar energy is converted to electricity using a -technology based on the photoelectric effect. - - - - - - - - -B29 - - - - -Solar concentration - - - - -Unit in which solar energy is converted to electricity using mirrors to -concentrate the sun’s energy to drive traditional steam turbines or -engines. - - - - - - - - -B30 - - - - -Wind unspecified - - - - -Unit in which wind energy is converted to electricity with -equipment/devices not specified. - - - - - - - - -B31 - - - - -Hydro-electric unspecified - - - - -Unit in which moving water energy is converted to electricity with -equipment/devices not specified. - - - - - - - - -B32 - - - - -Hydro-electric mixed pumped storage head installation - - - - -Unit in which moving water energy is converted to electricity using -flowing water to generate electricity with a large dam and reservoirs. -Mixed pumped storage plants use a combination of pumped storage and -conventional hydroelectric plants with an upper reservoir that is -replenished in part by natural inflows from a stream or river. - - - - - - - - -B33 - - - - -Marine tidal - - - - -Unit in which marine energy from tides is converted to electricity. - - - - - - - - -B34 - - - - -Marine wave - - - - -Unit in which marine energy from waves is converted to electricity. - - - - - - - - -B35 - - - - -Marine currents - - - - -Unit in which marine energy from currents is converted to electricity. - - - - - - - - -B36 - - - - -Marine pressure - - - - -Unit in which marine energy from pressure is converted to electricity. - - - - - - - - -B37 - - - - -Thermal unspecified - - - - -Unit in which heat energy is converted to electricity with -equipment/devices not specified in other thermal types. - - - - - - - - -B38 - - - - -Thermal combined cycle gas turbine with heat recovery - - - - -Unit in which heat energy is converted to electricity called Combined -Cycle Gas Turbine. The power is generated by the single or multiple gas -turbine(s) in combination with the steam turbine(s). The unit might be -equipped with waste heat recovery (e.g. to district heating network). - - - - - - - - -B39 - - - - -Thermal steam turbine with back-pressure turbine (open cycle) - - - - -Unit in which heat energy is converted to electricity. The power is -generated with the steam that is expanded in the back-pressure steam -turbine with or without heat output (e.g. to district heating network). - - - - - - - - -B40 - - - - -Thermal steam turbine with condensation turbine (closed cycle) - - - - -Unit in which heat energy is converted to electricity. The power is -generated with the steam that is expanded in the condensation steam -turbine with or without heat output (e.g. to district heating network). - - - - - - - - -B41 - - - - -Thermal gas turbine with heat recovery - - - - -Unit in which heat energy is converted to electricity called Simple -Cycle Gas Turbine. The power is generated by the gas turbine and the -flue gas waste heat is recovered (e.g. to district heating network). - - - - - - - - -B42 - - - - -Thermal internal combustion engine - - - - -An internal combustion engine is a heat engine in which the combustion -of a fuel occurs with an oxidizer (usually air) in a combustion chamber -that is an integral part of the working fluid flow circuit -(e.g. reciprocating engine). The unit might be equipped with waste heat -recovery (e.g. to district heating network). - - - - - - - - -B43 - - - - -Thermal micro-turbine - - - - -Unit in which heat energy is converted to electricity called Simple -Cycle Gas Turbine. The power is generated by the gas turbine (capacity -less than 500kWe). The unit might be equipped with waste heat recovery -(e.g. to district heating network). - - - - - - - - -B44 - - - - -Thermal Stirling engine - - - - -A Stirling engine is a heat engine that is operated by the cyclic -compression and expansion of air or other gas (the working fluid) at -different temperatures, resulting in a net conversion of heat energy to -mechanical work. - - - - - - - - -B45 - - - - -Thermal fuel cell - - - - -A fuel cell is an electrochemical cell that converts the chemical energy -of a fuel (e.g. hydrogen) and an oxidizing agent (e.g. oxygen) into -electricity through a pair of redox reactions. - - - - - - - - -B46 - - - - -Thermal steam engine - - - - -A steam engine is a heat engine that performs mechanical work using -steam as its working fluid. The steam engine uses the force produced by -steam pressure to push a piston back and forth inside a cylinder. - - - - - - - - -B47 - - - - -Thermal organic Rankine cycle - - - - -The Organic Rankine Cycle (ORC) is named for its use of an organic, high -molecular mass fluid with a liquid-vapor phase change, or boiling point, -occurring at a lower temperature than the water-steam phase change. The -fluid allows Rankine cycle heat recovery from lower temperature sources -such as biomass combustion, industrial waste heat, geothermal heat, -solar ponds etc. The low-temperature heat is converted into useful work, -that can itself be converted into electricity. - - - - - - - - -B48 - - - - -Thermal gas turbine without heat recovery - - - - -Unit in which heat energy is converted to electricity called Simple -Cycle Gas Turbine. The power is generated by the gas turbine and there -is no flue gas waste heat recovery. - - - - - - - - -B49 - - - - -Nuclear heavy water reactor - - - - -A unit in which the heat source is a pressurized heavy-water reactor -(PHWR) that is a nuclear reactor that uses heavy water (deuterium oxide -D2O) as its coolant and neutron moderator. - - - - - - - - -B50 - - - - -Nuclear light water reactor - - - - -A unit in which the heat source is a light-water reactor (LWR) that is a -type of thermal-neutron reactor that uses normal water, as both its -coolant and neutron moderator � furthermore a solid form of fissile -elements is used as fuel. - - - - - - - - -B51 - - - - -Nuclear breeder - - - - -A unit in which the heat source is a nuclear reactor that generates more -fissile material than it consumes. - - - - - - - - -B52 - - - - -Nuclear graphite reactor - - - - -A unit in which the heat source is a graphite-moderated reactor that is -a nuclear reactor that uses carbon as a neutron moderator, which allows -natural uranium to be used as nuclear fuel. - - - - - - - - -B53 - - - - -Temporary energy storage - - - - -A resource that is temporarily connected to the grid and that may store -energy when connected, such as an electric vehicle. - - - - - - - - -B54 - - - - -Permanent energy storage - - - - -A resource that is permanently connected to the grid and that may store -energy when connected, such as a pumped hydro. - - - - - - - - -B55 - - - - -Electric vehicle battery - - - - -A resource using electric vehicle batteries, commercial and private. The -reason for separating vehicle batteries and non-vehicle batteries is -that the vehicle batteries not necessarily is connected to the charger. - - - - - - - - -B56 - - - - -Heat pump specified - - - - -A heat pump is a device that uses work to transfer heat from a cool -space to a warm space by transferring thermal energy using a -refrigeration cycle - - - - - - - - -B57 - - - - -Heat pump electrical - - - - -A heat pump is a device that uses electricity to transfer heat from a -cool space to a warm space by transferring thermal energy using a -refrigeration cycle. - - - - - - - - -B58 - - - - -Heat pump absorption - - - - -A heat pump is a device that uses absorption technology to transfer heat -from a cool space to a warm space by transferring thermal energy using a -refrigeration cycle. - - - - - - - - -B59 - - - - -Auxiliary power unit - - - - -A technology that provides energy as a backup. - - - - - - - - -B60 - - - - -Water electrolysis unspecified - - - - -Unspecified water electrolysis. - - - - - - - - -B61 - - - - -Water electrolysis low temperature unspecified - - - - -Unspecified water electrolysis at low temperature as in an Alkaline or -Proto-Exchange Membrane (PEM) fuel cell. - - - - - - - - -B62 - - - - -Water electrolysis low temperature main product - - - - -Main product water electrolysis at low temperature as in an Alkaline or -Proto-Exchange Membrane (PEM) fuel cell. - - - - - - - - -B63 - - - - -Water electrolysis high temperature unspecified - - - - -Unspecified water electrolysis at high temperature as in a Solid Oxide -Electrolysis Cell (SOEC) fuel cell. - - - - - - - - -B64 - - - - -Steam methane reforming unspecified - - - - -Unspecified methane reforming. - - - - - - - - -B65 - - - - -Steam methane reforming without CCS/CCU unspecified - - - - -Main product methane reforming without Carbon Capture and Sequestration -(CCS)/Carbon Capture and Use (CCU). - - - - - - - - -B66 - - - - -Steam methane reforming with CCS/CCU unspecified - - - - -Unspecified methane reforming with Carbon Capture and Sequestration -(CCS)/Carbon Capture and Use (CCU). - - - - - - - - -B67 - - - - -Steam methane reforming with CCS/CCU main product - - - - -Main product methane reforming with Carbon Capture and Sequestration -(CCS)/Carbon Capture and Use (CCU). - - - - - - - - -B68 - - - - -Partial oxidation unspecified - - - - -Unspecified partial oxidation. - - - - - - - - -B69 - - - - -Autothermal reforming unspecified - - - - -Unspecified autothermal reforming. - - - - - - - - -B70 - - - - -Methanol reforming unspecified - - - - -Unspecified methanol reforming. - - - - - - - - -B71 - - - - -Ammonia reforming unspecified - - - - -Unspecified ammonia reforming. - - - - - - - - -B72 - - - - -Ammonia gasification - - - - -Unspecified gasification. - - - - - - - - -B73 - - - - -Chlor-alkali electrolysis unspecified - - - - -Unspecified alkali electrolysis. - - - - - - - - -B74 - - - - -Chlor-alkali electrolysis by-product - - - - -Alkali electrolysis product. - - - - - - - - -B75 - - - - -ACDC converter - - - - -ACDC converters are electrical circuits that transform alternating -current (AC) into direct current (DC) and vice versa. - - - - - - - - -B76 - - - - -Converter - - - - -Electrical device that converts current between AC and DC. - - - - @@ -2056,7 +491,7 @@ entsoeapi::load_actual_total( #> ── API call ──────────────────────────────────────────────────────────────────── #> → https://web-api.tp.entsoe.eu/api?documentType=A65&processType=A16&outBiddingZone_Domain=10Y1001A1001A83F&periodStart=201912312300&periodEnd=202001012300&securityToken=<...> #> <- HTTP/2 200 -#> <- date: Sun, 08 Mar 2026 23:29:58 GMT +#> <- date: Tue, 10 Mar 2026 18:15:50 GMT #> <- content-type: text/xml #> <- content-disposition: inline; filename="Actual Total Load_201912312300-202001012300.xml" #> <- x-content-type-options: nosniff @@ -2079,7 +514,7 @@ entsoeapi::load_actual_total( #> $ ts_object_aggregation_def "Area", "Area", "Area", "Area", "Area"… #> $ ts_business_type "A04", "A04", "A04", "A04", "A04", "A0… #> $ ts_business_type_def "Consumption", "Consumption", "Consump… -#> $ created_date_time 2026-03-08 23:29:58, 2026-03-08 23:29… +#> $ created_date_time 2026-03-10 18:15:50, 2026-03-10 18:15… #> $ revision_number 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,… #> $ time_period_time_interval_start 2019-12-31 23:00:00, 2019-12-31 23:00… #> $ time_period_time_interval_end 2020-01-01 23:00:00, 2020-01-01 23:00… @@ -2109,7 +544,7 @@ entsoeapi::gen_per_prod_type( #> ── API call ──────────────────────────────────────────────────────────────────── #> → https://web-api.tp.entsoe.eu/api?documentType=A75&processType=A16&in_Domain=10Y1001A1001A83F&periodStart=201912312300&periodEnd=202001012300&securityToken=<...> #> <- HTTP/2 200 -#> <- date: Sun, 08 Mar 2026 23:29:59 GMT +#> <- date: Tue, 10 Mar 2026 18:15:52 GMT #> <- content-type: text/xml #> <- content-disposition: inline; filename="Aggregated Generation per Type_201912312300-202001012300.xml" #> <- x-content-type-options: nosniff @@ -2121,10 +556,10 @@ entsoeapi::gen_per_prod_type( #> ✔ response has arrived #> Rows: 1,632 #> Columns: 25 -#> $ ts_in_bidding_zone_domain_mrid NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -#> $ ts_in_bidding_zone_domain_name NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -#> $ ts_out_bidding_zone_domain_mrid "10Y1001A1001A83F", "10Y1001A1001A83F"… -#> $ ts_out_bidding_zone_domain_name "Germany", "Germany", "Germany", "Germ… +#> $ ts_in_bidding_zone_domain_mrid "10Y1001A1001A83F", "10Y1001A1001A83F"… +#> $ ts_in_bidding_zone_domain_name "Germany", "Germany", "Germany", "Germ… +#> $ ts_out_bidding_zone_domain_mrid NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… +#> $ ts_out_bidding_zone_domain_name NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… #> $ type "A75", "A75", "A75", "A75", "A75", "A7… #> $ type_def "Actual generation per type", "Actual … #> $ process_type "A16", "A16", "A16", "A16", "A16", "A1… @@ -2133,9 +568,9 @@ entsoeapi::gen_per_prod_type( #> $ ts_object_aggregation_def "Resource type", "Resource type", "Res… #> $ ts_business_type "A01", "A01", "A01", "A01", "A01", "A0… #> $ ts_business_type_def "Production", "Production", "Productio… -#> $ ts_mkt_psr_type "B10", "B10", "B10", "B10", "B10", "B1… -#> $ ts_mkt_psr_type_def "Hydro-electric pure pumped storage he… -#> $ created_date_time 2026-03-08 23:29:59, 2026-03-08 23:29… +#> $ ts_mkt_psr_type "B01", "B01", "B01", "B01", "B01", "B0… +#> $ ts_mkt_psr_type_def "Biomass", "Biomass", "Biomass", "Biom… +#> $ created_date_time 2026-03-10 18:15:52, 2026-03-10 18:15… #> $ revision_number 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,… #> $ time_period_time_interval_start 2019-12-31 23:00:00, 2019-12-31 23:00… #> $ time_period_time_interval_end 2020-01-01 23:00:00, 2020-01-01 23:00… @@ -2144,7 +579,7 @@ entsoeapi::gen_per_prod_type( #> $ ts_time_interval_end 2020-01-01 23:00:00, 2020-01-01 23:00… #> $ ts_mrid 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,… #> $ ts_point_dt_start 2019-12-31 23:00:00, 2019-12-31 23:15… -#> $ ts_point_quantity 194.92, 225.11, 286.19, 397.02, 284.99… +#> $ ts_point_quantity 4809.13, 4803.04, 4787.15, 4787.26, 47… #> $ ts_quantity_measure_unit_name "MAW", "MAW", "MAW", "MAW", "MAW", "MA… ``` diff --git a/RELEASE_CHECKLIST.md b/RELEASE_CHECKLIST.md index 63d4506f..8a5b330e 100644 --- a/RELEASE_CHECKLIST.md +++ b/RELEASE_CHECKLIST.md @@ -41,7 +41,7 @@ ## 7. (When ready) CRAN Submission -- [ ] `rhub::rhub_doctor(gh_url = "https://github.com/krose/entsoeapi")` — multi-platform check +- [ ] `rhub::rhub_doctor(gh_url = "https://github.com/krose/entsoeapi"); rhub::rhub_check(gh_url = "https://github.com/krose/entsoeapi", platforms = c(1L, 3L, 5L), branch = "main")`— multi-platform check - [ ] `devtools::spell_check()` — no spelling errors in docs - [ ] Review [CRAN policies](https://cran.r-project.org/web/packages/policies.html) - [ ] `devtools::submit_cran()` or upload via diff --git a/tests/testthat/test-en_balancing.R b/tests/testthat/test-en_balancing.R index f3e14271..18dc29b4 100644 --- a/tests/testthat/test-en_balancing.R +++ b/tests/testthat/test-en_balancing.R @@ -1473,6 +1473,14 @@ testthat::test_that( testthat::test_that( desc = "activated_balancing_prices() covers business_type branch with mock", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) httr2::local_mocked_responses( mock = function(req) { httr2::response( @@ -2042,6 +2050,14 @@ testthat::test_that( testthat::test_that( desc = "sharing_of_frr_capacity() covers happy path with mock", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) httr2::local_mocked_responses( mock = function(req) { httr2::response( diff --git a/tests/testthat/test-en_helpers.R b/tests/testthat/test-en_helpers.R index ef568d47..14016b84 100644 --- a/tests/testthat/test-en_helpers.R +++ b/tests/testthat/test-en_helpers.R @@ -440,6 +440,14 @@ testthat::test_that( testthat::test_that( desc = "all_allocated_eic() stops on XML with unexpected structure", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) req_url <- paste0( "https://eepublicdownloads.blob.core.windows.net/", "cio-lio/xml/allocated-eic-codes.xml" diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 9d5dddff..4f4a8ebe 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1491,6 +1491,10 @@ testthat::test_that( "with expected columns on valid XML" ), code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) xml_fixture <- readLines( con = testthat::test_path("fixtures", "get_allocated_eic_min.xml"), encoding = "UTF-8" @@ -1537,6 +1541,10 @@ testthat::test_that( desc = "get_all_allocated_eic() joins doc_status from message_types correctly", code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) xml_fixture <- readLines( con = testthat::test_path("fixtures", "get_allocated_eic_min.xml"), encoding = "UTF-8" @@ -1567,6 +1575,10 @@ testthat::test_that( desc = "get_all_allocated_eic() stops with HTTP error message and request URL", code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) httr2::local_mocked_responses( mock = function(req) { httr2::response( @@ -1596,6 +1608,10 @@ testthat::test_that( testthat::test_that( desc = "get_all_allocated_eic() stops on empty response body", code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) httr2::local_mocked_responses( mock = function(req) { httr2::response( @@ -1613,6 +1629,10 @@ testthat::test_that( testthat::test_that( desc = "get_all_allocated_eic() stops on XML with unexpected tree structure", code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) minimal_xml <- charToRaw(x = paste0( '', "", @@ -1641,6 +1661,10 @@ testthat::test_that( desc = "get_all_allocated_eic() returns one row per EICCode_MarketDocument node", code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) multi_eic_xml <- readLines( con = testthat::test_path("fixtures", "get_allocated_eic_min.xml"), encoding = "UTF-8" @@ -1670,6 +1694,10 @@ testthat::test_that( desc = "get_all_allocated_eic() collapses duplicate Function_Names with ' - '", code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) dupl_fn_xml <- readLines( con = testthat::test_path("fixtures", "get_allocated_eic_min.xml"), encoding = "UTF-8" @@ -1704,6 +1732,10 @@ testthat::test_that( "and URL on no internet connection" ), code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) curl_err <- structure( class = c("curl_error", "error", "condition"), list(message = paste( @@ -1758,6 +1790,14 @@ testthat::test_that( "Function_Names elements with ' - '" ), code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) xml_fixture <- readLines( con = testthat::test_path("fixtures", "get_allocated_eic_dupl.xml"), encoding = "UTF-8" @@ -1787,6 +1827,43 @@ testthat::test_that( ) +testthat::test_that( + desc = paste( + "get_all_allocated_eic() stops with 'unexpected tree structure'", + "when bind_cols raises an error" + ), + code = { + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) + xml_fixture <- readLines( + con = testthat::test_path("fixtures", "get_allocated_eic_min.xml"), + encoding = "UTF-8" + ) |> + paste(collapse = "\n") |> + charToRaw() + httr2::local_mocked_responses( + mock = function(req) { + httr2::response( + status_code = 200L, + headers = list("content-type" = "application/xml"), + body = xml_fixture + ) + } + ) + testthat::local_mocked_bindings( + bind_cols = function(...) stop("simulated incompatible dimensions"), + .package = "dplyr" + ) + testthat::expect_error( + object = get_all_allocated_eic(), + regexp = "unexpected tree structure" + ) + } +) + + testthat::test_that( desc = "add_eic_names() adds names for additional domain mrid columns", code = { @@ -1912,6 +1989,14 @@ testthat::test_that( testthat::test_that( desc = "api_req() stops on unknown 200 response content-type", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) httr2::local_mocked_responses( mock = function(req) { httr2::response( @@ -1936,6 +2021,14 @@ testthat::test_that( testthat::test_that( desc = "api_req() stops on HTML error response", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) httr2::local_mocked_responses( mock = function(req) { httr2::response( @@ -1964,6 +2057,14 @@ testthat::test_that( testthat::test_that( desc = "api_req() stops on XML error with unexpected Reason structure", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) xml_body <- paste0( '', "", @@ -1996,6 +2097,14 @@ testthat::test_that( testthat::test_that( desc = "api_req() stops with code:text message on non-999 XML error code", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) xml_body <- paste0( '', "", @@ -2031,6 +2140,14 @@ testthat::test_that( testthat::test_that( desc = "api_req() stops with curl error message on no internet connection", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) curl_err <- structure( class = c("curl_error", "error", "condition"), list(message = "Could not resolve host: web-api.tp.entsoe.eu") @@ -2067,6 +2184,14 @@ testthat::test_that( testthat::test_that( desc = "api_req() stops with HTTP 503 message on service unavailable", code = { + testthat::skip_if_not( + condition = nchar(Sys.getenv("ENTSOE_PAT")) > 0L, + message = "No ENTSOE_PAT environment variable set" + ) + testthat::skip_if_not( + condition = there_is_provider(), + message = "The Entso-e API cannot be reached" + ) httr2::local_mocked_responses( mock = function(req) { httr2::response(