Improving Image _json_to_obj method

The previous method had a side-effect of actually deleting the entry
from object passed and therefore could not be used in a static context,
e.g. in a @classmethod

Change-Id: I0e560452f902db6c6b3bda73bc21b95c9b706cd6
This commit is contained in:
sw00 2013-08-15 17:56:46 +02:00
parent 8bbec6fdf0
commit c23ae6daf4
2 changed files with 4 additions and 3 deletions

View File

@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from copy import deepcopy
from cafe.engine.models.base import AutoMarshallingModel
from cloudcafe.compute.common.equality_tools import EqualityTools
@ -98,8 +99,8 @@ class Image(AutoMarshallingModel):
@classmethod
def _dict_to_obj(cls, json_dict):
"""@summary: Processing dates in converting string to date objects"""
json_dict['id_'] = json_dict['id']
del json_dict['id']
json_dict = deepcopy(json_dict)
json_dict['id_'] = json_dict.pop('id')
for date_key in ['created_at', 'updated_at', 'deleted_at']:
if json_dict.get(date_key):

View File

@ -67,7 +67,7 @@ class TestImage(object):
assert member1 in self.image_one.members_list
def test_remove_member_from_an_image(self):
image = Image._json_to_obj(self.raw_image_str)
image = Image._dict_to_obj(self._dict)
member1 = Member(member_id='1')
member2 = Member(member_id='2')