本文整理汇总了Python中mockito.any函数的典型用法代码示例。如果您正苦于以下问题:Python any函数的具体用法?Python any怎么用?Python any使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了any函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_skip_song_if_any_filter_should_filter
def test_skip_song_if_any_filter_should_filter(self):
self.create_file_in(self.SOURCE_PATH)
f = mock()
when(f).should_filter(any()).thenReturn(True)
self.ms.filters = [f]
self.ms.sync()
verify(self.file_operator_mock, never).copyfile(any(), any())
开发者ID:rockem,项目名称:MediaSync,代码行数:7,代码来源:test_synchronizer.py
示例2: test_backup_incremental_metadata
def test_backup_incremental_metadata(self):
when(backupagent).get_storage_strategy(any(), any()).thenReturn(
MockSwift)
MockStorage.save_metadata = Mock()
when(MockSwift).load_metadata(any(), any()).thenReturn(
{'lsn': '54321'})
meta = {
'lsn': '12345',
'parent_location': 'fake',
'parent_checksum': 'md5',
}
when(mysql_impl.InnoBackupExIncremental).metadata().thenReturn(meta)
when(mysql_impl.InnoBackupExIncremental).check_process().thenReturn(
True)
agent = backupagent.BackupAgent()
bkup_info = {'id': '123',
'location': 'fake-location',
'type': 'InnoBackupEx',
'checksum': 'fake-checksum',
'parent': {'location': 'fake', 'checksum': 'md5'}
}
agent.execute_backup(TroveContext(), bkup_info, '/var/lib/mysql')
self.assertTrue(MockStorage.save_metadata.called_once_with(
any(),
meta))
开发者ID:denismakogon,项目名称:trove-guestagent,代码行数:30,代码来源:test_backupagent.py
示例3: test_random_walk_classical
def test_random_walk_classical(self):
methods = RandomWalkMethods()
#given
graph = mockito.mock(nx.MultiGraph)
edgesData, nodes, nodeList = utils.prepareNodesAndEdges()
edgesList = utils.prepareEdgesList(edgesData, nodeList)
class_mat = utils.prepareTestClassMatWithUnknownNodes()
default_class_mat = utils.prepareTestClassMat()
mockito.when(graph).edges_iter(mockito.any(), data=True)\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))
mockito.when(graph).edges_iter(mockito.any())\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))\
.thenReturn(utils.generateEdges(10, nodeList, edgesData))
mockito.when(graph).edges(data=True).thenReturn(edgesList)
mockito.when(graph).nodes().thenReturn(nodes)
result = methods.random_walk_classical(graph, default_class_mat, [1, 2], 5, 1)
assert result.__len__() == 5
开发者ID:dfeng808,项目名称:multiplex,代码行数:27,代码来源:TestsRandomWalkMethods.py
示例4: test_check_for_heartbeat_negative
def test_check_for_heartbeat_negative(self):
# TODO (juice) maybe it would be ok to extend the test to validate
# the is_active method on the heartbeat
when(db_models.DatabaseModelBase).find_by(
instance_id=any()).thenReturn('agent')
when(agent_models.AgentHeartBeat).is_active(any()).thenReturn(False)
self.assertRaises(exception.GuestTimeout, self.api._check_for_hearbeat)
开发者ID:rmyers,项目名称:reddwarf,代码行数:7,代码来源:test_api.py
示例5: test_ensure_after_action_teardown_is_executed_and_suppresses
def test_ensure_after_action_teardown_is_executed_and_suppresses(self):
task = mock(name="task", dependencies=[])
when(task).execute(any(), {}).thenRaise(ValueError("simulated task error"))
action_teardown1 = mock(name="action_teardown1", execute_before=[], execute_after=["task"], teardown=True,
source="task")
when(action_teardown1).execute({}).thenRaise(ValueError("simulated action error teardown1"))
action_teardown2 = mock(name="action_teardown2", execute_before=[], execute_after=["task"], teardown=True,
source="task")
self.execution_manager.register_action(action_teardown1)
self.execution_manager.register_action(action_teardown2)
self.execution_manager.register_task(task)
self.execution_manager.resolve_dependencies()
try:
self.execution_manager.execute_task(task)
self.assertTrue(False, "should not have reached here")
except Exception as e:
self.assertEquals(type(e), ValueError)
self.assertEquals(str(e), "simulated task error")
verify(task).execute(any(), {})
verify(action_teardown1).execute({})
verify(action_teardown2).execute({})
verify(self.execution_manager.logger).error(
"Executing action '%s' from '%s' resulted in an error that was suppressed:\n%s", "action_teardown1",
"task", any())
开发者ID:Ferreiros-lab,项目名称:pybuilder,代码行数:27,代码来源:execution_tests.py
示例6: test_RunlistRemoveAction
def test_RunlistRemoveAction(self):
storage = mock()
action = runlist.Remove(storage, **{'name': 'RunlistName'})
when(storage).remove(any(str), any(str)).thenReturn(Chain([lambda: 'Ok']))
action.execute().get()
verify(storage).remove('runlists', 'RunlistName')
开发者ID:nexusriot,项目名称:cocaine-framework-python,代码行数:7,代码来源:test_tools.py
示例7: test_public_exists_events
def test_public_exists_events(self):
status = ServiceStatuses.BUILDING.api_status
db_instance = DBInstance(
InstanceTasks.BUILDING,
created="xyz",
name="test_name",
id="1",
flavor_id="flavor_1",
compute_instance_id="compute_id_1",
server_id="server_id_1",
tenant_id="tenant_id_1",
server_status=status,
)
server = mock(Server)
server.user_id = "test_user_id"
mgmt_instance = SimpleMgmtInstance(self.context, db_instance, server, None)
when(mgmtmodels).load_mgmt_instances(self.context, deleted=False, client=self.client).thenReturn(
[mgmt_instance, mgmt_instance]
)
flavor = mock(Flavor)
flavor.name = "db.small"
when(self.flavor_mgr).get("flavor_1").thenReturn(flavor)
self.assertThat(self.context.auth_token, Is("some_secret_password"))
when(notifier).notify(self.context, any(str), "trove.instance.exists", "INFO", any(dict)).thenReturn(None)
# invocation
mgmtmodels.publish_exist_events(NovaNotificationTransformer(context=self.context), self.context)
# assertion
verify(notifier, times=2).notify(self.context, any(str), "trove.instance.exists", "INFO", any(dict))
self.assertThat(self.context.auth_token, Is(None))
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:30,代码来源:test_models.py
示例8: test_RunlistViewAction
def test_RunlistViewAction(self):
storage = mock()
action = RunlistViewAction(storage, **{'name': 'RunlistName'})
when(storage).read(any(str), any(str)).thenReturn(ChainFactory([lambda: 'Ok']))
action.execute().get()
verify(storage).read('runlists', 'RunlistName')
开发者ID:ijon,项目名称:cocaine-framework-python,代码行数:7,代码来源:tests.py
示例9: test_CrashlogListAction
def test_CrashlogListAction(self):
storage = mock()
action = CrashlogListAction(storage, **{'name': 'CrashlogName'})
when(storage).find(any(str), any(tuple)).thenReturn(ChainFactory([lambda: 'Ok']))
action.execute().get()
verify(storage).find('crashlogs', ('CrashlogName', ))
开发者ID:ijon,项目名称:cocaine-framework-python,代码行数:7,代码来源:tests.py
示例10: _when_connection_timeouts_for_first_time
def _when_connection_timeouts_for_first_time(self):
when_connect = when(self._ssh).connect(any(), username=any(),
key_filename=any(),
timeout=any())
first_timeout = when_connect.thenRaise(socket.timeout)
second_timeout = first_timeout.thenRaise(socket.timeout)
second_timeout.thenReturn(None)
开发者ID:mdlugajczyk,项目名称:cloud-computing-assignment,代码行数:7,代码来源:node_availability_checker_test.py
示例11: test_ProfileViewAction
def test_ProfileViewAction(self):
storage = mock()
action = ProfileViewAction(storage, **{'name': 'ProfileName'})
when(storage).read(any(str), any(str)).thenReturn(ChainFactory([lambda: 'Ok']))
action.execute().get()
verify(storage).read('profiles', 'ProfileName')
开发者ID:ijon,项目名称:cocaine-framework-python,代码行数:7,代码来源:tests.py
示例12: testS3FileWriter
def testS3FileWriter(self):
mock_s3_client = mock()
writer = S3FileWriter(mock_s3_client)
writer.write(mock(), {'bucket': 'test bucket', 'key': 'test key'})
verify(mock_s3_client).connect()
verify(mock_s3_client).write_key(any(), any(), any(), any())
verify(mock_s3_client).disconnect()
开发者ID:tbeatty,项目名称:data-distribution,代码行数:7,代码来源:writers.py
示例13: testFtpFileWriter
def testFtpFileWriter(self):
mock_ftp_client = mock()
writer = FtpFileWriter(mock_ftp_client)
writer.write(mock(), {'filename': 'test'})
verify(mock_ftp_client).connect()
verify(mock_ftp_client).write_file(any(), any())
verify(mock_ftp_client).disconnect()
开发者ID:tbeatty,项目名称:data-distribution,代码行数:7,代码来源:writers.py
示例14: test_ornamentation_rate_can_be_controlled
def test_ornamentation_rate_can_be_controlled(self):
"""
There should be way to control how frequently walls are ornamented
"""
wall_tile(self.level, (2, 2), self.wall)
wall_tile(self.level, (3, 2), self.wall)
wall_tile(self.level, (4, 2), self.wall)
rng = mock()
when(rng).randint(any(), any()).thenReturn(0).thenReturn(100).thenReturn(0)
when(rng).choice(any()).thenReturn(self.ornamentation)
self.config = WallOrnamentDecoratorConfig(
['any level'],
wall_tile = self.wall,
ornamentation = [self.ornamentation],
rng = rng,
rate = 50)
self.decorator = WallOrnamentDecorator(self.config)
self.decorator.decorate_level(self.level)
candle_count = 0
for location, tile in get_tiles(self.level):
if self.ornamentation in tile['\ufdd0:ornamentation']:
candle_count = candle_count + 1
assert_that(candle_count, is_(equal_to(2)))
开发者ID:tuturto,项目名称:pyherc,代码行数:28,代码来源:test_leveldecorator.py
示例15: test_RunlistListAction
def test_RunlistListAction(self):
storage = mock()
action = runlist.List(storage)
when(storage).find(any(str), any(tuple)).thenReturn(Chain([lambda: 'Ok']))
action.execute().get()
verify(storage).find('runlists', RUNLISTS_TAGS)
开发者ID:nexusriot,项目名称:cocaine-framework-python,代码行数:7,代码来源:test_tools.py
示例16: testActivityRunnerSuccess
def testActivityRunnerSuccess(self):
mock_activity = mock()
mock_success_handler = mock()
mock_failure_handler = mock()
ActivityRunner(mock_activity, mock_success_handler, mock_failure_handler).run()
verify(mock_success_handler).handle_success(any())
verify(mock_failure_handler, times=0).handle_failure(any(), any())
开发者ID:tbeatty,项目名称:data-distribution,代码行数:7,代码来源:activities.py
示例17: test_RunlistUploadActionRawRunlistProvided
def test_RunlistUploadActionRawRunlistProvided(self):
storage = mock()
action = runlist.Upload(storage, **{'name': 'RunlistName', 'runlist': '{}'})
when(storage).write(any(str), any(str), any(str), any(tuple)).thenReturn(Chain([lambda: 'Ok']))
action.execute().get()
verify(storage).write('runlists', 'RunlistName', msgpack.dumps({}), RUNLISTS_TAGS)
开发者ID:nexusriot,项目名称:cocaine-framework-python,代码行数:7,代码来源:test_tools.py
示例18: _prepare_dynamic
def _prepare_dynamic(self, device_path='/dev/vdb', is_mysql_installed=True,
backup_id=None, is_root_enabled=False,
overrides=None):
# covering all outcomes is starting to cause trouble here
COUNT = 1 if device_path else 0
backup_info = None
if backup_id is not None:
backup_info = {'id': backup_id,
'location': 'fake-location',
'type': 'InnoBackupEx',
'checksum': 'fake-checksum',
}
# TODO(juice): this should stub an instance of the MySqlAppStatus
mock_status = mock()
when(dbaas.MySqlAppStatus).get().thenReturn(mock_status)
when(mock_status).begin_install().thenReturn(None)
when(VolumeDevice).format().thenReturn(None)
when(VolumeDevice).migrate_data(any()).thenReturn(None)
when(VolumeDevice).mount().thenReturn(None)
when(dbaas.MySqlApp).stop_db().thenReturn(None)
when(dbaas.MySqlApp).start_mysql().thenReturn(None)
when(dbaas.MySqlApp).install_if_needed(any()).thenReturn(None)
when(backup).restore(self.context,
backup_info,
'/var/lib/mysql').thenReturn(None)
when(dbaas.MySqlApp).secure(any()).thenReturn(None)
when(dbaas.MySqlApp).secure_root(any()).thenReturn(None)
(when(pkg.Package).pkg_is_installed(any()).
thenReturn(is_mysql_installed))
when(dbaas.MySqlAdmin).is_root_enabled().thenReturn(is_root_enabled)
when(dbaas.MySqlAdmin).create_user().thenReturn(None)
when(dbaas.MySqlAdmin).create_database().thenReturn(None)
when(os.path).exists(any()).thenReturn(True)
# invocation
self.manager.prepare(context=self.context,
packages=None,
memory_mb='2048',
databases=None,
users=None,
device_path=device_path,
mount_point='/var/lib/mysql',
backup_info=backup_info,
overrides=overrides)
# verification/assertion
verify(mock_status).begin_install()
verify(VolumeDevice, times=COUNT).format()
verify(dbaas.MySqlApp, times=COUNT).stop_db()
verify(VolumeDevice, times=COUNT).migrate_data(
any())
if backup_info:
verify(backup).restore(self.context, backup_info, '/var/lib/mysql')
verify(dbaas.MySqlApp).install_if_needed(any())
# We dont need to make sure the exact contents are there
verify(dbaas.MySqlApp).secure(any(), overrides)
verify(dbaas.MySqlAdmin, never).create_database()
verify(dbaas.MySqlAdmin, never).create_user()
verify(dbaas.MySqlApp).secure_root(secure_remote_root=any())
开发者ID:abramley,项目名称:trove,代码行数:60,代码来源:test_mysql_manager.py
示例19: test_CrashlogListAction
def test_CrashlogListAction(self):
storage = mock()
action = crashlog.List(storage, **{'name': 'CrashlogName'})
when(storage).find(any(str), any(list)).thenReturn(Chain([lambda: 'Ok']))
action.execute().get()
verify(storage).find('crashlogs', ['CrashlogName'])
开发者ID:nexusriot,项目名称:cocaine-framework-python,代码行数:7,代码来源:test_tools.py
示例20: _prepare_dynamic
def _prepare_dynamic(self, device_path='/dev/vdb', is_redis_installed=True,
backup_info=None, is_root_enabled=False):
# covering all outcomes is starting to cause trouble here
dev_path = 1 if device_path else 0
mock_status = mock()
when(redis_service.RedisAppStatus).get().thenReturn(mock_status)
when(mock_status).begin_install().thenReturn(None)
when(VolumeDevice).format().thenReturn(None)
when(VolumeDevice).mount().thenReturn(None)
when(redis_service.RedisApp).start_redis().thenReturn(None)
when(redis_service.RedisApp).install_if_needed().thenReturn(None)
when(backup).restore(self.context, backup_info).thenReturn(None)
when(redis_service.RedisApp).write_config(any()).thenReturn(None)
when(redis_service.RedisApp).complete_install_or_restart(
any()).thenReturn(None)
self.manager.prepare(self.context, self.packages,
None, '2048',
None, device_path=device_path,
mount_point='/var/lib/redis',
backup_info=backup_info)
verify(redis_service.RedisAppStatus, times=2).get()
verify(mock_status).begin_install()
verify(VolumeDevice, times=dev_path).format()
verify(VolumeDevice, times=dev_path).mount(redis_system.REDIS_BASE_DIR)
verify(redis_service.RedisApp).install_if_needed(self.packages)
verify(redis_service.RedisApp).write_config(None)
verify(redis_service.RedisApp).complete_install_or_restart()
开发者ID:rgeethapriya,项目名称:trove,代码行数:28,代码来源:test_manager.py
注:本文中的mockito.any函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论