-
Notifications
You must be signed in to change notification settings - Fork 1
Increase code coverage #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
72987c2
Port PSI add interval (#86)
acostarelli 2cfa8a4
copilot coverage
b51706b
Merge remote-tracking branch 'origin/lk/mbc_iec_refactor' into ac/cov…
e717b3b
Fix remaining coverage test failures
d6cd3b6
formatting
a569159
fixed bugs preventing tests; added more tests; removed unnecessary co…
3914d99
Merge remote-tracking branch 'origin/main' into ac/coverage
bdb11ee
check_time_series_consistency
b111065
Add tests to improve coverage for core types, services, network, bran…
b8cba2e
2d constraint container
51a820c
2d constraint container
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env julia | ||
| # | ||
| # Generate lcov.info from existing .cov files for Coverage Gutters. | ||
| # Run this AFTER running tests with coverage. | ||
| # | ||
| # Usage: | ||
| # 1. Run tests with coverage: julia --project=. -e 'using TestEnv; TestEnv.activate(); include("test/load_tests.jl"); InfrastructureOptimizationModelsTests.run_tests()' | ||
| # 2. Generate lcov: julia --project=. -e 'using TestEnv; TestEnv.activate(); include("scripts/generate_lcov.jl")' | ||
|
|
||
| using CoverageTools | ||
| using Coverage | ||
|
|
||
| const PROJECT_ROOT = dirname(@__DIR__) | ||
|
|
||
| coverage = CoverageTools.process_folder(joinpath(PROJECT_ROOT, "src")) | ||
| LCOV.writefile(joinpath(PROJECT_ROOT, "lcov.info"), coverage) | ||
|
|
||
| @info "Wrote $(joinpath(PROJECT_ROOT, "lcov.info"))" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/bin/zsh | ||
| # | ||
| # Run tests with coverage and generate lcov.info for Coverage Gutters. | ||
| # Usage: ./scripts/test_with_coverage.sh | ||
|
|
||
| set -euo pipefail | ||
| cd "$(dirname "$0")/.." | ||
|
|
||
| echo "==> Running tests with coverage..." | ||
| julia --project=. --code-coverage -e ' | ||
| using TestEnv; TestEnv.activate() | ||
| include("test/runtests.jl") | ||
| ' | ||
|
|
||
| echo "==> Generating lcov.info..." | ||
| julia --project=. -e ' | ||
| using TestEnv; TestEnv.activate() | ||
| include("scripts/generate_lcov.jl") | ||
| ' | ||
|
|
||
| echo "==> Done. lcov.info written to $(pwd)/lcov.info" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||
| ############################################################################### | ||||
| # Tests for core type definitions, interface fallbacks, and helper methods | ||||
| ############################################################################### | ||||
|
|
||||
| @testset "Network formulation capabilities" begin | ||||
| # supports_branch_filtering | ||||
| @test POM.supports_branch_filtering(PTDFPowerModel) == true | ||||
| @test POM.supports_branch_filtering(POM.SecurityConstrainedPTDFPowerModel) == true | ||||
|
|
||||
| # ignores_branch_filtering | ||||
| @test POM.ignores_branch_filtering(CopperPlatePowerModel) == true | ||||
| @test POM.ignores_branch_filtering(AreaBalancePowerModel) == true | ||||
|
|
||||
| # requires_all_branch_models | ||||
| @test POM.requires_all_branch_models(PTDFPowerModel) == false | ||||
| @test POM.requires_all_branch_models(CopperPlatePowerModel) == false | ||||
| @test POM.requires_all_branch_models(AreaBalancePowerModel) == false | ||||
| end | ||||
|
|
||||
| @testset "Expression type methods" begin | ||||
| # should_write_resulting_value | ||||
| @test IOM.should_write_resulting_value(POM.InterfaceTotalFlow) == true | ||||
| @test IOM.should_write_resulting_value(POM.PTDFBranchFlow) == true | ||||
| @test IOM.should_write_resulting_value(POM.HydroServedReserveUpExpression) == true | ||||
| @test IOM.should_write_resulting_value(POM.HydroServedReserveDownExpression) == true | ||||
| @test IOM.should_write_resulting_value(POM.TotalHydroFlowRateReservoirOutgoing) == true | ||||
| @test IOM.should_write_resulting_value(POM.TotalHydroFlowRateTurbineOutgoing) == true | ||||
|
|
||||
| # convert_output_to_natural_units | ||||
| @test IOM.convert_output_to_natural_units(POM.InterfaceTotalFlow) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.PTDFBranchFlow) == true | ||||
| end | ||||
|
|
||||
| @testset "Auxiliary variable type methods" begin | ||||
| # convert_output_to_natural_units | ||||
| @test IOM.convert_output_to_natural_units(POM.PowerOutput) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.PowerFlowBranchActivePowerFromTo) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.PowerFlowBranchActivePowerToFrom) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.PowerFlowBranchReactivePowerFromTo) == | ||||
| true | ||||
| @test IOM.convert_output_to_natural_units(POM.PowerFlowBranchReactivePowerToFrom) == | ||||
| true | ||||
| @test IOM.convert_output_to_natural_units(POM.PowerFlowBranchActivePowerLoss) == true | ||||
|
|
||||
| # is_from_power_flow | ||||
| @test IOM.is_from_power_flow(POM.PowerFlowVoltageAngle) == true | ||||
| @test IOM.is_from_power_flow(POM.PowerFlowVoltageMagnitude) == true | ||||
| @test IOM.is_from_power_flow(POM.PowerFlowBranchActivePowerFromTo) == true | ||||
| @test IOM.is_from_power_flow(POM.PowerFlowLossFactors) == true | ||||
| @test IOM.is_from_power_flow(POM.PowerFlowVoltageStabilityFactors) == true | ||||
| @test IOM.is_from_power_flow(POM.TimeDurationOn) == false | ||||
| @test IOM.is_from_power_flow(POM.PowerOutput) == false | ||||
| end | ||||
|
|
||||
| @testset "Parameter type methods" begin | ||||
| # convert_output_to_natural_units for parameters | ||||
| @test IOM.convert_output_to_natural_units(POM.ActivePowerTimeSeriesParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.ReactivePowerTimeSeriesParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.RequirementTimeSeriesParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.DynamicBranchRatingTimeSeriesParameter) == | ||||
| true | ||||
| @test IOM.convert_output_to_natural_units( | ||||
| POM.PostContingencyDynamicBranchRatingTimeSeriesParameter, | ||||
| ) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.UpperBoundValueParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.LowerBoundValueParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.EnergyLimitParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.EnergyTargetParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.ReservoirLimitParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.ReservoirTargetParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.EnergyTargetTimeSeriesParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.EnergyBudgetTimeSeriesParameter) == true | ||||
| @test IOM.convert_output_to_natural_units(POM.InflowTimeSeriesParameter) == false | ||||
| @test IOM.convert_output_to_natural_units(POM.OutflowTimeSeriesParameter) == false | ||||
|
|
||||
| # should_write_resulting_value for parameters | ||||
| @test IOM.should_write_resulting_value(POM.AvailableStatusParameter) == true | ||||
| @test IOM.should_write_resulting_value(POM.ActivePowerOffsetParameter) == true | ||||
| @test IOM.should_write_resulting_value(POM.ReactivePowerOffsetParameter) == true | ||||
| @test IOM.should_write_resulting_value(POM.AvailableStatusChangeCountdownParameter) == | ||||
| true | ||||
| end | ||||
|
|
||||
| @testset "Default interface methods" begin | ||||
| # get_multiplier_value defaults for OCC parameters | ||||
| gen = first( | ||||
| PSY.get_components(PSY.ThermalStandard, PSB.build_system(PSITestSystems, "c_sys5")), | ||||
| ) | ||||
| @test POM.get_multiplier_value( | ||||
| IOM.StartupCostParameter, | ||||
| gen, | ||||
| POM.ThermalStandardDispatch, | ||||
| ) == 1.0 | ||||
| @test POM.get_multiplier_value( | ||||
| IOM.ShutdownCostParameter, | ||||
| gen, | ||||
| POM.ThermalStandardDispatch, | ||||
| ) == 1.0 | ||||
|
|
||||
| # get_default_on_variable / get_default_on_parameter | ||||
| @test POM.get_default_on_variable(gen) isa POM.OnVariable | ||||
| @test POM.get_default_on_parameter(gen) isa IOM.OnStatusParameter | ||||
| end | ||||
|
|
||||
|
|
||||
|
Comment on lines
+104
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