Ejemplo n.º 1
0
 def test_iter_images_cached(self):
     # Tests whether the iter_images method returns the values from
     # the cache
     cache = {'images': []}
     images = list(glance.ImagePollster()._iter_images(
         self.manager.keystone, cache))
     self.assertEqual([], images)
Ejemplo n.º 2
0
 def test_glance_image_counter(self):
     counters = list(glance.ImagePollster().get_counters(self.manager))
     self.assertEqual(len(counters), 6)
     for counter in [c for c in counters if c.name == 'image']:
         self.assertEqual(counter.volume, 1)
     for image in IMAGE_LIST:
         self.assert_(
             any(map(lambda counter: counter.volume == image.size,
                     counters)))
Ejemplo n.º 3
0
 def _do_test_iter_images(self, page_size=0):
     self.CONF.set_override("glance_page_size", page_size)
     images = list(glance.ImagePollster()._iter_images(
         self.manager.keystone, {}))
     kwargs = {}
     if page_size > 0:
         kwargs['page_size'] = page_size
     FakeGlanceClient.images.list.assert_called_with(
         filters={'is_public': False}, **kwargs)
     self.assertEqual(len(set(image.id for image in images)), len(images))
Ejemplo n.º 4
0
 def test_image_get_sample_names(self):
     samples = list(glance.ImagePollster().get_samples(self.manager, {}))
     self.assertEqual(set(['image']), set([s.name for s in samples]))
Ejemplo n.º 5
0
 def test_image(self):
     samples = list(glance.ImagePollster().get_samples(self.manager, {}))
     self.assertEqual(3, len(samples))
     for sample in samples:
         self.assertEqual(1, sample.volume)
Ejemplo n.º 6
0
 def test_iter_images(self):
     # Tests whether the iter_images method returns a unique image
     # list when there is nothing in the cache
     images = list(glance.ImagePollster()._iter_images(
         self.manager.keystone, {}))
     self.assertEqual(len(set(image.id for image in images)), len(images))
Ejemplo n.º 7
0
 def test_default_discovery(self):
     pollster = glance.ImagePollster()
     self.assertEqual('endpoint:image', pollster.default_discovery)
Ejemplo n.º 8
0
 def test_get_counter_names(self):
     counters = list(glance.ImagePollster().get_counters(self.manager))
     self.assertEqual(set([c.name for c in counters]),
                      set(glance.ImagePollster().get_counter_names()))
Ejemplo n.º 9
0
 def test_glance_image_counter(self):
     counters = list(glance.ImagePollster().get_counters(
         self.manager, self.context))
     self.assertEqual(len(counters), 3)
     for counter in counters:
         self.assertEqual(counter.volume, 1)
Ejemplo n.º 10
0
 def test_iter_images(self):
     images = list(glance.ImagePollster().
                   iter_images(self.manager.keystone))
     self.assertEqual(len(images), len(set(image.id for image in images)))
Ejemplo n.º 11
0
 def setUp(self):
     super(TestImagePageSize, self).setUp()
     self.CONF = self.useFixture(fixture_config.Config()).conf
     self.manager = manager.AgentManager(0, self.CONF)
     self.pollster = glance.ImagePollster(self.CONF)