Merge lp:~soren/surveilr/mock080-compat into lp:surveilr

Proposed by Soren Hansen
Status: Merged
Approved by: Soren Hansen
Approved revision: 30
Merged at revision: 30
Proposed branch: lp:~soren/surveilr/mock080-compat
Merge into: lp:surveilr
Diff against target: 108 lines (+12/-12)
2 files modified
surveilr/tests/api/server/test_auth.py (+1/-1)
surveilr/tests/api/test_client.py (+11/-11)
To merge this branch: bzr merge lp:~soren/surveilr/mock080-compat
Reviewer Review Type Date Requested Status
Soren Hansen Pending
Review via email: mp+93402@code.launchpad.net

Commit message

Make our use of mock compatible with 0.8.0

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 'surveilr/tests/api/server/test_auth.py'
2--- surveilr/tests/api/server/test_auth.py 2012-01-29 22:49:00 +0000
3+++ surveilr/tests/api/server/test_auth.py 2012-02-16 13:46:20 +0000
4@@ -35,7 +35,7 @@
5
6 def test_require_auth_middleware_authed(self):
7 app, wrapped_app = self._get_wrapped_app()
8- expected_response = mock.Sentinel()
9+ expected_response = mock.sentinel.response
10
11 app.return_value = expected_response
12 start_response = mock.Mock()
13
14=== modified file 'surveilr/tests/api/test_client.py'
15--- surveilr/tests/api/test_client.py 2012-01-29 23:32:36 +0000
16+++ surveilr/tests/api/test_client.py 2012-02-16 13:46:20 +0000
17@@ -92,7 +92,7 @@
18
19 parent = FakeObjType(api_client)
20 parent.id = 7
21- with mock.patch_object(api_client, 'send_req') as send_req:
22+ with mock.patch.object(api_client, 'send_req') as send_req:
23 FakeObjType(api_client).req(api_client, 'create', test_data,
24 parent=parent)
25 self.assertEquals(send_req.call_args[0][0], '/stuffs/7/stuffs')
26@@ -108,7 +108,7 @@
27 class FakeObjType(client.APIObject):
28 url_part = 'stuff'
29
30- with mock.patch_object(api_client, 'send_req') as send_req:
31+ with mock.patch.object(api_client, 'send_req') as send_req:
32 FakeObjType(api_client).req(api_client, 'create', test_data)
33 self.assertEquals(send_req.call_args[0][0], '/stuffs')
34 self.assertEquals(send_req.call_args[1]['method'], 'POST')
35@@ -121,7 +121,7 @@
36 class FakeObjType(client.APIObject):
37 url_part = 'stuff'
38
39- with mock.patch_object(api_client, 'send_req') as send_req:
40+ with mock.patch.object(api_client, 'send_req') as send_req:
41 FakeObjType(api_client).req(api_client, 'get', 'someid')
42 self.assertEquals(send_req.call_args[0][0], '/stuffs/someid')
43 self.assertEquals(send_req.call_args[1]['method'], 'GET')
44@@ -132,7 +132,7 @@
45 class FakeObjType(client.APIObject):
46 url_part = 'stuff'
47
48- with mock.patch_object(api_client, 'send_req') as send_req:
49+ with mock.patch.object(api_client, 'send_req') as send_req:
50 FakeObjType(api_client).req(api_client, 'delete', 'someid')
51 self.assertEquals(send_req.call_args[0][0], '/stuffs/someid')
52 self.assertEquals(send_req.call_args[1]['method'], 'DELETE')
53@@ -141,7 +141,7 @@
54 class APIObjectTests(tests.TestCase):
55 def _test_req(self):
56 client_obj = mock.Mock()
57- data = mock.Sentinel()
58+ data = mock.sentinel.data
59
60 class TestObject(client.APIObject):
61 url_part = 'test'
62@@ -179,7 +179,7 @@
63 def _test_new(self, admin):
64 # Setup
65 client_obj = mock.Mock()
66- with mock.patch_object(client.User, 'req') as client_req:
67+ with mock.patch.object(client.User, 'req') as client_req:
68 client_req.return_value = json.dumps({'id': 'testid',
69 'key': 'testkey',
70 'admin': admin})
71@@ -210,7 +210,7 @@
72 # Setup
73 test_plugins = ['http://h:1/p']
74 client_obj = mock.Mock()
75- with mock.patch_object(client.Service, 'req') as service_req:
76+ with mock.patch.object(client.Service, 'req') as service_req:
77 service_req.return_value = json.dumps({'id': 'testid',
78 'name': 'testname',
79 'plugins': test_plugins})
80@@ -239,7 +239,7 @@
81 service_obj = client.Service(client_obj, id='testid',
82 name='testname', plugins=[])
83
84- with mock.patch_object(client, 'Metric') as Metric:
85+ with mock.patch.object(client, 'Metric') as Metric:
86 service_obj.new_metric({'foo': 1234})
87
88 Metric.new.assert_called_with(client_obj, service_obj,
89@@ -249,8 +249,8 @@
90 def test_new(self):
91 # Setup
92 client_obj = mock.Mock()
93- service_obj = mock.Sentinel()
94- with mock.patch_object(client.Metric, 'req') as metric_req:
95+ service_obj = mock.sentinel.service_obj
96+ with mock.patch.object(client.Metric, 'req') as metric_req:
97 metric_req.return_value = json.dumps({})
98
99 # Exercise
100@@ -274,7 +274,7 @@
101 from webob import Request
102
103 api_client = client.SurveilrDirectClient({})
104- with mock.patch_object(api_client, 'app') as app:
105+ with mock.patch.object(api_client, 'app') as app:
106 response = mock.Mock()
107 response.body = 'response'
108 app.return_value = response

Subscribers

People subscribed via source and target branches

to all changes: