Merge lp:~bgh/neutron/lp837174 into lp:neutron/diablo

Proposed by Brad Hall
Status: Merged
Approved by: Salvatore Orlando
Approved revision: 59
Merged at revision: 60
Proposed branch: lp:~bgh/neutron/lp837174
Merge into: lp:neutron/diablo
Diff against target: 117 lines (+45/-10)
2 files modified
quantum/db/api.py (+7/-0)
tests/unit/test_api.py (+38/-10)
To merge this branch: bzr merge lp:~bgh/neutron/lp837174
Reviewer Review Type Date Requested Status
Salvatore Orlando Approve
dan wendlandt Approve
Review via email: mp+73329@code.launchpad.net

Description of the change

Fix unit test printing (lp837174)

To post a comment you must log in.
Revision history for this message
dan wendlandt (danwent) wrote :

LGTM.

Btw, how did you invoke the tests such that you actually got the error? When I run the tests with "./run_tests.sh -N", I never see the original error. Were you running with a higher debug level?

review: Approve
Revision history for this message
Brad Hall (bgh) wrote :

You have to use run_tests.py instead of .sh :)

On Mon, Aug 29, 2011 at 11:31 PM, dan wendlandt <email address hidden> wrote:
> Review: Approve
> LGTM.
>
> Btw, how did you invoke the tests such that you actually got the error?  When I run the tests with "./run_tests.sh -N", I never see the original error.  Were you running with a higher debug level?
> --
> https://code.launchpad.net/~bgh/quantum/lp837174/+merge/73329
> You are the owner of lp:~bgh/quantum/lp837174.
>

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

> You have to use run_tests.py instead of .sh :)
>

Or just find the tracebacks in run_tests.err.log.
The error did not cause the test to fail. The exception is not canceled by the unit tests, it is the logging module who gracefully kills the operation.

The fix is fine for me. In nova the use of locals() is preferred when possible as it facilitates the translation task (the .pot file contains the actual name of the variable and not just %s).
However this does not matter in this case, as we don't have i18n at the moment, and I dont't think we have a great deal of interest in internationalization for unit tests.

