"""Functional tests for the reference flowthrough calculation.""" from abacus_contract.tests.utils.factories import ReferenceFlowthroughCalculationFactory def test_get_reference_flowthrough_calculation_by_id(fixture_client): """Test to get reference_flowthrough_calculation by ID.""" mock_reference_flowthrough_calculation = ( ReferenceFlowthroughCalculationFactory.create() ) reference_flowthrough_calculation_id = ( mock_reference_flowthrough_calculation.reference_flowthrough_calculation_id ) res = fixture_client.get( f'/reference-flowthrough-calculation/{reference_flowthrough_calculation_id}' ) assert res.status_code == 200 assert res.json == { 'reference_flowthrough_calculation_id': reference_flowthrough_calculation_id, 'flowthrough_calculation_name': mock_reference_flowthrough_calculation.flowthrough_calculation_name, 'flowthrough_calculation': mock_reference_flowthrough_calculation.flowthrough_calculation, 'flowthrough_calculation_example': mock_reference_flowthrough_calculation.flowthrough_calculation_example, 'flowthrough_calculation_example_summary': mock_reference_flowthrough_calculation.flowthrough_calculation_example_summary, } def test_get_reference_flowthrough_calculation_list(fixture_client): """Test to get a list of reference_flowthrough_calculation.""" mock_reference_flowthrough_calculations = ( ReferenceFlowthroughCalculationFactory.create_batch(2) ) res = fixture_client.get('/reference-flowthrough-calculations') assert res.status_code == 200 assert res.json.get('total_count') == 2 assert ( res.json.get('items')[0].get('reference_flowthrough_calculation_id') == mock_reference_flowthrough_calculations[ 0 ].reference_flowthrough_calculation_id ) assert ( res.json.get('items')[1].get('reference_flowthrough_calculation_id') == mock_reference_flowthrough_calculations[ 1 ].reference_flowthrough_calculation_id ) assert res.json.get('items') == [ { 'reference_flowthrough_calculation_id': mock_reference_flowthrough_calculations[ 0 ].reference_flowthrough_calculation_id, 'flowthrough_calculation_name': mock_reference_flowthrough_calculations[ 0 ].flowthrough_calculation_name, 'flowthrough_calculation': mock_reference_flowthrough_calculations[ 0 ].flowthrough_calculation, 'flowthrough_calculation_example': mock_reference_flowthrough_calculations[ 0 ].flowthrough_calculation_example, 'flowthrough_calculation_example_summary': mock_reference_flowthrough_calculations[ 0 ].flowthrough_calculation_example_summary, }, { 'reference_flowthrough_calculation_id': mock_reference_flowthrough_calculations[ 1 ].reference_flowthrough_calculation_id, 'flowthrough_calculation_name': mock_reference_flowthrough_calculations[ 1 ].flowthrough_calculation_name, 'flowthrough_calculation': mock_reference_flowthrough_calculations[ 1 ].flowthrough_calculation, 'flowthrough_calculation_example': mock_reference_flowthrough_calculations[ 1 ].flowthrough_calculation_example, 'flowthrough_calculation_example_summary': mock_reference_flowthrough_calculations[ 1 ].flowthrough_calculation_example_summary, }, ]