Exemplo n.º 1
0
    def test_volume_types_tab(self):
        encryption_list = (self.cinder_volume_encryption_types.list()[0],
                           self.cinder_volume_encryption_types.list()[1])
        cinder.volume_type_list_with_qos_associations(
            IsA(http.HttpRequest)).\
            AndReturn(self.cinder_volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest)).\
            AndReturn(self.cinder_qos_specs.list())
        cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
            .AndReturn(encryption_list)
        cinder.extension_supported(IsA(http.HttpRequest),
                                   'VolumeTypeEncryption').MultipleTimes()\
            .AndReturn(True)

        self.mox.ReplayAll()
        res = self.client.get(
            reverse('horizon:admin:volumes:volume_types_tab'))

        self.assertEqual(res.status_code, 200)
        self.assertTemplateUsed(
            res, 'admin/volumes/volume_types/volume_types_tables.html')
        volume_types = res.context['volume_types_table'].data
        self.assertItemsEqual(volume_types, self.cinder_volume_types.list())
        qos_specs = res.context['qos_specs_table'].data
        self.assertItemsEqual(qos_specs, self.cinder_qos_specs.list())
Exemplo n.º 2
0
    def test_volume_types_tab(self):
        encryption_list = (self.cinder_volume_encryption_types.list()[0],
                           self.cinder_volume_encryption_types.list()[1])
        cinder.volume_type_list_with_qos_associations(
            IsA(http.HttpRequest)).\
            AndReturn(self.volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest)).\
            AndReturn(self.cinder_qos_specs.list())
        cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
            .AndReturn(encryption_list)
        cinder.extension_supported(IsA(http.HttpRequest),
                                   'VolumeTypeEncryption').MultipleTimes()\
            .AndReturn(True)

        self.mox.ReplayAll()
        res = self.client.get(reverse(
            'horizon:admin:volumes:volume_types_tab'))

        self.assertEqual(res.status_code, 200)
        self.assertTemplateUsed(
            res, 'admin/volumes/volume_types/volume_types_tables.html')
        volume_types = res.context['volume_types_table'].data
        self.assertItemsEqual(volume_types, self.volume_types.list())
        qos_specs = res.context['qos_specs_table'].data
        self.assertItemsEqual(qos_specs, self.cinder_qos_specs.list())
Exemplo n.º 3
0
    def test_delete_volume_type_encryption(self):
        volume_type = self.cinder_volume_types.first()
        volume_type.id = u'1'
        formData = {
            'action': 'volume_types__delete_encryption__%s' % volume_type.id
        }
        encryption_list = (self.cinder_volume_encryption_types.list()[0],
                           self.cinder_volume_encryption_types.list()[1])

        cinder.extension_supported(IsA(http.HttpRequest),
                                   'VolumeTypeEncryption')\
            .AndReturn(True)
        cinder.volume_type_list_with_qos_associations(
            IsA(http.HttpRequest))\
            .AndReturn(self.cinder_volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest))\
            .AndReturn(self.cinder_qos_specs.list())
        cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
            .AndReturn(encryption_list)
        cinder.volume_encryption_type_delete(IsA(http.HttpRequest),
                                             volume_type.id)
        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:admin:volumes:volume_types_tab'), formData)

        redirect = reverse('horizon:admin:volumes:volume_types_tab')
        self.assertNoFormErrors(res)
        self.assertRedirectsNoFollow(res, redirect)
    def test_delete_volume_type_exception(self):
        volume_type = self.volume_types.first()
        formData = {'action': 'volume_types__delete__%s' % volume_type.id}
        encryption_list = (self.cinder_volume_encryption_types.list()[0],
                           self.cinder_volume_encryption_types.list()[1])

        cinder.volume_type_list_with_qos_associations(
            IsA(http.HttpRequest)).\
            AndReturn(self.volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest)).\
            AndReturn(self.cinder_qos_specs.list())
        cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
            .AndReturn(encryption_list)
        cinder.volume_type_delete(IsA(http.HttpRequest),
                                  str(volume_type.id))\
            .AndRaise(exceptions.BadRequest())
        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:admin:volumes:volumes_tab'),
            formData)

        redirect = reverse('horizon:admin:volumes:volumes_tab')
        self.assertNoFormErrors(res)
        self.assertRedirectsNoFollow(res, redirect)
Exemplo n.º 5
0
    def test_delete_volume_type_encryption(self):
        volume_type = self.volume_types.first()
        volume_type.id = u'1'
        formData = {'action': 'volume_types__delete_encryption__%s' %
                    volume_type.id}
        encryption_list = (self.cinder_volume_encryption_types.list()[0],
                           self.cinder_volume_encryption_types.list()[1])

        cinder.extension_supported(IsA(http.HttpRequest),
                                   'VolumeTypeEncryption')\
            .AndReturn(True)
        cinder.volume_type_list_with_qos_associations(
            IsA(http.HttpRequest))\
            .AndReturn(self.volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest))\
            .AndReturn(self.cinder_qos_specs.list())
        cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
            .AndReturn(encryption_list)
        cinder.volume_encryption_type_delete(IsA(http.HttpRequest),
                                             volume_type.id)
        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:admin:volumes:volume_types_tab'),
            formData)

        redirect = reverse('horizon:admin:volumes:volume_types_tab')
        self.assertNoFormErrors(res)
        self.assertRedirectsNoFollow(res, redirect)
