def test_amount_mass_vol(amount, units): ''' ensure mass is being returned correctly when 'amount' is initialized wtih 'mass' or 'volume' ''' spill = Spill(Release(datetime.now()), amount=amount, units=units, substance=test_oil) assert spill.amount == amount assert spill.units == units if units in Spill.valid_vol_units: exp_mass = (spill.get('substance').get_density() * uc.convert('Volume', units, 'm^3', spill.amount)) else: exp_mass = uc.convert('Mass', units, 'kg', spill.amount) assert spill.get_mass() == exp_mass exp_mass_g = exp_mass * 1000 assert spill.get_mass('g') == exp_mass_g
def test_amount_mass_vol(amount, units): ''' ensure mass is being returned correctly when 'amount' is initialized wtih 'mass' or 'volume' ''' spill = Spill(Release(datetime.now()), amount=amount, units=units, substance=test_oil) assert spill.amount == amount assert spill.units == units if units in Spill.valid_vol_units: exp_mass = (spill.get('substance').get_density() * uc.convert('Volume', units, 'm^3', spill.amount)) else: exp_mass = uc.convert('Mass', units, 'kg', spill.amount) assert spill.get_mass() == exp_mass exp_mass_g = exp_mass * 1000 assert spill.get_mass('g') == exp_mass_g
def test_amount_mass_vol(amount, units): ''' ensure mass is being returned correctly when 'amount' is initialized wtih 'mass' or 'volume' ''' water = Water() spill = Spill(Release(datetime.now()), amount=amount, units=units, substance=test_oil, water=water) assert spill.amount == amount assert spill.units == units if units in Spill.valid_vol_units: # use 15C (288.15K) for mass<=>volume conversion exp_mass = (spill.substance.density_at_temp(288.15) * uc.convert('Volume', units, 'm^3', spill.amount)) else: exp_mass = uc.convert('Mass', units, 'kg', spill.amount) assert spill.get_mass() == exp_mass exp_mass_g = exp_mass * 1000 assert spill.get_mass('g') == exp_mass_g
def test_amount_mass_vol(amount, units): ''' ensure mass is being returned correctly when 'amount' is initialized wtih 'mass' or 'volume' ''' water = Water() spill = Spill(Release(datetime.now()), amount=amount, units=units, substance=test_oil, water=water) assert spill.amount == amount assert spill.units == units if units in Spill.valid_vol_units: # use 15C (288.15K) for mass<=>volume conversion exp_mass = (spill.substance.density_at_temp(288.15) * uc.convert('Volume', units, 'm^3', spill.amount)) else: exp_mass = uc.convert('Mass', units, 'kg', spill.amount) assert spill.get_mass() == exp_mass exp_mass_g = exp_mass * 1000 assert spill.get_mass('g') == exp_mass_g