• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mock.mocksignature函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mock.mocksignature函数的典型用法代码示例。如果您正苦于以下问题:Python mocksignature函数的具体用法?Python mocksignature怎么用?Python mocksignature使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mocksignature函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_create_event_process

    def test_create_event_process(self):
        """
        Test creating an event process
        """
#        process_definition = ProcessDefinition(name='test')

        mock = Mock()
        mock.definition = 'a_definition'
        mock.detail = 'event_process_detail'
        mock_id = 'a_process_definition_id'

        self.mock_rr_client.read = Mock()
        self.mock_rr_client.read.return_value = mock

        self.mock_rr_client.update = Mock()
        self.mock_rr_client.update = mocksignature(self.mock_rr_client.update)

        self.mock_rr_client.find_objects = Mock()
        self.mock_rr_client.find_objects.return_value = ['stream_id_1'], 'obj_assoc_1'

        self.mock_pd_client.schedule_process = Mock()
        self.mock_pd_client.schedule_process.return_value = 'process_id'

        self.mock_rr_client.create_association = mocksignature(self.mock_rr_client.create_association)

        self.mock_dams_client.register_event_process = mocksignature(self.mock_dams_client.register_event_process)

        pid = self.event_management.create_event_process(process_definition_id=mock_id,
            event_types=['type_1', 'type_2'],
            sub_types=['subtype_1', 'subtype_2'],
            origins=['or_1', 'or_2'],
            origin_types=['t1', 't2'],
            out_data_products={'conductivity': 'id1'}
        )
开发者ID:Bobfrat,项目名称:coi-services,代码行数:34,代码来源:event_management_test.py


示例2: setUp

    def setUp(self):
        abstract_node_class = mocksignature(AbstractNode, AbstractNode)
        selector_class = mocksignature(StaticSelector, StaticSelector)

        self.abstract_node = abstract_node_class(self)
        self.abstract_node.selector = selector_class(self)
        self.root_node = Node(pattern='', parent=None, abstract_node=self.abstract_node)
开发者ID:carriercomm,项目名称:nodefs,代码行数:7,代码来源:unit.py


示例3: setUp

    def setUp(self):
        def config_get_args(str1, str2):
            if str2 == 'api_root':
                return sentinel.api_root
            else:
                return sentinel.promo_code

        self.config = Mock()
        self.config.get = config_get_args
        

        def testfun_nopromo(api_root, user):
            pass

        def testfun_promo(api_root, user, promo_code):
            pass

        self.testfun_nopromo_mock = Mock()
        self.testfun_nopromo = mocksignature(testfun_nopromo, 
                                             self.testfun_nopromo_mock)
        self.testfun_nopromo.return_value = sentinel.testfun_nopromo

        self.testfun_promo_mock = Mock()
        self.testfun_promo = mocksignature(testfun_promo, 
                                           self.testfun_promo_mock)
        self.testfun_promo.return_value = sentinel.testfun_promo
开发者ID:bdzim,项目名称:netkes,代码行数:26,代码来源:test_group_manager.py


示例4: testIntrospection

    def testIntrospection(self):
        def f(a, *args, **kwargs):
            pass
        f2 = mocksignature(f, f)
        self.assertEqual(inspect.getargspec(f), inspect.getargspec(f2))

        def f(a, b=None, c=3, d=object()):
            pass
        f2 = mocksignature(f, f)
        self.assertEqual(inspect.getargspec(f), inspect.getargspec(f2))
开发者ID:dzohrob,项目名称:input-lib,代码行数:10,代码来源:testmocksignature.py


示例5: test_create_event_type

    def test_create_event_type(self):
        """
        Test creating an event
        """
        event_type = EventType(name="Test event type")
        self.mock_rr_client.create = mocksignature(self.mock_rr_client.create)
        self.mock_rr_client.create.return_value = ('event_type_id','rev_1')

        self.mock_dams_client.register_process = mocksignature(self.mock_dams_client.register_process)

        event_type_id = self.event_management.create_event_type(event_type)

        self.assertEquals(event_type_id, 'event_type_id')
        self.mock_rr_client.create.assert_called_once_with(event_type)
开发者ID:Bobfrat,项目名称:coi-services,代码行数:14,代码来源:event_management_test.py


