def test_serialize_deseriailize(): 'test serialize/deserialize for webapi' wind = constant_wind(1., 0) water = Water() w = Waves(wind, water) json_ = w.serialize() # deserialize and ensure the dict's are correct w2 = Waves.deserialize(json_) assert w2.wind == Wind.deserialize(json_['wind']) assert w2.water == Water.deserialize(json_['water']) assert w == w2
def deserialize(cls, json_): """ ChemicalDispersion could include 'waves'. """ schema = cls._schema() _to_dict = schema.deserialize(json_) if "waves" in json_ and json_["waves"] is not None: _to_dict["waves"] = Waves.deserialize(json_["waves"]) return _to_dict
def deserialize(cls, json_): """ ChemicalDispersion could include 'waves'. """ schema = cls._schema() _to_dict = schema.deserialize(json_) if 'waves' in json_ and json_['waves'] is not None: _to_dict['waves'] = Waves.deserialize(json_['waves']) return _to_dict
def test_serialize_deseriailize(): 'test serialize/deserialize for webapi' wind = constant_wind(15., 0) waves = Waves(wind, Water()) e = NaturalDispersion(waves) json_ = e.serialize() json_['waves'] = waves.serialize() # deserialize and ensure the dict's are correct d_ = NaturalDispersion.deserialize(json_) assert d_['waves'] == Waves.deserialize(json_['waves']) d_['waves'] = waves e.update_from_dict(d_) assert e.waves is waves
def test__deserialize(): 'test serialize/deserialize for webapi' wind = constant_wind(15., 0) water = Water() waves = Waves(wind, water) diss = Dissolution(waves, wind) json_ = diss.serialize() pp.pprint(json_) assert json_['waves'] == waves.serialize() # deserialize and ensure the dict's are correct d_ = Dissolution.deserialize(json_) assert d_['waves'] == Waves.deserialize(json_['waves']) d_['waves'] = waves diss.update_from_dict(d_) assert diss.waves is waves
def test_serialize_deseriailize(): 'test serialize/deserialize for webapi' wind = constant_wind(15., 0) water = Water() waves = Waves(wind, water) diss = Dissolution(waves) json_ = diss.serialize() pp.pprint(json_) assert json_['waves'] == waves.serialize() # deserialize and ensure the dict's are correct d_ = Dissolution.deserialize(json_) assert d_['waves'] == Waves.deserialize(json_['waves']) d_['waves'] = waves diss.update_from_dict(d_) assert diss.waves is waves
def test_serialize_deseriailize(): "test serialize/deserialize for webapi" wind = constant_wind(1.0, 0) water = Water() w = Waves(wind, water) json_ = w.serialize() json_["wind"] = wind.serialize() json_["water"] = water.serialize() # deserialize and ensure the dict's are correct d_ = Waves.deserialize(json_) print "d_" print d_ assert d_["wind"] == Wind.deserialize(json_["wind"]) assert d_["water"] == Water.deserialize(json_["water"]) d_["wind"] = wind d_["water"] = water w.update_from_dict(d_) assert w.wind is wind assert w.water is water
def test_serialize_deseriailize(): 'test serialize/deserialize for webapi' wind = constant_wind(1., 0) water = Water() w = Waves(wind, water) json_ = w.serialize() json_['wind'] = wind.serialize() json_['water'] = water.serialize() # deserialize and ensure the dict's are correct d_ = Waves.deserialize(json_) print 'd_' print d_ assert d_['wind'] == Wind.deserialize(json_['wind']) assert d_['water'] == Water.deserialize(json_['water']) d_['wind'] = wind d_['water'] = water w.update_from_dict(d_) assert w.wind is wind assert w.water is water
def test_serialize_deseriailize(): 'test serialize/deserialize for webapi' wind = constant_wind(15., 0) water = Water() waves = Waves(wind, water) bio_deg = Biodegradation(waves) json_ = bio_deg.serialize() pp.pprint(json_) assert json_['waves'] == waves.serialize() # deserialize and ensure the dict's are correct d_ = Biodegradation.deserialize(json_) assert d_['waves'] == Waves.deserialize(json_['waves']) d_['waves'] = waves bio_deg.update_from_dict(d_) assert bio_deg.waves is waves