当前位置: 首页>>代码示例>>Python>>正文


Python mock.mocksignature函数代码示例

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


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


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