本文整理汇总了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'] == {}
示例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
示例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'
示例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'
示例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()
示例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()))
示例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()))
示例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))))
示例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()