def test_process_grid_set(): rep = schema205.load_json( 'examples/RS0004/DX-Constant-Efficiency.RS0004.a205.json') grid_vars = rep['performance']['performance_map_cooling']['grid_variables'] schema = schema205.A205Schema( os.path.join(os.path.dirname(__file__), '..', 'build', "schema", "RS0004.schema.json")) grid_set = schema.create_grid_set( rep, ['performance', 'performance_map_cooling', 'grid_variables']) grid_vars2 = schema205.util.process_grid_set(grid_set) assert (grid_vars == grid_vars2)
def test_get_representation_node_and_rs_selections(): rep = schema205.load_json( 'examples/RS0002/Unitary-Constant-Efficiency.RS0002.a205.json') node, rs_selections = schema205.util.get_representation_node_and_rs_selections( rep, [ 'RS_instance', 'performance', 'DX_system_representation', 'RS_instance', 'performance', 'performance_map_cooling', 'grid_variables' ]) assert (len(node) == 6) assert (rs_selections[0] == schema205.util.get_rs_index('RS0002')) assert (rs_selections[3] == schema205.util.get_rs_index('RS0004'))
def test_create_grid_set(): rep = schema205.load_json( 'examples/RS0004/DX-Constant-Efficiency.RS0004.a205.json') schema = schema205.A205Schema( os.path.join(os.path.dirname(__file__), '..', 'build', "schema", "RS0004.schema.json")) grid_set = schema.create_grid_set( rep, ['performance', 'performance_map_cooling', 'grid_variables']) table_length = 1 grid_vars = rep['performance']['performance_map_cooling']['grid_variables'] for var in grid_vars: table_length *= len(grid_vars[var]) for var in grid_vars: assert (table_length == len(grid_set[var]))
def test_validate(example): schema_name = schema205.load_json(example)["metadata"]["schema"] schema_path = os.path.join(SCHEMA_DIR,f"{schema_name}.schema.json") schema205.schema.validate(example, schema_path)