~ubuntu-branches/ubuntu/utopic/python-quantumclient/utopic

« back to all changes in this revision

Viewing changes to quantumclient/tests/unit/test_cli20_subnet.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 12:45:43 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120816124543-5m96n37eik89sr2j
Tags: 1:2.0-0ubuntu1
* New upstream version.
* debian/control: Update build dependencies.
* debian/rules: Enable testsuite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
class CLITestV20Subnet(CLITestV20Base):
30
30
 
31
31
    def test_create_subnet(self):
32
 
        """ create_subnet --gateway gateway netid cidr"""
 
32
        """Create sbunet: --gateway gateway netid cidr."""
33
33
        resource = 'subnet'
34
34
        cmd = CreateSubnet(MyApp(sys.stdout), None)
35
35
        name = 'myname'
39
39
        gateway = 'gatewayvalue'
40
40
        args = ['--gateway', gateway, netid, cidr]
41
41
        position_names = ['ip_version', 'network_id', 'cidr', 'gateway_ip']
42
 
        position_values = [4, ]
43
 
        position_values.extend([netid, cidr, gateway])
 
42
        position_values = [4, netid, cidr, gateway]
44
43
        _str = self._test_create_resource(resource, cmd, name, myid, args,
45
44
                                          position_names, position_values)
46
45
 
47
46
    def test_create_subnet_tenant(self):
48
 
        """create_subnet --tenant-id tenantid netid cidr"""
 
47
        """Create subnet: --tenant_id tenantid netid cidr."""
49
48
        resource = 'subnet'
50
49
        cmd = CreateSubnet(MyApp(sys.stdout), None)
51
50
        name = 'myname'
52
51
        myid = 'myid'
53
52
        netid = 'netid'
54
53
        cidr = 'prefixvalue'
55
 
        args = ['--tenant-id', 'tenantid', netid, cidr]
 
54
        args = ['--tenant_id', 'tenantid', netid, cidr]
56
55
        position_names = ['ip_version', 'network_id', 'cidr']
57
 
        position_values = [4, ]
58
 
        position_values.extend([netid, cidr])
 
56
        position_values = [4, netid, cidr]
59
57
        _str = self._test_create_resource(resource, cmd, name, myid, args,
60
58
                                          position_names, position_values,
61
59
                                          tenant_id='tenantid')
62
60
 
63
61
    def test_create_subnet_tags(self):
64
 
        """ create_subnet netid cidr --tags a b"""
 
62
        """Create subnet: netid cidr --tags a b."""
65
63
        resource = 'subnet'
66
64
        cmd = CreateSubnet(MyApp(sys.stdout), None)
67
65
        name = 'myname'
70
68
        cidr = 'prefixvalue'
71
69
        args = [netid, cidr, '--tags', 'a', 'b']
72
70
        position_names = ['ip_version', 'network_id', 'cidr']
73
 
        position_values = [4, ]
74
 
        position_values.extend([netid, cidr])
 
71
        position_values = [4, netid, cidr]
75
72
        _str = self._test_create_resource(resource, cmd, name, myid, args,
76
73
                                          position_names, position_values,
77
74
                                          tags=['a', 'b'])
78
75
 
 
76
    def test_create_subnet_allocation_pool(self):
 
77
        """Create subnet: --tenant_id tenantid <allocation_pool> netid cidr.
 
78
        The <allocation_pool> is --allocation_pool start=1.1.1.10,end=1.1.1.20
 
79
        """
 
80
        resource = 'subnet'
 
81
        cmd = CreateSubnet(MyApp(sys.stdout), None)
 
82
        name = 'myname'
 
83
        myid = 'myid'
 
84
        netid = 'netid'
 
85
        cidr = 'prefixvalue'
 
86
        args = ['--tenant_id', 'tenantid',
 
87
                '--allocation_pool', 'start=1.1.1.10,end=1.1.1.20',
 
88
                netid, cidr]
 
89
        position_names = ['ip_version', 'allocation_pools', 'network_id',
 
90
                          'cidr']
 
91
        pool = [{'start': '1.1.1.10', 'end': '1.1.1.20'}]
 
92
        position_values = [4, pool, netid, cidr]
 
93
        _str = self._test_create_resource(resource, cmd, name, myid, args,
 
94
                                          position_names, position_values,
 
95
                                          tenant_id='tenantid')
 
