Skip to content

Commit

Permalink
Fixed cer processing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phoebeheywood committed Apr 29, 2024
1 parent e71a263 commit 2b3a178
Showing 1 changed file with 94 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ testthat::test_that("simple case",{
2015-01-01, WA, SMA, 150, 4
2015-01-01, NSW, X, 201, 5
2015-01-01, WA, X, 151, 6
2015-10-01, NSW, SMA, 300, 4
2015-10-01, WA, SMA, 250, 5
2015-10-01, NSW, X, 301, 6
2015-10-01, WA, X, 251, 7
2015-11-01, NSW, SMA, 400, 5
2015-11-01, WA, SMA, 350, 6
2015-11-01, NSW, X, 401, 7
2015-11-01, WA, X, 351, 8
2016-10-01, NSW, SMA, 500, 6
2016-10-01, WA, SMA, 450, 7
2016-10-01, NSW, X, 501, 8
2016-10-01, WA, X, 451, 9
2016-11-01, NSW, SMA, 600, 7
2016-11-01, WA, SMA, 550, 8
2016-11-01, NSW, X, 601, 9
2016-11-01, WA, X, 551, 10
2017-11-01, NSW, SMA, 700, 8
2017-11-01, WA, SMA, 650, 9
2017-11-01, NSW, X, 701, 10
2017-11-01, WA, X, 651, 11"
2016-11-01, NSW, SMA, 300, 4
2016-11-01, WA, SMA, 250, 5
2016-11-01, NSW, X, 301, 6
2016-11-01, WA, X, 251, 7
2016-12-01, NSW, SMA, 400, 5
2016-12-01, WA, SMA, 350, 6
2016-12-01, NSW, X, 401, 7
2016-12-01, WA, X, 351, 8
2023-03-01, NSW, SMA, 500, 6
2023-03-01, WA, SMA, 450, 7
2023-03-01, NSW, X, 501, 8
2023-03-01, WA, X, 451, 9
2023-04-01, NSW, SMA, 600, 7
2023-04-01, WA, SMA, 550, 8
2023-04-01, NSW, X, 601, 9
2023-04-01, WA, X, 551, 10
2024-04-01, NSW, SMA, 700, 8
2024-04-01, WA, SMA, 650, 9
2024-04-01, NSW, X, 701, 10
2024-04-01, WA, X, 651, 11"

e_out <- " date, s_state, manufacturer, capacity, number, Standard_Version, initial_cap, standard_capacity
2014-01-01, NSW, SMA, 100, 2, AS4777.3:2005, 0, 100
Expand All @@ -48,30 +48,36 @@ testthat::test_that("simple case",{
2015-01-01, WA, SMA, 150, 4, AS4777.3:2005, 0, 150
2015-01-01, NSW, X, 201, 5, AS4777.3:2005, 0, 201
2015-01-01, WA, X, 151, 6, AS4777.3:2005, 0, 151
2015-10-01, NSW, SMA, 300, 4, Transition, 200, 100
2015-10-01, WA, SMA, 250, 5, Transition, 150, 100
2015-10-01, NSW, X, 301, 6, Transition, 201, 100
2015-10-01, WA, X, 251, 7, Transition, 151, 100
2015-11-01, NSW, SMA, 400, 5, Transition, 200, 200
2015-11-01, WA, SMA, 350, 6, Transition, 150, 200
2015-11-01, NSW, X, 401, 7, Transition, 201, 200
2015-11-01, WA, X, 351, 8, Transition, 151, 200
2016-10-01, NSW, SMA, 500, 6, Transition, 200, 300
2016-10-01, WA, SMA, 450, 7, Transition, 150, 300
2016-10-01, NSW, X, 501, 8, Transition, 201, 300
2016-10-01, WA, X, 451, 9, Transition, 151, 300
2016-11-01, NSW, SMA, 600, 7, AS4777.2:2015, 500, 100
2016-11-01, WA, SMA, 550, 8, AS4777.2:2015, 450, 100
2016-11-01, NSW, X, 601, 9, AS4777.2:2015, 501, 100
2016-11-01, WA, X, 551, 10, AS4777.2:2015, 451, 100
2017-11-01, NSW, SMA, 700, 8, AS4777.2:2015, 500, 200
2017-11-01, WA, SMA, 650, 9, AS4777.2:2015, 450, 200
2017-11-01, NSW, X, 701, 10, AS4777.2:2015, 501, 200
2017-11-01, WA, X, 651, 11, AS4777.2:2015, 451, 200"
2016-11-01, NSW, SMA, 300, 4, AS4777.2:2015, 200, 100
2016-11-01, WA, SMA, 250, 5, AS4777.2:2015, 150, 100
2016-11-01, NSW, X, 301, 6, AS4777.2:2015, 201, 100
2016-11-01, WA, X, 251, 7, AS4777.2:2015, 151, 100
2016-12-01, NSW, SMA, 400, 5, AS4777.2:2015, 200, 200
2016-12-01, WA, SMA, 350, 6, AS4777.2:2015, 150, 200
2016-12-01, NSW, X, 401, 7, AS4777.2:2015, 201, 200
2016-12-01, WA, X, 351, 8, AS4777.2:2015, 151, 200
2023-03-01, NSW, SMA, 500, 6, AS4777.2:2015, 200, 300
2023-03-01, WA, SMA, 450, 7, AS4777.2:2015, 150, 300
2023-03-01, NSW, X, 501, 8, AS4777.2:2015, 201, 300
2023-03-01, WA, X, 451, 9, AS4777.2:2015, 151, 300
2023-04-01, NSW, SMA, 600, 7, AS4777.2:2020, 500, 100
2023-04-01, WA, SMA, 550, 8, AS4777.2:2020, 450, 100
2023-04-01, NSW, X, 601, 9, AS4777.2:2020, 501, 100
2023-04-01, WA, X, 551, 10, AS4777.2:2020, 451, 100
2024-04-01, NSW, SMA, 700, 8, AS4777.2:2020, 500, 200
2024-04-01, WA, SMA, 650, 9, AS4777.2:2020, 450, 200
2024-04-01, NSW, X, 701, 10, AS4777.2:2020, 501, 200
2024-04-01, WA, X, 651, 11, AS4777.2:2020, 451, 200"

data_by_state_and_manufacturer <- load_test_file(data_by_state_and_manufacturer)
e_out <- load_test_file(e_out)
e_out <- mutate(e_out, date = ymd(date))
e_out <- mutate(e_out,
date = ymd(date),
Standard_Version = ifelse(
Standard_Version == "AS4777.2:2020",
"AS4777.2:2020 (>=Apr'23)",
Standard_Version)
)
output <- calc_installed_capacity_by_standard_and_manufacturer(data_by_state_and_manufacturer)
testthat::expect_equal(output, e_out, tolerance = 1e-4)
})
Expand All @@ -88,26 +94,26 @@ testthat::test_that("discontinued line",{
2015-01-01, WA, SMA, 150, 4
2015-01-01, NSW, X, 201, 5
2015-01-01, WA, X, 151, 6
2015-10-01, NSW, SMA, 300, 4
2015-10-01, WA, SMA, 250, 5
2015-10-01, NSW, X, 201, 6
2015-10-01, WA, X, 251, 7
2015-11-01, NSW, SMA, 400, 5
2015-11-01, WA, SMA, 350, 6
2015-11-01, NSW, X, 201, 7
2015-11-01, WA, X, 351, 8
2016-10-01, NSW, SMA, 500, 6
2016-10-01, WA, SMA, 450, 7
2016-10-01, NSW, X, 201, 8
2016-10-01, WA, X, 451, 9
2016-11-01, NSW, SMA, 600, 7
2016-11-01, WA, SMA, 550, 8
2016-11-01, NSW, X, 201, 9
2016-11-01, WA, X, 551, 10
2017-11-01, NSW, SMA, 700, 8
2017-11-01, WA, SMA, 650, 9
2017-11-01, NSW, X, 201, 10
2017-11-01, WA, X, 651, 11"
2016-11-01, NSW, SMA, 300, 4
2016-11-01, WA, SMA, 250, 5
2016-11-01, NSW, X, 201, 6
2016-11-01, WA, X, 251, 7
2016-12-01, NSW, SMA, 400, 5
2016-12-01, WA, SMA, 350, 6
2016-12-01, NSW, X, 201, 7
2016-12-01, WA, X, 351, 8
2017-10-01, NSW, SMA, 500, 6
2017-10-01, WA, SMA, 450, 7
2017-10-01, NSW, X, 201, 8
2017-10-01, WA, X, 451, 9
2023-04-01, NSW, SMA, 600, 7
2023-04-01, WA, SMA, 550, 8
2023-04-01, NSW, X, 201, 9
2023-04-01, WA, X, 551, 10
2024-04-01, NSW, SMA, 700, 8
2024-04-01, WA, SMA, 650, 9
2024-04-01, NSW, X, 201, 10
2024-04-01, WA, X, 651, 11"

e_out <- " date, s_state, manufacturer, capacity, number, Standard_Version, initial_cap, standard_capacity
2014-01-01, NSW, SMA, 100, 2, AS4777.3:2005, 0, 100
Expand All @@ -118,30 +124,36 @@ testthat::test_that("discontinued line",{
2015-01-01, WA, SMA, 150, 4, AS4777.3:2005, 0, 150
2015-01-01, NSW, X, 201, 5, AS4777.3:2005, 0, 201
2015-01-01, WA, X, 151, 6, AS4777.3:2005, 0, 151
2015-10-01, NSW, SMA, 300, 4, Transition, 200, 100
2015-10-01, WA, SMA, 250, 5, Transition, 150, 100
2015-10-01, NSW, X, 201, 6, Transition, 201, 0
2015-10-01, WA, X, 251, 7, Transition, 151, 100
2015-11-01, NSW, SMA, 400, 5, Transition, 200, 200
2015-11-01, WA, SMA, 350, 6, Transition, 150, 200
2015-11-01, NSW, X, 201, 7, Transition, 201, 0
2015-11-01, WA, X, 351, 8, Transition, 151, 200
2016-10-01, NSW, SMA, 500, 6, Transition, 200, 300
2016-10-01, WA, SMA, 450, 7, Transition, 150, 300
2016-10-01, NSW, X, 201, 8, Transition, 201, 0
2016-10-01, WA, X, 451, 9, Transition, 151, 300
2016-11-01, NSW, SMA, 600, 7, AS4777.2:2015, 500, 100
2016-11-01, WA, SMA, 550, 8, AS4777.2:2015, 450, 100
2016-11-01, NSW, X, 201, 9, AS4777.2:2015, 201, 0
2016-11-01, WA, X, 551, 10, AS4777.2:2015, 451, 100
2017-11-01, NSW, SMA, 700, 8, AS4777.2:2015, 500, 200
2017-11-01, WA, SMA, 650, 9, AS4777.2:2015, 450, 200
2017-11-01, NSW, X, 201, 10, AS4777.2:2015, 201, 0
2017-11-01, WA, X, 651, 11, AS4777.2:2015, 451, 200"
2016-11-01, NSW, SMA, 300, 4, AS4777.2:2015, 200, 100
2016-11-01, WA, SMA, 250, 5, AS4777.2:2015, 150, 100
2016-11-01, NSW, X, 201, 6, AS4777.2:2015, 201, 0
2016-11-01, WA, X, 251, 7, AS4777.2:2015, 151, 100
2016-12-01, NSW, SMA, 400, 5, AS4777.2:2015, 200, 200
2016-12-01, WA, SMA, 350, 6, AS4777.2:2015, 150, 200
2016-12-01, NSW, X, 201, 7, AS4777.2:2015, 201, 0
2016-12-01, WA, X, 351, 8, AS4777.2:2015, 151, 200
2017-10-01, NSW, SMA, 500, 6, AS4777.2:2015, 200, 300
2017-10-01, WA, SMA, 450, 7, AS4777.2:2015, 150, 300
2017-10-01, NSW, X, 201, 8, AS4777.2:2015, 201, 0
2017-10-01, WA, X, 451, 9, AS4777.2:2015, 151, 300
2023-04-01, NSW, SMA, 600, 7, AS4777.2:2020, 500, 100
2023-04-01, WA, SMA, 550, 8, AS4777.2:2020, 450, 100
2023-04-01, NSW, X, 201, 9, AS4777.2:2020, 201, 0
2023-04-01, WA, X, 551, 10, AS4777.2:2020, 451, 100
2024-04-01, NSW, SMA, 700, 8, AS4777.2:2020, 500, 200
2024-04-01, WA, SMA, 650, 9, AS4777.2:2020, 450, 200
2024-04-01, NSW, X, 201, 10, AS4777.2:2020, 201, 0
2024-04-01, WA, X, 651, 11, AS4777.2:2020, 451, 200"

data_by_state_and_manufacturer <- load_test_file(data_by_state_and_manufacturer)
e_out <- load_test_file(e_out)
e_out <- mutate(e_out, date = ymd(date))
e_out <- mutate(e_out,
date = ymd(date),
Standard_Version = ifelse(
Standard_Version == "AS4777.2:2020",
"AS4777.2:2020 (>=Apr'23)",
Standard_Version)
)
output <- calc_installed_capacity_by_standard_and_manufacturer(data_by_state_and_manufacturer)
testthat::expect_equal(output, e_out, tolerance = 1e-4)
})

0 comments on commit 2b3a178

Please sign in to comment.