def it_creates_the_expected_new_network_record(session): network = get_or_create_pcic_climate_variables_network(session) results = session.query(Network).filter(Network.name == pcic_climate_variable_network_name) assert results.count() == 1 result = results.first() assert network.id == result.id assert result.publish is True assert 'PCIC' in result.long_name
def test_creates_the_expected_new_network_record(empty_database_session): sesh = empty_database_session network = get_or_create_pcic_climate_variables_network(sesh) results = sesh.query(Network).filter(Network.name == pcic_climate_variable_network_name) assert results.count() == 1 result = results.first() assert network.id == result.id assert result.publish == True assert 'PCIC' in result.long_name
def test_creates_precip_variable(sesh_with_climate_baseline_variables): sesh = sesh_with_climate_baseline_variables network = get_or_create_pcic_climate_variables_network(sesh) result = sesh.query(Variable).filter(Variable.name == 'Precip_Climatology').first() assert (result.unit, result.standard_name, result.network_id) == \ (u'mm', u'lwe_thickness_of_precipitation_amount', network.id) assert result.short_name == u'lwe_thickness_of_precipitation_amount {}'.format(result.cell_method) assert result.cell_method == u't: sum within months t: mean over years' assert result.description == u'Climatological mean of monthly total precipitation' assert result.display_name == u'Precipitation Climatology'
def test_creates_temperature_variables(sesh_with_climate_baseline_variables, name, keyword, kwd): sesh = sesh_with_climate_baseline_variables network = get_or_create_pcic_climate_variables_network(sesh) result = sesh.query(Variable).filter(Variable.name == name).first() assert result assert (result.unit, result.standard_name, result.network_id) == \ (u'celsius', u'air_temperature', network.id) assert result.short_name == u'air_temperature {}'.format(result.cell_method) assert result.cell_method == u't: {} within days t: mean within months t: mean over years'.format(keyword) assert result.description == u'Climatological mean of monthly mean of {} daily temperature'.format(keyword) assert result.display_name == u'Temperature Climatology ({})'.format(kwd)
def it_creates_no_more_than_one_of_them(session): get_or_create_pcic_climate_variables_network(session) get_or_create_pcic_climate_variables_network(session) results = session.query(Network).filter(Network.name == pcic_climate_variable_network_name) assert results.count() == 1
def test_creates_no_more_than_one_of_them(empty_database_session): sesh = empty_database_session get_or_create_pcic_climate_variables_network(sesh) get_or_create_pcic_climate_variables_network(sesh) results = sesh.query(Network).filter(Network.name == pcic_climate_variable_network_name) assert results.count() == 1