96
 
 
97
    def test_create_subnet_allocation_pools(self):
 
98
        """Create subnet: --tenant-id tenantid <pools> netid cidr.
 
99
        The <pools> are --allocation_pool start=1.1.1.10,end=1.1.1.20 and
 
100
        --allocation_pool start=1.1.1.30,end=1.1.1.40
 
101
        """
 
102
        resource = 'subnet'
 
103
        cmd = CreateSubnet(MyApp(sys.stdout), None)
 
104
        name = 'myname'
 
105
        myid = 'myid'
 
106
        netid = 'netid'
 
107
        cidr = 'prefixvalue'
 
108
        args = ['--tenant_id', 'tenantid',
 
109
                '--allocation_pool', 'start=1.1.1.10,end=1.1.1.20',
 
110
                '--allocation_pool', 'start=1.1.1.30,end=1.1.1.40',
 
111
                netid, cidr]
 
112
        position_names = ['ip_version', 'allocation_pools', 'network_id',
 
113
                          'cidr']
 
114
        pools = [{'start': '1.1.1.10', 'end': '1.1.1.20'},
 
115
                 {'start': '1.1.1.30', 'end': '1.1.1.40'}]
 
116
        position_values = [4, pools, netid, cidr]
 
117
        _str = self._test_create_resource(resource, cmd, name, myid, args,
 
118
                                          position_names, position_values,
 
119
                                          tenant_id='tenantid')
 
120
 
79
121
    def test_list_subnets_detail(self):
80
 
        """list_subnets -D"""
 
122
        """List subnets: -D."""
81
123
        resources = "subnets"
82
124
        cmd = ListSubnet(MyApp(sys.stdout), None)
83
125
        self._test_list_resources(resources, cmd, True)
84
126
 
85
127
    def test_list_subnets_tags(self):
86
 
        """list_subnets -- --tags a b"""
 
128
        """List subnets: -- --tags a b."""
87
129
        resources = "subnets"
88
130
        cmd = ListSubnet(MyApp(sys.stdout), None)
89
131
        self._test_list_resources(resources, cmd, tags=['a', 'b'])
90
132
 
91
133
    def test_list_subnets_detail_tags(self):
92
 
        """list_subnets -D -- --tags a b"""
 
134
        """List subnets: -D -- --tags a b."""
93
135
        resources = "subnets"
94
136
        cmd = ListSubnet(MyApp(sys.stdout), None)
95
137
        self._test_list_resources(resources, cmd, detail=True, tags=['a', 'b'])
96
138
 
97
139
    def test_list_subnets_fields(self):
98
 
        """list_subnets --fields a --fields b -- --fields c d"""
 
140
        """List subnets: --fields a --fields b -- --fields c d."""
99
141
        resources = "subnets"
100
142
        cmd = ListSubnet(MyApp(sys.stdout), None)
101
143
        self._test_list_resources(resources, cmd,
102
144
                                  fields_1=['a', 'b'], fields_2=['c', 'd'])
103
145
 
104
146
    def test_update_subnet(self):
105
 
        """ update_subnet myid --name myname --tags a b"""
 
147
        """Update subnet: myid --name myname --tags a b."""
106
148
        resource = 'subnet'
107
149
        cmd = UpdateSubnet(MyApp(sys.stdout), None)
108
150
        self._test_update_resource(resource, cmd, 'myid',
112
154
                                   )
113
155
 
114
156
    def test_show_subnet(self):
115
 
        """ show_subnet --fields id --fields name myid """
 
157
        """Show subnet: --fields id --fields name myid."""
116
158
        resource = 'subnet'
117
159
        cmd = ShowSubnet(MyApp(sys.stdout), None)
118
 
        myid = 'myid'
119
 
        args = ['--fields', 'id', '--fields', 'name', myid]
120
 
        self._test_show_resource(resource, cmd, myid, args, ['id', 'name'])
 
160
        args = ['--fields', 'id', '--fields', 'name', self.test_id]
 
161
        self._test_show_resource(resource, cmd, self.test_id,
 
162
                                 args, ['id', 'name'])
121
163
 
122
164
    def test_delete_subnet(self):
123
 
        """
124
 
        delete_subnet myid
125
 
        """
 
165
        """Delete subnet: subnetid."""
126
166
        resource = 'subnet'
127
167
        cmd = DeleteSubnet(MyApp(sys.stdout), None)
128
168
        myid = 'myid'