> On Mon, Aug 29, 2011 at 11:31 PM, dan wendlandt <email address hidden> wrote:
> > Review: Approve
> > LGTM.
> >
> > Btw, how did you invoke the tests such that you actually got the error?
> When I run the tests with "./run_tests.sh -N", I never see the original error.
> Were you running with a higher debug level?
> > --
> > https://code.launchpad.net/~bgh/quantum/lp837174/+merge/73329
> > You are the owner of lp:~bgh/quantum/lp837174.
> >

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'quantum/db/api.py'
2--- quantum/db/api.py 2011-08-17 21:48:56 +0000
3+++ quantum/db/api.py 2011-08-30 05:45:17 +0000
4@@ -142,6 +142,13 @@
5 net = session.query(models.Network).\
6 filter_by(uuid=net_id).\
7 one()
8+
9+ ports = session.query(models.Port).\
10+ filter_by(network_id=net_id).\
11+ all()
12+ for p in ports:
13+ session.delete(p)
14+
15 session.delete(net)
16 session.flush()
17 return net
18
19=== modified file 'tests/unit/test_api.py'
20--- tests/unit/test_api.py 2011-08-24 11:54:53 +0000
21+++ tests/unit/test_api.py 2011-08-30 05:45:17 +0000
22@@ -218,8 +218,8 @@
23 LOG.debug("_test_delete_network - format:%s - START", format)
24 content_type = "application/%s" % format
25 network_id = self._create_network(format)
26- LOG.debug("Deleting network %(network_id)s"\
27- " of tenant %(tenant_id)s", locals())
28+ LOG.debug("Deleting network %s"\
29+ " of tenant %s" % (network_id, self.tenant_id))
30 delete_network_req = testlib.network_delete_request(self.tenant_id,
31 network_id,
32 format)
33@@ -240,8 +240,8 @@
34 port_state = "ACTIVE"
35 attachment_id = "test_attachment"
36 network_id = self._create_network(format)
37- LOG.debug("Deleting network %(network_id)s"\
38- " of tenant %(tenant_id)s", locals())
39+ LOG.debug("Deleting network %s"\
40+ " of tenant %s" % (network_id, self.tenant_id))
41 port_id = self._create_port(network_id, port_state, format)
42 #plug an attachment into the port
43 LOG.debug("Putting attachment into port %s", port_id)
44@@ -252,8 +252,8 @@
45 attachment_res = attachment_req.get_response(self.api)
46 self.assertEquals(attachment_res.status_int, 204)
47
48- LOG.debug("Deleting network %(network_id)s"\
49- " of tenant %(tenant_id)s", locals())
50+ LOG.debug("Deleting network %s"\
51+ " of tenant %s" % (network_id, self.tenant_id))
52 delete_network_req = testlib.network_delete_request(self.tenant_id,
53 network_id,
54 format)
55@@ -261,6 +261,26 @@
56 self.assertEqual(delete_network_res.status_int, 421)
57 LOG.debug("_test_delete_network_in_use - format:%s - END", format)
58
59+ def _test_delete_network_with_unattached_port(self, format):
60+ LOG.debug("_test_delete_network_with_unattached_port "\
61+ "- format:%s - START", format)
62+ content_type = "application/%s" % format
63+ port_state = "ACTIVE"
64+ network_id = self._create_network(format)
65+ LOG.debug("Deleting network %s"\
66+ " of tenant %s" % (network_id, self.tenant_id))
67+ port_id = self._create_port(network_id, port_state, format)
68+
69+ LOG.debug("Deleting network %s"\
70+ " of tenant %s" % (network_id, self.tenant_id))
71+ delete_network_req = testlib.network_delete_request(self.tenant_id,
72+ network_id,
73+ format)
74+ delete_network_res = delete_network_req.get_response(self.api)
75+ self.assertEqual(delete_network_res.status_int, 204)
76+ LOG.debug("_test_delete_network_with_unattached_port "\
77+ "- format:%s - END", format)
78+
79 def _test_list_ports(self, format):
80 LOG.debug("_test_list_ports - format:%s - START", format)
81 content_type = "application/%s" % format
82@@ -433,8 +453,9 @@
83 port_state = "ACTIVE"
84 network_id = self._create_network(format)
85 port_id = self._create_port(network_id, port_state, format)
86- LOG.debug("Deleting port %(port_id)s for network %(network_id)s"\
87- " of tenant %(tenant_id)s", locals())
88+ LOG.debug("Deleting port %s for network %s"\
89+ " of tenant %s" % (port_id, network_id,
90+ self.tenant_id))
91 delete_port_req = testlib.port_delete_request(self.tenant_id,
92 network_id, port_id,
93 format)
94@@ -464,8 +485,9 @@
95 attachment_id)
96 attachment_res = attachment_req.get_response(self.api)
97 self.assertEquals(attachment_res.status_int, 204)
98- LOG.debug("Deleting port %(port_id)s for network %(network_id)s"\
99- " of tenant %(tenant_id)s", locals())
100+ LOG.debug("Deleting port %s for network %s"\
101+ " of tenant %s" % (port_id, network_id,
102+ self.tenant_id))
103 delete_port_req = testlib.port_delete_request(self.tenant_id,
104 network_id, port_id,
105 format)
106@@ -848,6 +870,12 @@
107 def test_delete_network_in_use_xml(self):
108 self._test_delete_network_in_use('xml')
109
110+ def test_delete_network_with_unattached_port_xml(self):
111+ self._test_delete_network_with_unattached_port('xml')
112+
113+ def test_delete_network_with_unattached_port_json(self):
114+ self._test_delete_network_with_unattached_port('json')
115+
116 def test_list_ports_json(self):
117 self._test_list_ports('json')
118

Subscribers

People subscribed via source and target branches