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


Python Mock.identifier方法代码示例

本文整理汇总了Python中unittest.mock.Mock.identifier方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.identifier方法的具体用法?Python Mock.identifier怎么用?Python Mock.identifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.Mock的用法示例。


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

示例1: it_creates_items

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
    def it_creates_items(self, time, generate_id):
        generate_id.return_value = 'random'
        time.return_value = 1400000000.00

        key3 = Mock()
        key3.identifier = 'abcd'
        key3.level = 'SL3'

        key5 = Mock()
        key5.identifier = 'efgh'
        key5.level = 'SL5'

        data_source = DataSource('some_path')
        data_source._keys = [key3, key5]

        item = data_source.create_item()

        assert type(item) is AgileKeychainItem
        assert item['uuid'] == 'random'
        assert item['createdAt'] == 1400000000
        assert item['location'] == ''
        assert item['locationKey'] == ''
        assert item['title'] == 'Untitled'
        assert item['typeName'] == 'passwords.Password'
        assert item['keyID'] == 'efgh'
        assert item['encrypted'] == {}
开发者ID:clofresh,项目名称:blimey,代码行数:28,代码来源:data_source_spec.py

示例2: main

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
 def main(argument_namespace_callback, **kwargs):
     from PyOpenWorm.context import Context
     argument_namespace_callback.output_mode = 'json'
     m = Mock(name='context_result', spec=Context())
     m.identifier = 'ident'
     m.base_namespace = 'base_namespace'
     return m
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:9,代码来源:CLITest.py

示例3: it_guarantees_generated_item_id_is_unique

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
    def it_guarantees_generated_item_id_is_unique(self, generate_id, get_item_by_id):
        get_item_by_id.side_effect = [Mock(), ItemNotFoundException]
        generate_id.side_effect = ['123', '567']

        key3 = Mock()
        key3.identifier = 'abcd'
        key3.level = 'SL3'

        key5 = Mock()
        key5.identifier = 'efgh'
        key5.level = 'SL5'

        data_source = DataSource('some_path')
        data_source._keys = [key3, key5]

        item = data_source.create_item()

        assert item['uuid'] == '567'
开发者ID:clofresh,项目名称:blimey,代码行数:20,代码来源:data_source_spec.py

示例4: it_creates_items_item_initialised_with_data

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
    def it_creates_items_item_initialised_with_data(self, generate_id):
        generate_id.return_value = 'random'

        key3 = Mock()
        key3.identifier = 'abcd'
        key3.level = 'SL3'

        key5 = Mock()
        key5.identifier = 'efgh'
        key5.level = 'SL5'

        data_source = DataSource('some_path')
        data_source._keys = [key3, key5]

        item = data_source.create_item({'title': 'Thing'})

        assert type(item) is AgileKeychainItem
        assert item['title'] == 'Thing'
开发者ID:clofresh,项目名称:blimey,代码行数:20,代码来源:data_source_spec.py

示例5: test_init_imports

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
 def test_init_imports(self):
     ctx = Mock()
     m = Mock()
     m.identifier = 'blah'
     ctx.imports = [m, m]
     m.imports = []
     ctx.contents_triples.return_value = ()
     m.contents_triples.return_value = [('a', 'b', 'c')]
     with patch('PyOpenWorm.context_store.RDFContextStore'):
         cut = ContextStore(ctx, include_stored=True)
         m.contents_triples.assert_called()
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:13,代码来源:ContextTest.py

示例6: test_contexts_staged_ignores_stored

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
 def test_contexts_staged_ignores_stored(self):
     ctxid0 = URIRef('http://example.com/context_0')
     ctxid1 = URIRef('http://example.com/context_1')
     ctx = Mock()
     graph = Mock()
     graph.store.triples.side_effect = [[((None, None, ctxid0), ())], []]
     ctx.conf = {'rdf.graph': graph}
     ctx.contents_triples.return_value = ()
     ctx.identifier = ctxid1
     ctx.imports = []
     store = ContextStore(ctx)
     self.assertNotIn(ctxid0, set(store.contexts()))
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:14,代码来源:ContextTest.py

示例7: test_contexts_combined

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
 def test_contexts_combined(self):
     ctxid0 = URIRef('http://example.com/context_0')
     ctxid1 = URIRef('http://example.com/context_1')
     ctx = Mock()
     graph = Mock()
     graph.store.triples.side_effect = [[((None, None, ctxid0), ())], []]
     ctx.rdf = graph
     ctx.contents_triples.return_value = ()
     ctx.identifier = ctxid1
     ctx.imports = []
     store = ContextStore(ctx, include_stored=True)
     self.assertEqual(set([ctxid0, ctxid1]),
                      set(store.contexts()))
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:15,代码来源:ContextTest.py

示例8: test_query

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
    def test_query(self):
        rdf_type = 'http://example.org/A'
        ctxid = URIRef('http://example.com/context_1')
        ctx = Mock()
        graph = Mock()
        graph.store.triples.side_effect = ([], [((URIRef('anA0'), rdflib.RDF.type, rdf_type), (ctxid,))],)
        ctx.rdf = graph

        ctx.contents_triples.return_value = [(URIRef('anA'), rdflib.RDF.type, rdf_type)]
        ctx.identifier = ctxid
        ctx.imports = []
        store = ContextStore(ctx, include_stored=True)
        self.assertEqual(set([URIRef('anA'), URIRef('anA0')]),
                         set(x[0][0] for x in store.triples((None, rdflib.RDF.type, rdf_type))))
开发者ID:openworm,项目名称:PyOpenWorm,代码行数:16,代码来源:ContextTest.py

示例9: test_consensus_register_handler

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import identifier [as 别名]
 def test_consensus_register_handler(self):
     mock_chain_head = Mock()
     mock_chain_head.identifier = "dead"
     mock_chain_head.previous_block_id = "beef"
     mock_chain_head.signer_public_key = "abcd"
     mock_chain_head.block_num = 12
     mock_chain_head.consensus = b"deadbeef"
     self.mock_proxy.register.return_value = mock_chain_head, []
     handler = handlers.ConsensusRegisterHandler(self.mock_proxy)
     request_class = handler.request_class
     request = request_class()
     request.name = "test"
     request.version = "test"
     result = handler.handle(None, request.SerializeToString())
     response = result.message_out
     self.assertEqual(response.status, handler.response_class.OK)
     self.mock_proxy.register.assert_called_with()
开发者ID:Whiteblock,项目名称:sawtooth-core,代码行数:19,代码来源:tests.py


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