~ubuntu-branches/ubuntu/precise/horizon/precise-updates

« back to all changes in this revision

Viewing changes to horizon/dashboards/settings/ec2/tests.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-03-02 12:11:59 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20120302121159-65b88lcl4slve26i
Tags: 2012.1~e4-0ubuntu1
* New upstream version.
* debian/rules: Update due to upstream build changes.
* debian/control: Update standards-version.
* debian/patches/openstack-config-settings.patch: Dropped
* debian/patches/fix-dashboard-django-wsgi.patch: Refreshed
* debian/patches/fix-dashboard-manage.patch: Refreshed
* debian/openstack-dashboard.install: Update due to upstream build changes.
* debian/dashboard: Update to upstream build changes.
* debian/pydist-overrides: Dont try to install python-django-nose-selenium.
* debian/openstack-dashboard.install: Add missing config files.
* debian/rules: Fix broken settings.py
* debian/patches/pkg-setup.patch: Copy missing templates, shameously
  taken from debian
* debian/patches/fix-broken-tarbll.patch: Add missing files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012 Nebula Inc
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
 
 
17
from django.http import HttpRequest
 
18
from django.core.urlresolvers import reverse
 
19
from mox import IsA
 
20
 
 
21
from horizon import api
 
22
from horizon import test
 
23
from .forms import DownloadX509Credentials
 
24
 
 
25
 
 
26
INDEX_URL = reverse("horizon:settings:ec2:index")
 
27
 
 
28
 
 
29
class EC2SettingsTest(test.TestCase):
 
30
    def test_ec2_download_view(self):
 
31
        creds = self.ec2.first()
 
32
        cert = self.certs.first()
 
33
 
 
34
        self.mox.StubOutWithMock(api.keystone, "tenant_list")
 
35
        self.mox.StubOutWithMock(api.nova, "get_x509_credentials")
 
36
        self.mox.StubOutWithMock(api.nova, "get_x509_root_certificate")
 
37
        self.mox.StubOutWithMock(api.keystone, "create_ec2_credentials")
 
38
 
 
39
        # GET request
 
40
        api.keystone.tenant_list(IsA(HttpRequest)) \
 
41
                    .AndReturn(self.tenants.list())
 
42
 
 
43
        # POST request
 
44
        api.keystone.tenant_list(IsA(HttpRequest)) \
 
45
                    .AndReturn(self.tenants.list())
 
46
        api.nova.get_x509_credentials(IsA(HttpRequest)).AndReturn(cert)
 
47
        api.nova.get_x509_root_certificate(IsA(HttpRequest)) \
 
48
                .AndReturn(cert)
 
49
        api.keystone.create_ec2_credentials(IsA(HttpRequest),
 
50
                                            self.user.id,
 
51
                                            self.tenant.id).AndReturn(creds)
 
52
        self.mox.ReplayAll()
 
53
 
 
54
        res = self.client.get(INDEX_URL)
 
55
        self.assertNoMessages()
 
56
        self.assertEqual(res.status_code, 200)
 
57
 
 
58
        data = {'method': DownloadX509Credentials.__name__,
 
59
                'tenant': self.tenant.id}
 
60
        res = self.client.post(INDEX_URL, data)
 
61
        self.assertEqual(res['content-type'], 'application/zip')