Exemplo n.º 6
0
 def get_qos_specs_data(self):
     try:
         qos_specs = cinder.qos_spec_list(self.request)
     except Exception:
         qos_specs = []
         exceptions.handle(self.request, _("Unable to retrieve QoS specs"))
     return qos_specs
Exemplo n.º 7
0
 def get_qos_specs_data(self):
     try:
         qos_specs = cinder.qos_spec_list(self.request)
     except Exception:
         qos_specs = []
         exceptions.handle(self.request, _("Unable to retrieve QOS specs"))
     return qos_specs
Exemplo n.º 8
0
    def test_volume_types_tab(self):
        cinder.volume_type_list(IsA(http.HttpRequest)).\
            AndReturn(self.volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest)).\
            AndReturn(self.cinder_qos_specs.list())

        self.mox.ReplayAll()
        res = self.client.get(reverse(
            'horizon:admin:volumes:volume_types_tab'))

        self.assertEqual(res.status_code, 200)
        self.assertTemplateUsed(res,
            'admin/volumes/volume_types/volume_types_tables.html')
        volume_types = res.context['volume_types_table'].data
        self.assertItemsEqual(volume_types, self.volume_types.list())
        qos_specs = res.context['qos_specs_table'].data
        self.assertItemsEqual(qos_specs, self.cinder_qos_specs.list())
Exemplo n.º 9
0
    def test_volume_types_tab(self):
        cinder.volume_type_list(IsA(http.HttpRequest)).\
            AndReturn(self.volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest)).\
            AndReturn(self.cinder_qos_specs.list())

        self.mox.ReplayAll()
        res = self.client.get(
            reverse('horizon:admin:volumes:volume_types_tab'))

        self.assertEqual(res.status_code, 200)
        self.assertTemplateUsed(
            res, 'admin/volumes/volume_types/volume_types_tables.html')
        volume_types = res.context['volume_types_table'].data
        self.assertItemsEqual(volume_types, self.volume_types.list())
        qos_specs = res.context['qos_specs_table'].data
        self.assertItemsEqual(qos_specs, self.cinder_qos_specs.list())
Exemplo n.º 10
0
    def test_delete_volume_type(self):
        volume_type = self.volume_types.first()
        formData = {'action': 'volume_types__delete__%s' % volume_type.id}

        cinder.volume_type_list(IsA(http.HttpRequest)).\
                                AndReturn(self.volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest)).\
                             AndReturn(self.cinder_qos_specs.list())
        cinder.volume_type_delete(IsA(http.HttpRequest), str(volume_type.id))
        self.mox.ReplayAll()

        res = self.client.post(reverse('horizon:admin:volumes:volumes_tab'),
                               formData)

        redirect = reverse('horizon:admin:volumes:volumes_tab')
        self.assertNoFormErrors(res)
        self.assertRedirectsNoFollow(res, redirect)
Exemplo n.º 11
0
    def test_delete_volume_type(self):
        volume_type = self.volume_types.first()
        formData = {'action': 'volume_types__delete__%s' % volume_type.id}

        cinder.volume_type_list(IsA(http.HttpRequest)).\
                                AndReturn(self.volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest)).\
                             AndReturn(self.cinder_qos_specs.list())
        cinder.volume_type_delete(IsA(http.HttpRequest),
                                  str(volume_type.id))
        self.mox.ReplayAll()

        res = self.client.post(
            reverse('horizon:admin:volumes:volumes_tab'),
            formData)

        redirect = reverse('horizon:admin:volumes:volumes_tab')
        self.assertNoFormErrors(res)
        self.assertRedirectsNoFollow(res, redirect)
Exemplo n.º 12
0
    def test_delete_volume_type(self):
        volume_type = self.cinder_volume_types.first()
        formData = {'action': 'volume_types__delete__%s' % volume_type.id}
        encryption_list = (self.cinder_volume_encryption_types.list()[0],
                           self.cinder_volume_encryption_types.list()[1])

        cinder.volume_type_list_with_qos_associations(
            IsA(http.HttpRequest)).\
            AndReturn(self.cinder_volume_types.list())
        cinder.qos_spec_list(IsA(http.HttpRequest)).\
            AndReturn(self.cinder_qos_specs.list())
        cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
            .AndReturn(encryption_list)
        cinder.volume_type_delete(IsA(http.HttpRequest), volume_type.id)
        self.mox.ReplayAll()

        res = self.client.post(INDEX_URL, formData)

        self.assertNoFormErrors(res)
        self.assertRedirectsNoFollow(res, INDEX_URL)