temoa icon indicating copy to clipboard operation
temoa copied to clipboard

Add test scenarios exercising ConstructionInput and EndOfLifeOutput paths

Open coderabbitai[bot] opened this issue 2 months ago • 0 comments

Context

This issue tracks the enhancement suggested in PR #177 review comment: https://github.com/TemoaProject/temoa/pull/177#discussion_r2464156032

Currently, all test scenarios in tests/test_network_model_data.py set ConstructionInput and EndOfLifeOutput tables to empty lists, which means regressions in those code paths won't be caught.

Objective

Add at least one test scenario that includes non-empty ConstructionInput and EndOfLifeOutput data to validate:

  • Construction creates demand on the appropriate technology
  • EOL produces expected waste commodities
  • Lifetime handling is correct

Draft Test Scenario

{
    'name': 'construction_and_eol',
    'db_data': {
        'Technology WHERE retire==1': [],
        'FROM SurvivalCurve': [],
        'FROM TimePeriod': [(2020,), (2025,), (2030,)],
        'FROM main.Commodity': [('s1',), ('p1',), ('d1',), ('waste1',), ('construct_mat',)],
        "Commodity WHERE flag LIKE '%p%'": [('s1',), ('p1',), ('d1',), ('waste1',), ('construct_mat',)],
        "Commodity WHERE flag LIKE '%w%'": [('waste1',)],
        "Commodity WHERE flag = 's'": [('s1',)],
        "Commodity WHERE flag LIKE '%p%' OR flag = 's' OR flag LIKE '%a%'": [
            ('s1',), ('p1',), ('d1',), ('waste1',), ('construct_mat',)
        ],
        'FROM main.Demand': [('R1', 2020, 'd1')],
        'FROM main.Efficiency': [
            ('R1', 's1', 't1', 2020, 'p1', 30),  # lifetime=30 years
            ('R1', 'p1', 't2', 2020, 'd1', 20),  # lifetime=20 years
        ],
        'FROM EndOfLifeOutput': [
            ('R1', 't1', 2020, 'waste1', 0.8),  # t1 produces waste at EOL
        ],
        'FROM ConstructionInput': [
            ('R1', 't1', 2020, 'construct_mat', 5.0),  # t1 needs construct_mat
        ],
        'FROM main.LinkedTech': [],
        'FROM CostVariable': [],
    },
    'expected': {
        'demands_count': 1,
        'techs_count': 2,
        'valid_techs': 2,
        'demand_orphans': 0,
        'other_orphans': 0,
        'unsupported_demands': set(),
        # Additional assertions for Construction/EOL:
        'has_construction_demand': True,
        'has_eol_waste': True,
        'construction_commodity': 'construct_mat',
        'waste_commodity': 'waste1',
    },
}

Implementation Notes

  • Add the new scenario to test_scenarios list in tests/test_network_model_data.py
  • Extend test_network_build_and_analysis or create a dedicated test function to assert:
    • construct_mat appears in appropriate demand or capacity commodity sets
    • waste1 appears in waste_commodities
    • Lifetime values are correctly loaded and accessible via tech_data
  • Ensure the test validates both the initial data loading and the network analysis results

Related

  • Requested by: @ParticularlyPythonicBS
  • Original review comment: https://github.com/TemoaProject/temoa/pull/177#discussion_r2464156032

coderabbitai[bot] avatar Oct 27 '25 14:10 coderabbitai[bot]