Skip to content

Commit

Permalink
use valid scenario and scenario_source values in tests (#339)
Browse files Browse the repository at this point in the history
* install phantomJS in CI
* install phantomJS in test coverage CI
  • Loading branch information
cjyetman authored Dec 12, 2024
1 parent fd375e1 commit ed3e148
Show file tree
Hide file tree
Showing 6 changed files with 1,549 additions and 1,541 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jobs:
extra-packages: any::rcmdcheck
needs: check

- name: install phantomJS
run: webshot::install_phantomjs()
shell: Rscript {0}

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
extra-packages: any::covr
needs: coverage

- name: install phantomJS
run: webshot::install_phantomjs()
shell: Rscript {0}

- name: Test coverage
run: |
token <- Sys.getenv("CODECOV_TOKEN", "")
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-3-prioritise_and_diagnose.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_that("with known input, runs without error", {
),
project_parameters = list(
scenario_source = "weo_2022",
scenario_select = "nze_2050",
scenario_select = "sds",
region_select = "global",
start_year = 2022L,
time_frame = 5L,
Expand All @@ -33,14 +33,14 @@ test_that("with known input, runs without error", {
plot_resolution = 300L
)
)

matched_path <- file.path(test_tmpdir, "output/matched_loanbooks/matched_lbk_raw_loanbook_1.csv")
manual_path <- file.path(test_tmpdir, "output/matched_loanbooks/matched_lbk_raw_loanbook_1_manual.csv")

readr::read_csv(matched_path, show_col_types = FALSE) %>%
dplyr::slice_max(order_by = score, by = id_loan) %>%
dplyr::slice_head(by = id_loan) %>%
dplyr::slice_max(order_by = score, by = id_loan) %>%
dplyr::slice_head(by = id_loan) %>%
readr::write_csv(manual_path, na = "")

expect_no_error(suppressWarnings(prioritise_and_diagnose(config)))
})
2 changes: 1 addition & 1 deletion tests/testthat/test-4-analyse.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_that("with known input, runs without error", {
),
project_parameters = list(
scenario_source = "weo_2022",
scenario_select = "nze_2050",
scenario_select = "sds",
region_select = "global",
start_year = 2022L,
time_frame = 5L,
Expand Down
44 changes: 22 additions & 22 deletions tests/testthat/test-data/input/scenario_data_sda.csv
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
scenario_source,scenario,sector,region,year,emission_factor_unit,emission_factor
demo_2020,demo,cement,global,2020,tonnes of CO2 per tonne of Cement,0.7
demo_2020,demo,cement,global,2021,tonnes of CO2 per tonne of Cement,0.64
demo_2020,demo,cement,global,2022,tonnes of CO2 per tonne of Cement,0.58
demo_2020,demo,cement,global,2023,tonnes of CO2 per tonne of Cement,0.52
demo_2020,demo,cement,global,2024,tonnes of CO2 per tonne of Cement,0.46
demo_2020,demo,cement,global,2025,tonnes of CO2 per tonne of Cement,0.4
demo_2020,demo,cement,global,2030,tonnes of CO2 per tonne of Cement,0.39
demo_2020,demo,cement,global,2035,tonnes of CO2 per tonne of Cement,0.38
demo_2020,demo,cement,global,2040,tonnes of CO2 per tonne of Cement,0.25
demo_2020,demo,cement,global,2045,tonnes of CO2 per tonne of Cement,0.2
demo_2020,demo,cement,global,2050,tonnes of CO2 per tonne of Cement,0.1
demo_2020,demo,steel,global,2020,tonnes of CO2 per tonne of Steel,2
demo_2020,demo,steel,global,2021,tonnes of CO2 per tonne of Steel,1.9
demo_2020,demo,steel,global,2022,tonnes of CO2 per tonne of Steel,1.8
demo_2020,demo,steel,global,2023,tonnes of CO2 per tonne of Steel,1.7
demo_2020,demo,steel,global,2024,tonnes of CO2 per tonne of Steel,1.6
demo_2020,demo,steel,global,2025,tonnes of CO2 per tonne of Steel,1.5
demo_2020,demo,steel,global,2030,tonnes of CO2 per tonne of Steel,1.433333333
demo_2020,demo,steel,global,2035,tonnes of CO2 per tonne of Steel,1.366666667
demo_2020,demo,steel,global,2040,tonnes of CO2 per tonne of Steel,0.5
demo_2020,demo,steel,global,2045,tonnes of CO2 per tonne of Steel,0.25
demo_2020,demo,steel,global,2050,tonnes of CO2 per tonne of Steel,0.2
weo_2022,sds,cement,global,2020,tonnes of CO2 per tonne of Cement,0.7
weo_2022,sds,cement,global,2021,tonnes of CO2 per tonne of Cement,0.64
weo_2022,sds,cement,global,2022,tonnes of CO2 per tonne of Cement,0.58
weo_2022,sds,cement,global,2023,tonnes of CO2 per tonne of Cement,0.52
weo_2022,sds,cement,global,2024,tonnes of CO2 per tonne of Cement,0.46
weo_2022,sds,cement,global,2025,tonnes of CO2 per tonne of Cement,0.4
weo_2022,sds,cement,global,2030,tonnes of CO2 per tonne of Cement,0.39
weo_2022,sds,cement,global,2035,tonnes of CO2 per tonne of Cement,0.38
weo_2022,sds,cement,global,2040,tonnes of CO2 per tonne of Cement,0.25
weo_2022,sds,cement,global,2045,tonnes of CO2 per tonne of Cement,0.2
weo_2022,sds,cement,global,2050,tonnes of CO2 per tonne of Cement,0.1
weo_2022,sds,steel,global,2020,tonnes of CO2 per tonne of Steel,2
weo_2022,sds,steel,global,2021,tonnes of CO2 per tonne of Steel,1.9
weo_2022,sds,steel,global,2022,tonnes of CO2 per tonne of Steel,1.8
weo_2022,sds,steel,global,2023,tonnes of CO2 per tonne of Steel,1.7
weo_2022,sds,steel,global,2024,tonnes of CO2 per tonne of Steel,1.6
weo_2022,sds,steel,global,2025,tonnes of CO2 per tonne of Steel,1.5
weo_2022,sds,steel,global,2030,tonnes of CO2 per tonne of Steel,1.433333333
weo_2022,sds,steel,global,2035,tonnes of CO2 per tonne of Steel,1.366666667
weo_2022,sds,steel,global,2040,tonnes of CO2 per tonne of Steel,0.5
weo_2022,sds,steel,global,2045,tonnes of CO2 per tonne of Steel,0.25
weo_2022,sds,steel,global,2050,tonnes of CO2 per tonne of Steel,0.2
Loading

0 comments on commit ed3e148

Please sign in to comment.