示例6: testMockSignatureWithReservedArg

    def testMockSignatureWithReservedArg(self):
        def f(_mock_):
            pass
        self.assertRaises(AssertionError, lambda: mocksignature(f))

        def f(_mock_=None):
            pass
        self.assertRaises(AssertionError, lambda: mocksignature(f))

        def f(*_mock_):
            pass
        self.assertRaises(AssertionError, lambda: mocksignature(f))

        def f(**_mock_):
            pass
        self.assertRaises(AssertionError, lambda: mocksignature(f))
开发者ID:dzohrob,项目名称:input-lib,代码行数:16,代码来源:testmocksignature.py


示例7: test_create_event_process

    def test_create_event_process(self):
        """
        Test creating an event process
        """
        process_definition = ProcessDefinition(name='test')
        process_definition.definition = ''

        rrc = ResourceRegistryServiceClient(node = self.container.node)
        process_definition_id = rrc.create(process_definition)

        self.mock_rr_client.find_objects = Mock()
        self.mock_rr_client.find_objects.return_value = ['stream_id_1'], 'obj_assoc_1'

#        self.mock_pd_client.schedule_process = Mock()
#        self.mock_pd_client.schedule_process.return_value = 'process_id'

        self.mock_rr_client.create_association = mocksignature(self.mock_rr_client.create_association)

        pid = self.event_management.create_event_process(process_definition_id=process_definition_id,
            event_types=['type_1', 'type_2'],
            sub_types=['subtype_1', 'subtype_2'],
            origins=['or_1', 'or_2'],
            origin_types=['t1', 't2'],
            out_data_products={'conductivity': 'id1'}
        )
开发者ID:kerfoot,项目名称:coi-services,代码行数:25,代码来源:event_management_test.py


示例8: test_side_effect_from_existing_mock

    def test_side_effect_from_existing_mock(self):
        mock = Mock(side_effect=KeyError)
        func = mocksignature(f, mock)
        self.assertRaises(KeyError, func, 1, 2, 3)

        mock.side_effect = NameError
        self.assertRaises(NameError, func, 1, 2, 3)
开发者ID:calvinchengx,项目名称:python-mock,代码行数:7,代码来源:testmocksignature.py


示例9: test_return_value_from_existing_mock

    def test_return_value_from_existing_mock(self):
        mock = Mock(return_value='foo')
        func = mocksignature(f, mock)
        self.assertEqual(func(1, 2, 3), 'foo')

        mock.return_value = 'bar'
        self.assertEqual(func(1, 2, 3), 'bar')
开发者ID:calvinchengx,项目名称:python-mock,代码行数:7,代码来源:testmocksignature.py


示例10: _create_service_mock

 def _create_service_mock(self, service_name):
     # set self.clients if not already set
     clients = Mock(name='clients')
     base_service = get_service_registry().get_service_base(service_name)
     # Save it to use in test_verify_service
     self.base_service = base_service
     self.addCleanup(delattr, self, 'base_service')
     dependencies = base_service.dependencies
     for dep_name in dependencies:
         dep_service = get_service_registry().get_service_base(dep_name)
         # Force mock service to use interface
         mock_service = Mock(name='clients.%s' % dep_name,
                 spec=dep_service)
         setattr(clients, dep_name, mock_service)
         # set self.dep_name for convenience
         setattr(self, dep_name, mock_service)
         self.addCleanup(delattr, self, dep_name)
         iface = list(implementedBy(dep_service))[0]
         names_and_methods = iface.namesAndDescriptions()
         for func_name, _ in names_and_methods:
             mock_func = mocksignature(getattr(dep_service, func_name),
                     mock=Mock(name='clients.%s.%s' % (dep_name,
                         func_name)), skipfirst=True)
             setattr(mock_service, func_name, mock_func)
     return clients
开发者ID:mkl-,项目名称:scioncc,代码行数:25,代码来源:unit_test.py


示例11: test_mocksignature_with_reserved_arg

    def test_mocksignature_with_reserved_arg(self):
        def f(_mock_):
            pass
        self.assertRaises(AssertionError, lambda: mocksignature(f))

        def f(_mock_=None):
            pass
        self.assertRaises(AssertionError, lambda: mocksignature(f))

        def f(*_mock_):
            pass
        self.assertRaises(AssertionError, lambda: mocksignature(f))

        def f(**_mock_):
            pass
        self.assertRaises(AssertionError, lambda: mocksignature(f))
开发者ID:calvinchengx,项目名称:python-mock,代码行数:16,代码来源:testmocksignature.py


