當前位置: 首頁>>代碼示例>>Python>>正文


Python NonCallableMock.reset_mock方法代碼示例

本文整理匯總了Python中mock.NonCallableMock.reset_mock方法的典型用法代碼示例。如果您正苦於以下問題:Python NonCallableMock.reset_mock方法的具體用法?Python NonCallableMock.reset_mock怎麽用?Python NonCallableMock.reset_mock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mock.NonCallableMock的用法示例。


在下文中一共展示了NonCallableMock.reset_mock方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestMeetmeServiceManager

# 需要導入模塊: from mock import NonCallableMock [as 別名]
# 或者: from mock.NonCallableMock import reset_mock [as 別名]

#.........這裏部分代碼省略.........
        self.assertEqual(self.mock_manager.leave.call_count, 0)

    def test_leave(self):
        start_time = 1234556.123

        self.manager._cache = {conf_room_number: {'number': conf_room_number,
                                                  'name': conf_room_name,
                                                  'pin_required': True,
                                                  'start_time': start_time,
                                                  'members': {1: {'join_order': 1,
                                                                  'join_time': start_time,
                                                                  'number': '1002',
                                                                  'name': 'Tester 1',
                                                                  'channel': 'SIP/jsdhfjd-124'},
                                                              2: {'join_order': 2,
                                                                  'join_time': start_time + 10,
                                                                  'number': '4181235555',
                                                                  'name': '4181235555',
                                                                  'channel': 'DAHDI/i1/4181235555-5'}}}}

        self.manager.leave(conf_room_number, 1)

        expected = {conf_room_number: {'number': conf_room_number,
                                       'name': conf_room_name,
                                       'pin_required': True,
                                       'start_time': start_time,
                                       'members': {2: {'join_order': 2,
                                                       'join_time': start_time + 10,
                                                       'number': '4181235555',
                                                       'name': '4181235555',
                                                       'channel': 'DAHDI/i1/4181235555-5'}}}}

        self.mock_notifier.publish_meetme_update.assert_called_once_with(expected)
        self.mock_notifier.reset_mock()

        self.manager.leave(conf_room_number, 2)

        expected = {conf_room_number: {'number': conf_room_number,
                                       'name': conf_room_name,
                                       'pin_required': True,
                                       'start_time': 0,
                                       'members': {}}}

        self.mock_notifier.publish_meetme_update.assert_called_once_with(expected)

    def test_leave_after_restart(self):
        start_time = 1234556.123

        self.manager._cache = {
            conf_room_number: {
                'number': conf_room_number,
                'name': conf_room_name,
                'pin_required': True,
                'start_time': start_time,
                'members': {},
            }
        }

        self.manager.leave(conf_room_number, 1)

        self.assertEqual(self.mock_notifier.publish_meetme_update.call_count, 0)

    def test_has_members(self):
        self.manager._cache = {'800': {'members': {}}}

        self.assertFalse(self.manager._has_members('800'))
開發者ID:gorocacher,項目名稱:xivo-ctid,代碼行數:70,代碼來源:test_meetme_service_manager.py


注:本文中的mock.NonCallableMock.reset_mock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。