Merge lp:~tribaal/landscape-client/remove-mocker-process into lp:~landscape/landscape-client/trunk

Proposed by Chris Glass
Status: Merged
Merged at revision: 847
Proposed branch: lp:~tribaal/landscape-client/remove-mocker-process
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 60 lines (+16/-15)
1 file modified
landscape/lib/tests/test_process.py (+16/-15)
To merge this branch: bzr merge lp:~tribaal/landscape-client/remove-mocker-process
Reviewer Review Type Date Requested Status
🤖 Landscape Builder test results Approve
Free Ekanayaka (community) Approve
Benji York (community) Approve
Review via email: mp+297496@code.launchpad.net

Commit message

s/mocker/mock/

Description of the change

Replaced some mocking, etc.

Testing instructions:

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This branch looks good with one small comment inline.

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

Command: make check
Result: Success
Revno: 843
Branch: lp:~tribaal/landscape-client/remove-mocker-process
Jenkins: https://ci.lscape.net/job/latch-test/5030/

review: Approve (test results)
Revision history for this message
Chris Glass (tribaal) :
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

+1

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

Command: make check
Result: Success
Revno: 846
Branch: lp:~tribaal/landscape-client/remove-mocker-process
Jenkins: https://ci.lscape.net/job/latch-test/5037/

review: Approve (test results)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :
Download full text (178.8 KiB)

The attempt to merge lp:~tribaal/landscape-client/remove-mocker-process into lp:landscape-client failed. Below is the output from the failed tests.

python setup.py build_ext -i
running build_ext
landscape.broker.tests.test_amp
  RemoteBrokerTest
    test_call_if_accepted ... [OK]
    test_call_if_accepted_with_not_accepted ... [OK]
    test_call_on_events ... [OK]
    test_exit ... [OK]
    test_fire_event ... [OK]
    test_get_accepted_message_types ... [OK]
    test_get_server_uuid ... [OK]
    test_is_message_pending ... [OK]
    test_listen_events ... [OK]
    test_method_call_error ... [OK]
    test_ping ... [OK]
    test_register ... [OK]
    test_register_client ... [OK]
    test_register_client_accepted_message_type ... [OK]
    test_reload_configuration ... [OK]
    test_send_message ... [OK]
    test_send_message_with_urgent ... [OK]
    test_stop_clients ... [OK]
  RemoteClientTest
    test_exit ... [OK]
    test_fire_event ... [OK]
    test_message ... [OK]
    test_method_call_error ... [OK]
    test_ping ... [OK]
landscape.broker.tests.test_client
  BrokerClientTest
    test_add ... [OK]
    test_dispatch_message ... [OK]
    test_dispatch_message_with_exception ... [OK]
    test_dispatch_message_with_no_handler ... [OK]
    test_exchange ... [OK]
    test_exchange_logs_errors_and_continues ... [OK]
    test_exchange_on_plugin_without_exchange_method ... [OK]
    test_exit ... [OK]
    test_fire_event ... [OK]
    test_fire_event_with_acceptance_changed ... [OK]
    test_fire_event_with_arguments ... [OK]
    test_fire_event_with_mixed_results ... [OK]
    test_get_named_plugin ... [OK]
...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'landscape/lib/tests/test_process.py'
--- landscape/lib/tests/test_process.py 2012-10-10 13:32:10 +0000
+++ landscape/lib/tests/test_process.py 2016-06-15 17:28:32 +0000
@@ -1,4 +1,5 @@
1import unittest1import unittest
2import mock
2import os3import os
34
4from landscape.tests.helpers import LandscapeTest5from landscape.tests.helpers import LandscapeTest
@@ -39,15 +40,14 @@
39 stat = " ".join(stat_array)40 stat = " ".join(stat_array)
40 create_file(os.path.join(process_dir, "stat"), stat)41 create_file(os.path.join(process_dir, "stat"), stat)
4142
42 def test_missing_process_race(self):43 @mock.patch("landscape.lib.process.detect_jiffies", return_value=1)
44 @mock.patch("os.listdir")
45 def test_missing_process_race(self, list_dir_mock, jiffies_mock):
43 """46 """
44 We use os.listdir("/proc") to get the list of active processes, if a47 We use os.listdir("/proc") to get the list of active processes, if a
45 process ends before we attempt to read the process' information, then48 process ends before we attempt to read the process' information, then
46 this should not trigger an error.49 this should not trigger an error.
47 """50 """
48 listdir_mock = self.mocker.replace("os.listdir")
49 listdir_mock("/proc")
50 self.mocker.result(["12345"])
5151
52 class FakeFile(object):52 class FakeFile(object):
5353
@@ -67,20 +67,21 @@
67 def close(self):67 def close(self):
68 self.closed = True68 self.closed = True
6969
70 open_mock = self.mocker.replace("__builtin__.open")70 list_dir_mock.return_value = ["12345"]
71 open_mock("/proc/12345/cmdline", "r")
72 fakefile1 = FakeFile("test-binary")71 fakefile1 = FakeFile("test-binary")
73 self.mocker.result(fakefile1)
74
75 open_mock("/proc/12345/status", "r")
76 fakefile2 = FakeFile(None)72 fakefile2 = FakeFile(None)
77 self.mocker.result(fakefile2)73
7874 with mock.patch("__builtin__.open", mock.mock_open()) as open_mock:
79 self.mocker.replay()75 # This means "return fakefile1, then fakefile2"
8076 open_mock.side_effect = [fakefile1, fakefile2]
81 process_info = ProcessInformation("/proc")77 process_info = ProcessInformation("/proc")
82 processes = list(process_info.get_all_process_info())78 processes = list(process_info.get_all_process_info())
79 calls = [
80 mock.call("/proc/12345/cmdline", "r"),
81 mock.call("/proc/12345/status", "r")]
82 open_mock.assert_has_calls(calls)
83 self.assertEqual(processes, [])83 self.assertEqual(processes, [])
84 list_dir_mock.assert_called_with("/proc")
84 self.assertTrue(fakefile1.closed)85 self.assertTrue(fakefile1.closed)
85 self.assertTrue(fakefile2.closed)86 self.assertTrue(fakefile2.closed)
8687

Subscribers

People subscribed via source and target branches

to all changes: