def test_add_dvis_to_oil(self): oil_obj = ImportedRecord(**OilTestCase.get_mock_oil_file_record()) dvis_obj = DVis(**DVisTestCase.get_mock_dvis_file_record()) oil_obj.dvis.append(dvis_obj) self.add_objs_and_assert_ids([oil_obj, dvis_obj]) assert oil_obj.dvis == [dvis_obj] assert dvis_obj.imported == oil_obj
def add_dynamic_viscosities(oil, row_dict): for i in range(1, 7): obj_args = ('kg_ms', 'ref_temp_k', 'weathering') row_fields = ['dvis{0}_{1}'.format(i, a) for a in obj_args] if any([row_dict.get(k) for k in row_fields]): dvisargs = {} for col, arg in zip(row_fields, obj_args): dvisargs[arg] = row_dict.get(col) fix_weathering(dvisargs) oil.dvis.append(DVis(**dvisargs))
def get_oil_viscosities_at_5c(oil_columns, field_indexes, weathering): viscosities = [] props = get_oil_properties_by_category(oil_columns, field_indexes, 'viscosity_at_0_5_c_mpa_s') prop_names = props.keys() for idx, vals in enumerate(zip(*props.values())): dvis_kwargs = build_dvis_kwargs(prop_names, vals, 'viscosity_at_5_c_mpa_s', weathering[idx], 273.15 + 5.0) viscosities.append(dvis_kwargs) return [DVis(**v) for v in viscosities if v['kg_ms'] not in (None, 0.0)]
def test_init_with_args(self): dvis_obj = DVis(**self.get_mock_dvis_file_record()) self.assert_mock_dvis_object(dvis_obj) self.add_objs_and_assert_ids(dvis_obj)
def test_init_no_args(self): dvis_obj = DVis() self.add_objs_and_assert_ids(dvis_obj)