コード例 #1
0
ファイル: tests.py プロジェクト: wendy-king/x7_venv
    def test_index_no_images(self):
        self.mox.StubOutWithMock(api, 'snapshot_list_detailed')
        api.snapshot_list_detailed(IsA(http.HttpRequest)).\
                                   AndReturn(self.snapshots)

        self.mox.StubOutWithMock(api, 'flavor_list')
        api.flavor_list(IsA(http.HttpRequest)).AndReturn(self.flavors)

        self.mox.StubOutWithMock(api, 'security_group_list')
        api.security_group_list(IsA(http.HttpRequest)).\
                                AndReturn(self.security_groups)

        self.mox.StubOutWithMock(api, 'keypair_list')
        api.keypair_list(IsA(http.HttpRequest)).AndReturn(self.keypairs)

        self.mox.StubOutWithMock(api, 'image_list_detailed')
        api.image_list_detailed(IsA(http.HttpRequest)).AndReturn([])

        self.mox.StubOutWithMock(api, 'tenant_quota_get')
        api.tenant_quota_get(IsA(http.HttpRequest), self.TEST_TENANT) \
                .AndReturn({})

        self.mox.StubOutWithMock(messages, 'info')
        messages.info(IsA(http.HttpRequest), IsA(basestring))

        self.mox.ReplayAll()

        res = self.client.get(INDEX_URL)

        self.assertTemplateUsed(res, 'engine/images_and_snapshots/index.html')
コード例 #2
0
ファイル: views.py プロジェクト: wendy-king/x7_venv
def index(request):
    images = []

    try:
        images = api.snapshot_list_detailed(request)
    except tank_exception.ClientConnectionError, e:
        msg = _('Error connecting to tank: %s') % str(e)
        LOG.exception(msg)
        messages.error(request, msg)
コード例 #3
0
ファイル: views.py プロジェクト: wendy-king/x7_venv
def index(request):
    images = []

    try:
        images = api.snapshot_list_detailed(request)
    except tank_exception.ClientConnectionError, e:
        msg = _('Error connecting to tank: %s') % str(e)
        LOG.exception(msg)
        messages.error(request, msg)
コード例 #4
0
ファイル: views.py プロジェクト: wendy-king/x7_venv
def index(request):
    for f in (DeleteImage, ):
        unused, handled = f.maybe_handle(request)
        if handled:
            return handled
    all_images = []
    snapshots = []
    try:
        all_images = api.image_list_detailed(request)
        snapshots = api.snapshot_list_detailed(request)
        if not all_images:
            messages.info(request, _("There are currently no images."))
    except tank_exception.ClientConnectionError, e:
        LOG.exception("Error connecting to tank")
        messages.error(request, _("Error connecting to tank: %s") % str(e))
コード例 #5
0
ファイル: tests.py プロジェクト: wendy-king/x7_venv
    def test_index(self):
        self.mox.StubOutWithMock(api, 'image_list_detailed')
        api.image_list_detailed(IsA(http.HttpRequest)).AndReturn(self.images)

        self.mox.StubOutWithMock(api, 'snapshot_list_detailed')
        api.snapshot_list_detailed(IsA(http.HttpRequest)).AndReturn(
                self.snapshots)

        self.mox.StubOutWithMock(api, 'flavor_list')
        api.flavor_list(IsA(http.HttpRequest)).AndReturn(self.flavors)
        api.flavor_list(IsA(http.HttpRequest)).AndReturn(self.flavors)

        self.mox.StubOutWithMock(api, 'security_group_list')
        api.security_group_list(IsA(http.HttpRequest)).\
                                AndReturn(self.security_groups)
        api.security_group_list(IsA(http.HttpRequest)).\
                                AndReturn(self.security_groups)

        self.mox.StubOutWithMock(api, 'keypair_list')
        api.keypair_list(IsA(http.HttpRequest)).AndReturn(self.keypairs)

        self.mox.StubOutWithMock(api, 'tenant_quota_get')
        api.tenant_quota_get(IsA(http.HttpRequest),
                self.TEST_TENANT).AndReturn({})

        self.mox.ReplayAll()

        res = self.client.get(INDEX_URL)

        self.assertTemplateUsed(res,
                                'engine/images_and_snapshots/index.html')

        self.assertIn('images', res.context)
        images = res.context['images']
        self.assertEqual(len(images), 1)
        self.assertEqual(images[0].name, 'visibleImage')