diff --git a/spec/fixtures/assertions/RdSAP-Schema-21.0.0/to_hash.json b/spec/fixtures/assertions/RdSAP-Schema-21.0.0/to_hash.json new file mode 100644 index 0000000..111e1e6 --- /dev/null +++ b/spec/fixtures/assertions/RdSAP-Schema-21.0.0/to_hash.json @@ -0,0 +1,207 @@ +{ + "type_of_assessment": "RdSAP", + "assessment_id": "0000-0000-0000-0000-0000", + "date_of_expiry": "2030-05-03", + "date_of_assessment": "2020-05-04", + "date_of_registration": "2020-05-04", + "date_registered": "2020-05-04", + "address_line1": "1 Some Street", + "address_line2": "", + "address_line3": "", + "address_line4": "", + "town": "Whitbury", + "postcode": "A0 0AA", + "address": { + "address_id": "UPRN-000000000000", + "address_line1": "1 Some Street", + "address_line2": "", + "address_line3": "", + "address_line4": "", + "town": "Whitbury", + "postcode": "A0 0AA" + }, + "assessor": { + "scheme_assessor_id": "SPEC000000", + "name": "Testa Sessor", + "contact_details": { + "email": "a@b.c", + "telephone": "0555 497 2848" + } + }, + "current_carbon_emission": 0.24e1, + "current_energy_efficiency_band": "e", + "current_energy_efficiency_rating": 50, + "dwelling_type": "Mid-terrace house", + "estimated_energy_cost": "689.83", + "main_fuel_type": "26", + "heat_demand": { + "current_space_heating_demand": 13120, + "current_water_heating_demand": 2285, + "impact_of_cavity_insulation": -122, + "impact_of_loft_insulation": -2114, + "impact_of_solid_wall_insulation": -3560 + }, + "heating_cost_current": "365.98", + "heating_cost_potential": "250.34", + "hot_water_cost_current": "200.40", + "hot_water_cost_potential": "180.43", + "lighting_cost_current": "123.45", + "lighting_cost_potential": "84.23", + "potential_carbon_emission": 0.14e1, + "potential_energy_efficiency_band": "c", + "potential_energy_efficiency_rating": 72, + "potential_energy_saving": "174.83", + "primary_energy_use": "230", + "energy_consumption_potential": "88", + "property_age_band": "M", + "property_summary": [ + { + "energy_efficiency_rating": 1, + "environmental_efficiency_rating": 1, + "name": "wall", + "description": "Solid brick, as built, no insulation (assumed)" + }, + { + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4, + "name": "wall", + "description": "Cavity wall, as built, insulated (assumed)" + }, + { + "energy_efficiency_rating": 2, + "environmental_efficiency_rating": 2, + "name": "roof", + "description": "Pitched, 25 mm loft insulation" + }, + { + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4, + "name": "roof", + "description": "Pitched, 250 mm loft insulation" + }, + { + "energy_efficiency_rating": 0, + "environmental_efficiency_rating": 0, + "name": "floor", + "description": "Suspended, no insulation (assumed)" + }, + { + "energy_efficiency_rating": 0, + "environmental_efficiency_rating": 0, + "name": "floor", + "description": "Solid, insulated (assumed)" + }, + { + "energy_efficiency_rating": 3, + "environmental_efficiency_rating": 3, + "name": "window", + "description": "Fully double glazed" + }, + { + "energy_efficiency_rating": 3, + "environmental_efficiency_rating": 1, + "name": "main_heating", + "description": "Boiler and radiators, anthracite" + }, + { + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4, + "name": "main_heating", + "description": "Boiler and radiators, mains gas" + }, + { + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4, + "name": "main_heating_controls", + "description": "Programmer, room thermostat and TRVs" + }, + { + "energy_efficiency_rating": 5, + "environmental_efficiency_rating": 5, + "name": "main_heating_controls", + "description": "Time and temperature zone control" + }, + { + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4, + "name": "hot_water", + "description": "From main system" + }, + { + "energy_efficiency_rating": 4, + "environmental_efficiency_rating": 4, + "name": "lighting", + "description": "Low energy lighting in 50% of fixed outlets" + }, + { + "energy_efficiency_rating": 0, + "environmental_efficiency_rating": 0, + "name": "secondary_heating", + "description": "Room heaters, electric" + } + ], + "recommended_improvements": [ + { + "energy_performance_rating_improvement": 50, + "environmental_impact_rating_improvement": 50, + "green_deal_category_code": null, + "improvement_category": "6", + "improvement_code": "5", + "improvement_description": null, + "improvement_title": "", + "improvement_type": "Z3", + "indicative_cost": "£100 - £350", + "sequence": 1, + "typical_saving": "360", + "energy_performance_band_improvement": "e" + }, + { + "energy_performance_rating_improvement": 60, + "environmental_impact_rating_improvement": 64, + "green_deal_category_code": null, + "improvement_category": "2", + "improvement_code": "1", + "improvement_description": null, + "improvement_title": "", + "improvement_type": "Z2", + "indicative_cost": "2000", + "sequence": 2, + "typical_saving": "99", + "energy_performance_band_improvement": "d" + }, + { + "energy_performance_rating_improvement": 60, + "environmental_impact_rating_improvement": 64, + "green_deal_category_code": null, + "improvement_category": "2", + "improvement_code": null, + "improvement_description": "Improvement desc", + "improvement_title": "", + "improvement_type": "Z2", + "indicative_cost": "1000", + "sequence": 3, + "typical_saving": "99", + "energy_performance_band_improvement": "d" + } + ], + "lzc_energy_sources": null, + "related_party_disclosure_number": null, + "related_party_disclosure_text": "No related party", + "tenure": "1", + "transaction_type": "16", + "total_floor_area": 0.55e2, + "status": "ENTERED", + "country_code": "ENG", + "environmental_impact_current": 52, + "environmental_impact_potential": 74, + "addendum": { + "addendum_number": [ + 1, + 8 + ], + "stone_walls": true, + "system_build": true + }, + "gas_smart_meter_present": false, + "electricity_smart_meter_present": true +} \ No newline at end of file diff --git a/spec/view_model/rdsap_wrapper_new_spec.rb b/spec/view_model/rdsap_wrapper_new_spec.rb new file mode 100644 index 0000000..210507e --- /dev/null +++ b/spec/view_model/rdsap_wrapper_new_spec.rb @@ -0,0 +1,15 @@ +require_relative "../wrapper_test_helper" + +RSpec.describe ViewModel::RdSapWrapper do + context "when calling the RdSAP wrapper for a valid schema" do + it "returns the expected assertion" do + schema_tests = [ + { schema: "RdSAP-Schema-21.0.0", type: "epc", method_called: :to_hash } + ] + + schema_tests.each do |schema| + test_wrapper(schema) + end + end + end +end diff --git a/spec/wrapper_test_helper.rb b/spec/wrapper_test_helper.rb index 2834b6a..95668c8 100644 --- a/spec/wrapper_test_helper.rb +++ b/spec/wrapper_test_helper.rb @@ -52,9 +52,7 @@ def fetch_assertion(assertion, method_called, type) unless File.exist? assertion_path raise ArgumentError, - "No assertion found for schema #{schema}, create one at #{ - assertion_path - }" + "No assertion found for schema #{assertion}, create one at #{assertion_path}" end json_assertion = File.read assertion_path