def test_exception_new_from_dict(): # WindMover does not modify Wind object! wm = WindMover(environment.Wind(filename=file_)) wm_state = wm.to_dict('create') wm_state.update({'wind': environment.Wind(filename=file_)}) with pytest.raises(ValueError): WindMover.new_from_dict(wm_state)
def test_new_from_dict(): """ Currently only checks that new object can be created from dict It does not check equality of objects """ wind = environment.Wind(filename=file_) wm = WindMover(wind) # WindMover does not modify Wind object! wm_state = wm.to_dict('create') # must create a Wind object and add this to wm_state dict wind2 = environment.Wind.new_from_dict(wind.to_dict('create')) wm_state.update({'wind': wind2}) wm2 = WindMover.new_from_dict(wm_state) assert wm is not wm2 assert wm.wind is not wm2.wind assert wm == wm2
def test_new_from_dict(): """ Currently only checks that new object can be created from dict It does not check equality of objects """ wind = environment.Wind(filename=file_) wm = WindMover(wind) # WindMover does not modify Wind object! wm_state = wm.to_dict('create') # must create a Wind object and add this to wm_state dict wind2 = environment.Wind.new_from_dict(wind.to_dict('create')) wm_state.update({'wind': wind2}) wm2 = WindMover.new_from_dict(wm_state) # check serializable state is correct assert all([wm.__getattribute__(k) == wm2.__getattribute__(k) for k in WindMover.state.get_names('create') if k != 'wind_id' and k != 'obj_type']) assert wm.wind.id == wm2.wind.id