Merge lp:~markwash/network-service/style-points into lp:~rajarammallya/network-service/melange_framework

Proposed by Mark Washenberger
Status: Merged
Merged at revision: 24
Proposed branch: lp:~markwash/network-service/style-points
Merge into: lp:~rajarammallya/network-service/melange_framework
Diff against target: 45 lines (+13/-16)
1 file modified
tests/unit/test_service.py (+13/-16)
To merge this branch: bzr merge lp:~markwash/network-service/style-points
Reviewer Review Type Date Requested Status
Rajaram Mallya Pending
Review via email: mp+62072@code.launchpad.net

Description of the change

Tries to fix up the style of a given test to be more pythonic

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/unit/test_service.py'
2--- tests/unit/test_service.py 2011-05-20 08:38:53 +0000
3+++ tests/unit/test_service.py 2011-05-24 04:27:28 +0000
4@@ -175,29 +175,26 @@
5 class TestIpNatController(TestController):
6
7 def test_create_inside_local_nat(self):
8- global_block, local_block_1, local_block_2 =\
9- _create_blocks("169.1.1.1/32",
10- '10.1.1.1/32',
11- '10.0.0.1/32')
12+ global_block, = _create_blocks("169.1.1.1/32")
13+ local_block1, = _create_blocks("10.1.1.1/32")
14+ local_block2, = _create_blocks("10.0.0.1/32")
15
16- response = self.app.post("/ipam/ip_blocks/%s/ip_addresses/"
17- "169.1.1.1/inside_locals"
18- % global_block.id,
19- {"ip_addresses": json.dumps(
20- [{"ip_block_id": local_block_1.id,
21- "ip_address": "10.1.1.1"},
22- {"ip_block_id": local_block_2.id,
23- "ip_address": "10.0.0.1"}])})
24+ url = "/ipam/ip_blocks/%s/ip_addresses/169.1.1.1/inside_locals"
25+ json_data = [
26+ {'ip_block_id': local_block1.id, 'ip_address': "10.1.1.1"},
27+ {'ip_block_id': local_block2.id, 'ip_address': "10.0.0.1"},
28+ ]
29+ request_data = {'ip_addresses': json.dumps(json_data)}
30+ response = self.app.post(url % global_block.id, request_data)
31
32 self.assertEqual(response.status, "200 OK")
33- inside_locals = [ip.address for ip in
34- global_block.find_allocated_ip("169.1.1.1").\
35- inside_locals()]
36+ ips = global_block.find_allocated_ip("169.1.1.1").inside_locals()
37+ inside_locals = [ip.address for ip in ips]
38
39 self.assertEqual(len(inside_locals), 2)
40 self.assertTrue("10.1.1.1" in inside_locals)
41 self.assertTrue("10.0.0.1" in inside_locals)
42- local_ip = IpAddress.find_by_block_and_address(local_block_1.id,
43+ local_ip = IpAddress.find_by_block_and_address(local_block1.id,
44 "10.1.1.1")
45 self.assertEqual(local_ip.inside_globals()[0].address, "169.1.1.1")
46

Subscribers

People subscribed via source and target branches