示例12: test_load_cards

    def test_load_cards(self):
        fbb = [u"Foo", u"Bar", u"Baz"]

        parse = mock.mocksignature(p.parse)

        for l, f in itertools.izip_longest(p.load_cards(S, _parse=parse), fbb):
            self.assertEqual(list(parse.mock.call_args[0][0]), [f] * 3)
开发者ID:Julian,项目名称:cardboard,代码行数:7,代码来源:test_populate.py


示例13: test_delete_event_process

    def test_delete_event_process(self):
        """
        Test deleting an event process
        """
        self.mock_rr_client.delete = mocksignature(self.mock_rr_client.delete)
        self.event_management.delete_event_process('event_process_id')

        self.mock_rr_client.delete.assert_called_once_with('event_process_id')
开发者ID:Bobfrat,项目名称:coi-services,代码行数:8,代码来源:event_management_test.py


示例14: test_delete_event_type

    def test_delete_event_type(self):
        """
        Test updating an event
        """
        self.mock_rr_client.delete = mocksignature(self.mock_rr_client.delete)

        self.event_management.delete_event_type(event_type_id='event_type_id')
        self.mock_rr_client.delete.assert_called_once_with('event_type_id')
开发者ID:Bobfrat,项目名称:coi-services,代码行数:8,代码来源:event_management_test.py


示例15: test_get_pod_files

def test_get_pod_files():
    mock_os_listdir = Mock(return_value = ['foo', 'bar', 'baz'])
    mock_pod_executable_file_p = mocksignature(barker.pod.executable_file_p)
    mock_pod_executable_file_p.return_value = True
    with patch.object(barker.pod.os, 'listdir', mock_os_listdir):
        with patch.object(barker.pod, "executable_file_p", mock_pod_executable_file_p):
            assert_equals(list(barker.pod.get_pod_files('/barker-tests')),
                          ['/barker-tests/foo', '/barker-tests/bar', '/barker-tests/baz'])
开发者ID:simplegeo,项目名称:barker,代码行数:8,代码来源:test_pod.py


示例16: test_get_nodes

    def test_get_nodes(self):
        selector = ModelSelector(projection="%(label)s", model_class=Thing)

        abstract_node_class = mocksignature(AbstractNode, AbstractNode)
        abstract_node = abstract_node_class(self)
        nodes = selector.get_nodes(abstract_node)

        self.assertIsInstance(nodes, list)
        self.assertGreater(len(nodes), 0)
开发者ID:perenecabuto,项目名称:django_nodefs,代码行数:9,代码来源:unit.py


示例17: test_read_event_process

    def test_read_event_process(self):
        """
        Test reading an event process
        """
        event_process = Mock()
        self.mock_rr_client.read = mocksignature(self.mock_rr_client.read)
        self.mock_rr_client.read.return_value = event_process

        result = self.event_management.read_event_process('event_process_id')
        self.assertEquals(result, event_process)
开发者ID:Bobfrat,项目名称:coi-services,代码行数:10,代码来源:event_management_test.py


示例18: testMockSignatureClass

    def testMockSignatureClass(self):
        MockedSomething = mocksignature(Something)

        result = MockedSomething(5, 23)
        self.assertIs(result, MockedSomething.mock.return_value)

        MockedSomething(1)
        MockedSomething.mock.assert_caled_with(1, 10)

        self.assertRaises(TypeError, MockedSomething)
开发者ID:dzohrob,项目名称:input-lib,代码行数:10,代码来源:testmocksignature.py


示例19: test_read_event_process_definition

    def test_read_event_process_definition(self):
        """
        Test reading an event process definition
        """
        event_process_def = Mock()
        self.mock_rr_client.read = mocksignature(self.mock_rr_client.read)
        self.mock_rr_client.read.return_value = event_process_def

        result = self.event_management.read_event_process_definition()
        self.assertEquals(result, event_process_def)
开发者ID:Bobfrat,项目名称:coi-services,代码行数:10,代码来源:event_management_test.py


示例20: testMockSignatureCallable

    def testMockSignatureCallable(self):
        mocked_something = mocksignature(something)

        result = mocked_something(5, 23)
        self.assertIs(result, mocked_something.mock.return_value)

        mocked_something(1)
        mocked_something.mock.assert_caled_with(1, 5)

        self.assertRaises(TypeError, mocked_something)
开发者ID:dzohrob,项目名称:input-lib,代码行数:10,代码来源:testmocksignature.py



注:本文中的mock.mocksignature函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mock.patch函数代码示例发布时间:2022-05-27
下一篇:
Python mock.mock_open函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap