~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/compute/contrib/test_networks.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    {
29
29
        'bridge': 'br100', 'vpn_public_port': 1000,
30
30
        'dhcp_start': '10.0.0.3', 'bridge_interface': 'eth0',
31
 
        'updated_at': '2011-08-16 09:26:13.048257', 'id': 1,
 
31
        'updated_at': '2011-08-16 09:26:13.048257',
 
32
        'id': 1, 'uuid': '20c8acc0-f747-4d71-a389-46d078ebf047',
32
33
        'cidr_v6': None, 'deleted_at': None,
33
34
        'gateway': '10.0.0.1', 'label': 'mynet_0',
34
35
        'project_id': '1234',
68
69
            if network['id'] == network_id:
69
70
                del self.networks[0]
70
71
                return True
71
 
        raise exception.NetworkNotFound()
 
72
        raise exception.NetworkNotFoundForUUID()
72
73
 
73
74
    #NOTE(bcwaldon): this does nothing other than check for existance
74
75
    def disassociate(self, context, network_id):
75
76
        for i, network in enumerate(self.networks):
76
 
            if network['id'] == network_id:
 
77
            if network.get('uuid') == network_id:
77
78
                return True
78
79
        raise exception.NetworkNotFound()
79
80
 
82
83
 
83
84
    def get(self, context, network_id):
84
85
        for network in self.networks:
85
 
            if network['id'] == network_id:
 
86
            if network.get('uuid') == network_id:
86
87
                return network
87
88
        raise exception.NetworkNotFound()
88
89
 
99
100
    def test_network_list_all(self):
100
101
        req = fakes.HTTPRequest.blank('/v2/1234/os-networks')
101
102
        res_dict = self.controller.index(req)
102
 
        self.assertEquals(res_dict, {'networks': FAKE_NETWORKS})
 
103
        expected = copy.deepcopy(FAKE_NETWORKS)
 
104
        expected[0]['id'] = expected[0]['uuid']
 
105
        del expected[0]['uuid']
 
106
        self.assertEquals(res_dict, {'networks': expected})
103
107
 
104
108
    def test_network_disassociate(self):
105
 
        req = fakes.HTTPRequest.blank('/v2/1234/os-networks/1/action')
106
 
        res = self.controller.action(req, 1, {'disassociate': None})
 
109
        uuid = FAKE_NETWORKS[0]['uuid']
 
110
        req = fakes.HTTPRequest.blank('/v2/1234/os-networks/%s/action' % uuid)
 
111
        res = self.controller.action(req, uuid, {'disassociate': None})
107
112
        self.assertEqual(res.status_int, 202)
108
113
 
109
114
    def test_network_disassociate_not_found(self):
113
118
                          req, 100, {'disassociate': None})
114
119
 
115
120
    def test_network_get(self):
116
 
        req = fakes.HTTPRequest.blank('/v2/1234/os-networks/1')
117
 
        res_dict = self.controller.show(req, 1)
118
 
        expected = {'network': FAKE_NETWORKS[0]}
 
121
        uuid = FAKE_NETWORKS[0]['uuid']
 
122
        req = fakes.HTTPRequest.blank('/v2/1234/os-networks/%s' % uuid)
 
123
        res_dict = self.controller.show(req, uuid)
 
124
        expected = {'network': copy.deepcopy(FAKE_NETWORKS[0])}
 
125
        expected['network']['id'] = expected['network']['uuid']
 
126
        del expected['network']['uuid']
119
127
        self.assertEqual(res_dict, expected)
120
128
 
121
129
    def test_network_get_not_found(self):
124
132
                          self.controller.show, req, 100)
125
133
 
126
134
    def test_network_delete(self):
127
 
        req = fakes.HTTPRequest.blank('/v2/1234/os-networks/1')
 
135
        uuid = FAKE_NETWORKS[0]['uuid']
 
136
        req = fakes.HTTPRequest.blank('/v2/1234/os-networks/%s' % uuid)
128
137
        res = self.controller.delete(req, 1)
129
138
        self.assertEqual(res.status_int, 202)
130
139