* Fix TypeError when getting the tags property from an image that has
  no tags. Ex: An image pulled by cryptohash. It is handled like when
  the image doesn't have defined the RepoTags member.

Signed-off-by: Alejandro E. Brito Monedero <alejandro.monedero@gmail.com>
This commit is contained in:
Alejandro E. Brito Monedero 2017-01-16 08:48:41 +01:00
parent aed1af6f6f
commit 95b6fddd14
2 changed files with 9 additions and 4 deletions

View File

@ -30,10 +30,10 @@ class Image(Model):
"""
The image's tags.
"""
return [
tag for tag in self.attrs.get('RepoTags', [])
if tag != '<none>:<none>'
]
tags = self.attrs.get('RepoTags')
if tags is None:
tags = []
return [tag for tag in tags if tag != '<none>:<none>']
def history(self):
"""

View File

@ -83,6 +83,11 @@ class ImageTest(unittest.TestCase):
})
assert image.tags == []
image = Image(attrs={
'RepoTags': None
})
assert image.tags == []
def test_history(self):
client = make_fake_client()
image = client.images.get(FAKE_IMAGE_ID)