Merge lp:~bogdana/landscape-client/mocker-monitor-test-plugin into lp:~landscape/landscape-client/trunk

Proposed by Bogdana Vereha
Status: Merged
Approved by: Bogdana Vereha
Approved revision: 864
Merged at revision: 877
Proposed branch: lp:~bogdana/landscape-client/mocker-monitor-test-plugin
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 46 lines (+8/-12)
1 file modified
landscape/monitor/tests/test_plugin.py (+8/-12)
To merge this branch: bzr merge lp:~bogdana/landscape-client/mocker-monitor-test-plugin
Reviewer Review Type Date Requested Status
Benji York (community) Approve
🤖 Landscape Builder test results Approve
Chris Glass (community) Approve
Review via email: mp+297561@code.launchpad.net

Commit message

Update monitor.test_plugin to use mock instead of mocker

Description of the change

Update monitor.test_plugin to use mock instead of mocker

Testing instructions:
unittests

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
Chris Glass (tribaal) wrote :

Yep yep! +1

review: Approve
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: make check
Result: Success
Revno: 864
Branch: lp:~bogdana/landscape-client/mocker-monitor-test-plugin
Jenkins: https://ci.lscape.net/job/latch-test/5064/

review: Approve (test results)
Revision history for this message
Benji York (benji) wrote :

This looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/monitor/tests/test_plugin.py'
2--- landscape/monitor/tests/test_plugin.py 2013-08-22 14:08:19 +0000
3+++ landscape/monitor/tests/test_plugin.py 2016-06-15 21:42:02 +0000
4@@ -1,8 +1,7 @@
5-from twisted.internet.defer import succeed
6+from mock import ANY, Mock, patch
7
8 from landscape.monitor.plugin import MonitorPlugin, DataWatcher
9 from landscape.schema import Message, Int
10-from landscape.tests.mocker import ANY
11 from landscape.tests.helpers import (
12 LandscapeTest, MonitorHelper, LogKeeperHelper)
13
14@@ -48,11 +47,10 @@
15 """
16 plugin = MonitorPlugin()
17 plugin.register(self.monitor)
18- callback = self.mocker.mock()
19- callback("foo", kwarg="bar")
20- self.mocker.replay()
21+ callback = Mock()
22 plugin.call_on_accepted("type", callback, "foo", kwarg="bar")
23 self.reactor.fire(("message-type-acceptance-changed", "type"), True)
24+ callback.assert_called_once_with("foo", kwarg="bar")
25
26 def test_call_on_accepted_when_unaccepted(self):
27 """
28@@ -163,13 +161,11 @@
29 When exchange is called with an urgent argument set to True
30 make sure it sends the message urgently.
31 """
32- remote_broker_mock = self.mocker.replace(self.remote)
33- remote_broker_mock.send_message(ANY, ANY, urgent=True)
34- self.mocker.result(succeed(None))
35- self.mocker.replay()
36-
37- self.mstore.set_accepted_types(["wubble"])
38- self.plugin.exchange(True)
39+ with patch.object(self.remote, "send_message"):
40+ self.mstore.set_accepted_types(["wubble"])
41+ self.plugin.exchange(True)
42+ self.remote.send_message.assert_called_once_with(
43+ ANY, ANY, urgent=True)
44
45 def test_no_message_if_not_accepted(self):
46 """

Subscribers

People subscribed via source and target branches

to all changes: