api_v1.4/tests/test_service.sh

126 lines
17 KiB
Bash
Executable File

#!/bin/bash
clear
printf 'Uptime:\n'
curl -i -X GET http://127.0.0.1:15789/v1.3/uptime
printf '\n\nSession start:\n'
curl -i -X PUT -H "Session: {'session_id': 'debug'}" http://127.0.0.1:15789/v1.3/session/start
printf '\n\nRepeat session start:\n'
curl -i -X PUT -H "Session: {'session_id': 'debug'}" http://127.0.0.1:15789/v1.3/session/start
printf '\n\nKeep session alive:\n'
curl -i -X PUT -H "Session: {'session_id': 'debug', 'token': 'debug'}" http://127.0.0.1:15789/v1.3/session/keep_alive
printf '\n\nCity info:\n'
curl -i -X GET -H "Session: {'session_id': 'debug', 'token': 'debug'}" http://127.0.0.1:15789/v1.3/city_info
printf '\n\nGreenery catalog entry without parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/entry
printf '\n\nGreenery catalog entry with wrong parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"name": "non_existing_name"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/entry
printf '\n\nGreenery catalog entry with correct parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"name": "grass"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/entry
printf '\n\nGreenery catalog names without parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/names
printf '\n\nGreenery catalog names with wrong parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"category": "non_existing_name"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/names
printf '\n\nGreenery catalog names with correct parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"category": "soils"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/names
printf '\n\nGreenery catalog entries without parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/entries
printf '\n\nGreenery catalog entries with wrong parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"category": "non_existing_category"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/entries
printf '\n\nGreenery catalog entries with correct parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"category": "vegetations"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery-catalog/entries
printf '\n\nGeometry:\n'
curl -i -X GET -H "Session: {'session_id': 'debug', 'token': 'debug'}" http://127.0.0.1:15789/v1.3/geometry
printf '\n\nHeat Pump:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"BuildingSuppTemp": 40, "EndYear": 2016, "FuelDensity": 0.717, "FuelEF": 1887, "FuelLHV": 47100, "FuelPrice": 0.3, "HPSupTemp": 60, "HeatPumpModel": "012", "HeatPumpType": "Air Source HP", "HoursOfStorageAtMaxDemand": 1, "MaximumHPEnergyInput": 8000, "SimType": 0, "StartYear": 2015, "TemperatureDifference": 15 }' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/heat-pump
printf '\n\Material LCA Catalog:\n'
curl -i -X GET -H "Session: {'session_id': 'debug', 'token': 'debug'}" http://127.0.0.1:15789/v1.3/material_lca_catalog/entries
printf '\n\Material LCA Calculations:\n'
curl -i -X GET -H "Session: {'session_id': 'debug', 'token': 'debug'}" http://127.0.0.1:15789/v1.3/material_lca_catalog/calculations
printf '\n\nConstruction catalog entry without parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/entry
printf '\n\nConstruction catalog entry with wrong parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"name": "non_existing_name"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/entry
printf '\n\nConstruction catalog entry with correct parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"name": "189.1-2009 Nonres 4B Ext Wall Mass"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/entry
printf '\n\nConstruction catalog names without parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/names
printf '\n\nConstruction catalog names with wrong parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"category": "non_existing_name"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/names
printf '\n\nConstruction catalog names with correct parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"category": "materials"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/names
printf '\n\nConstruction catalog entries without parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/entries
printf '\n\nConstruction catalog entries with wrong parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"category": "non_existing_category"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/entries
printf '\n\nConstruction catalog entries with correct parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"category": "archetypes"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction-catalog/entries
printf '\n\nSet Construction without building names:\n'
curl -i -X PUT -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"extra_loses_due_to_thermal_bridges":"0.15","indirect_heated_ratio":"0.15","infiltration_rate_for_ventilation_system_off":"0.5","infiltration_rate_for_ventilation_system_on":"0","constructions":[{"type":"Wall","layers":[{"thickness":"0.0253","material":{"solar_absorptance":"0.92","thermal_absorptance":"0.9","visible_absorptance":"0.92","no_mass":"False","thermal_resistance":"","conductivity":"0.6918","density":"1858","specific_heat":"837"}},{"thickness":"0.2033","material":{"solar_absorptance":"0.65","thermal_absorptance":"0.9","visible_absorptance":"0.65","no_mass":"False","thermal_resistance":"","conductivity":"1.7296","density":"2243","specific_heat":"837"}},{"thickness":"0.0338606","material":{"solar_absorptance":"0.5","thermal_absorptance":"0.9","visible_absorptance":"0.5","no_mass":"False","thermal_resistance":"","conductivity":"0.0432","density":"91","specific_heat":"837"}},{"thickness":"0.01271","material":{"solar_absorptance":"0.92","thermal_absorptance":"0.9","visible_absorptance":"0.92","no_mass":"False","thermal_resistance":"","conductivity":"0.16","density":"784.9","specific_heat":"830"}}],"window":{"frame_ratio":"0","g_value":"0.36","overall_u_value":"4.491833333333333"}},{"type":"Ground","layers":[{"thickness":"0.1016","material":{"solar_absorptance":"0.7","thermal_absorptance":"0.9","visible_absorptance":"0.7","no_mass":"False","thermal_resistance":"","conductivity":"1.311","density":"2240","specific_heat":"836.8"}},{"thickness":0,"material":{"solar_absorptance":"0.7","thermal_absorptance":"0.9","visible_absorptance":"0.8","no_mass":"True","thermal_resistance":"0.21648","conductivity":"","density":"","specific_heat":""}}]},{"type":"Roof","layers":[{"thickness":"0.0178","material":{"solar_absorptance":"0.78","thermal_absorptance":"0.9","visible_absorptance":"0.78","no_mass":"False","thermal_resistance":"","conductivity":"0.115","density":"513","specific_heat":"1255"}},{"thickness":"0.0254","material":{"solar_absorptance":"0.78","thermal_absorptance":"0.9","visible_absorptance":"0.78","no_mass":"False","thermal_resistance":"","conductivity":"0.1211","density":"593","specific_heat":"2510"}},{"thickness":"0.221604","material":{"solar_absorptance":"0.7","thermal_absorptance":"0.9","visible_absorptance":"0.7","no_mass":"False","thermal_resistance":"","conductivity":"0.049","density":"265","specific_heat":"836.8"}},{"thickness":"0.01271","material":{"solar_absorptance":"0.92","thermal_absorptance":"0.9","visible_absorptance":"0.92","no_mass":"False","thermal_resistance":"","conductivity":"0.16","density":"784.9","specific_heat":"830"}}],"window":{"frame_ratio":"0","g_value":"0.36","overall_u_value":"4.491833333333333"}}]}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction
printf '\n\nSet Construction:\n'
curl -i -X PUT -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"building_names":["Dompark"], "extra_loses_due_to_thermal_bridges":"0.15","indirect_heated_ratio":"0.15","infiltration_rate_for_ventilation_system_off":"0.5","infiltration_rate_for_ventilation_system_on":"0","constructions": [{"name": "189.1-2009 Res 4B Ext Wall Steel-Framed", "type": "Wall", "layers": [{"name": "Layer 1", "thickness": 0, "material": {"id": "12", "name": "MAT-SHEATH", "solar_absorptance": "0.7", "thermal_absorptance": "0.9", "visible_absorptance": "0.7", "no_mass": "True", "thermal_resistance": "0.36256", "conductivity": "", "density": "", "specific_heat": ""}}, {"name": "Layer 2", "thickness": "0.118387", "material": {"id": "3", "name": "Floor Insulation [4]", "solar_absorptance": "0.7", "thermal_absorptance": "0.9", "visible_absorptance": "0.7", "no_mass": "False", "thermal_resistance": "", "conductivity": "0.045", "density": "265", "specific_heat": "836.8"}}, {"name": "Layer 3", "thickness": "0.01271", "material": {"id": "7", "name": "1/2IN Gypsum", "solar_absorptance": "0.92", "thermal_absorptance": "0.9", "visible_absorptance": "0.92", "no_mass": "False", "thermal_resistance": "", "conductivity": "0.16", "density": "784.9", "specific_heat": "830"}}], "window_ratio": "0.3", "window": {"name": "189.1-2009 Nonres 4B Window Nonmetal framing", "frame_ratio": "0", "g_value": "0.35", "overall_u_value": "2.379966666666667"}}, {"name": "189.1-2009 Nonres 4B Ext Slab Unheated - 4in Slab with Carpet", "type": "Ground", "layers": [{"name": "Layer 1", "thickness": "0.1016", "material": {"id": "1", "name": "MAT-CC05 8 HW CONCRETE", "solar_absorptance": "0.7", "thermal_absorptance": "0.9", "visible_absorptance": "0.7", "no_mass": "False", "thermal_resistance": "", "conductivity": "1.311", "density": "2240", "specific_heat": "836.8"}}, {"name": "Layer 2", "thickness": 0, "material": {"id": "16", "name": "CP02 CARPET PAD", "solar_absorptance": "0.7", "thermal_absorptance": "0.9", "visible_absorptance": "0.8", "no_mass": "True", "thermal_resistance": "0.21648", "conductivity": "", "density": "", "specific_heat": ""}}]}, {"name": "189.1-2009 Nonres 4B Roof IEAD", "type": "Roof", "layers": [{"name": "Layer 1", "thickness": "0.0095", "material": {"id": "15", "name": "Roof Membrane", "solar_absorptance": "0.7", "thermal_absorptance": "0.9", "visible_absorptance": "0.7", "no_mass": "False", "thermal_resistance": "", "conductivity": "0.16", "density": "1121.29", "specific_heat": "1460"}}, {"name": "Layer 2", "thickness": "0.210538", "material": {"id": "11", "name": "Roof Insulation [23]", "solar_absorptance": "0.7", "thermal_absorptance": "0.9", "visible_absorptance": "0.7", "no_mass": "False", "thermal_resistance": "", "conductivity": "0.049", "density": "265", "specific_heat": "836.8"}}, {"name": "Layer 3", "thickness": "0.001524", "material": {"id": "14", "name": "Metal Decking", "solar_absorptance": "0.7", "thermal_absorptance": "0.9", "visible_absorptance": "0.3", "no_mass": "False", "thermal_resistance": "", "conductivity": "45.006", "density": "7680", "specific_heat": "418.4"}}]}]}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/construction
printf '\n\nEnergy Demand:\n'
curl -i -X GET -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/energy-demand
printf '\n\nUsage catalog entry without parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/usage-catalog/entry
printf '\n\nUsage catalog entry with wrong parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"name": "non_existing_name"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/usage-catalog/entry
printf '\n\nUsage catalog entry with correct parameter:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"name": "BA Automotive Facility"}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/usage-catalog/entry
printf '\n\nUsage catalog names:\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/usage-catalog/names
printf '\n\nUsage catalog entries :\n'
curl -i -X POST -H "Session: {'session_id': 'debug', 'token': 'debug'}" -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/usage-catalog/entries
printf '\n\nSet Greenery with missing parameters:\n'
curl -i -X PUT --header "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"vegetation": {"vegetation_name": "Grass", "soil_thickness": "0.2", "air_gap": "0.0", "soil_name": "Loamy sand", "soil_roughness": "MediumRough", "dry_soil_conductivity": "0.35", "dry_soil_density": "1100", "dry_soil_specific_heat": "1200", "soil_thermal_absorptance": "0.9", "soil_solar_absorptance": "0.7", "soil_visible_absorptance": "0.75", "soil_saturation_volumetric_moisture_content": "0.41", "soil_residual_volumetric_moisture_content": "0.057", "plant_percentages": [{"plant_percentage": "100", "plant_name": "Lawn", "plant_height": "0.06", "plant_leaf_area_index": "1.4", "plant_leaf_reflectivity": "0.1", "plant_leaf_emissivity": "0.9", "plant_minimal_stomatal_resistance": "50", "plant_co2_sequestration": "0", "plant_grows_on": [{"soil_name": "Loam", "soil_roughness": "MediumRough", "soil_dry_conductivity": "0.67", "soil_dry_density": "1100", "soil_dry_specific_heat": "900", "soil_thermal_absortance": "0.9", "soil_solar_absortance": "0.7", "soil_visible_absortance": "0.75", "soil_saturation_volumetric_moisture_content": "0.43", "soil_residual_volumetric_moisture_content": "0.078", "soil_initial_volumetric_moisture_content": "0.1"}]}]}}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery
printf '\n\nSet Greenery:\n'
curl -i -X PUT --header "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"building_names":["Dompark"], "greenery_percentage":"30", "vegetation": {"vegetation_name": "Grass", "soil_thickness": "0.2", "air_gap": "0.0", "soil_name": "Loamy sand", "soil_roughness": "MediumRough", "dry_soil_conductivity": "0.35", "dry_soil_density": "1100", "dry_soil_specific_heat": "1200", "soil_thermal_absorptance": "0.9", "soil_solar_absorptance": "0.7", "soil_visible_absorptance": "0.75", "soil_saturation_volumetric_moisture_content": "0.41", "soil_residual_volumetric_moisture_content": "0.057", "plant_percentages": [{"plant_percentage": "100", "plant_name": "Lawn", "plant_height": "0.06", "plant_leaf_area_index": "1.4", "plant_leaf_reflectivity": "0.1", "plant_leaf_emissivity": "0.9", "plant_minimal_stomatal_resistance": "50", "plant_co2_sequestration": "0", "plant_grows_on": [{"soil_name": "Loam", "soil_roughness": "MediumRough", "soil_dry_conductivity": "0.67", "soil_dry_density": "1100", "soil_dry_specific_heat": "900", "soil_thermal_absortance": "0.9", "soil_solar_absortance": "0.7", "soil_visible_absortance": "0.75", "soil_saturation_volumetric_moisture_content": "0.43", "soil_residual_volumetric_moisture_content": "0.078", "soil_initial_volumetric_moisture_content": "0.1"}]}]}}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/greenery
printf '\n\nSet Usages with missing parameters:\n'
curl -i -X PUT --header "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"building_names":["Dompark"],"usages":[{"name": "BA Convention Center"}, {"name": "BA Multifamily", "percentage": "0.2"}, {"name": "BA Office", "percentage": "0.75"}]}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/usage
printf '\n\nSet Usages:\n'
curl -i -X PUT --header "Session: {'session_id': 'debug', 'token': 'debug'}" -d '{"building_names":["Dompark"],"usages":[{"name": "BA Convention Center", "percentage": "0.05"}, {"name": "BA Multifamily", "percentage": "0.2"}, {"name": "BA Office", "percentage": "0.75"}]}' -H "Content-Type: application/json" http://127.0.0.1:15789/v1.3/usage
printf '\n\nSession end:\n'
curl -i -X PUT -H "Session: {'session_id': 'debug', 'token': 'debug'}" http://127.0.0.1:15789/v1.3/session/end
printf '\n\nRepeat session end:\n'
curl -i -X PUT -H "Session: {'session_id': 'debug', 'token': 'debug'}" http://127.0.0.1:15789/v1.3/session/end
printf '\n'