Example #1
0
 def db_to_msg(self, db_obj):
     msg = ImageMsg()
     msg.last_modified = db_obj.last_modified.strftime(self.rfc2339_date_fmt)
     msg.created_at = db_obj.created_at.strftime(self.rfc2339_date_fmt)
     msg.distro_namespace = db_obj.distro_namespace
     msg.user_id = db_obj.user_id
     msg.state = db_obj.state
     msg.id = db_obj.id
     msg.digest = db_obj.digest
     msg.tags = []
     return msg
def test_image():
    """
    Simple serialization test
    :return:
    """

    i = Image()
    i.user_id = 'user'
    i.id = 'image1'
    i.state = 'active'
    i.digest = 'digest'
    i.tags = ['tag1', 'tag2']
    assert i.to_json() == {
        'id': 'image1',
        'user_id': 'user',
        'digest': 'digest',
        'tags': ['tag1', 'tag2'],
        'state': 'active',
        'created_at': None,
        'last_modified': None,
        'distro_namespace': None
    }
Example #3
0
def test_image():
    """
    Simple serialization test
    :return:
    """

    i = Image()
    i.user_id = "user"
    i.id = "image1"
    i.state = "active"
    i.digest = "digest"
    i.tags = ["tag1", "tag2"]
    assert i.to_json() == {
        "id": "image1",
        "user_id": "user",
        "digest": "digest",
        "tags": ["tag1", "tag2"],
        "state": "active",
        "created_at": None,
        "last_modified": None,
        "distro_namespace": None,
    }