Beispiel #1
0
def test_find_images_by_name_pending_image():
    """
    Test find_images_by_name does not raise if an image is pending.

    If Status is pending image will not have a name key.
    """
    images = _get_test_images()
    image = {}
    image['Status'] = 'pending'
    image['ImageId'] = 'testimage-3'
    images.append(image)
    utils.find_images_by_name(images, 'testimage-1')
Beispiel #2
0
def test_find_images_by_name_find_some():
    """Test find_images_by_name finds images"""
    images = _get_test_images()
    image = {}
    image['Name'] = 'testimage-1'
    images.append(image)
    found_images = utils.find_images_by_name(images, 'testimage-1')
    assert 2 == len(found_images)
    assert 'testimage-1' == found_images[1]['Name']
Beispiel #3
0
 def _get_images(self):
     """Return a list of images that match the filter criteria"""
     self._connect()
     owned_images = self._get_owned_images()
     if self.image_id:
         return utils.find_images_by_id(owned_images, self.image_id)
     elif self.image_name:
         return utils.find_images_by_name(owned_images, self.image_name)
     elif self.image_name_fragment:
         return utils.find_images_by_name_fragment(owned_images,
                                                   self.image_name_fragment)
     elif self.image_name_match:
         try:
             return utils.find_images_by_name_regex_match(
                 owned_images, self.image_name_match)
         except:
             msg = 'Unable to complie regular expression "%s"'
             msg = msg % self.image_name_match
             raise EC2PublishImgException(msg)
Beispiel #4
0
 def _find_images_by_name(self, image_name, filter_replacement_image=None):
     """Find images by exact name match"""
     my_images = self._get_all_type_match_images(filter_replacement_image)
     return utils.find_images_by_name(my_images, image_name)
Beispiel #5
0
def test_find_images_by_name_find_none():
    """Test find_images_by_name finds nothing and does not error"""
    images = _get_test_images()
    found_images = utils.find_images_by_name(images, 'test')
    assert 0 == len(found_images)