本文整理汇总了Python中mock.Mock.log方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.log方法的具体用法?Python Mock.log怎么用?Python Mock.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.Mock
的用法示例。
在下文中一共展示了Mock.log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_snap_to_over_distance
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_snap_to_over_distance():
config = create_core_test_config({
"movement": {
"walk_speed": 5,
}
})
api_wrapper = create_mock_api_wrapper(config)
path_finder = DirectPathFinder(config)
logger = Mock()
logger.log = Mock(return_value=None)
stepper = Stepper(config, api_wrapper, path_finder, logger)
stepper.start(51.50451, -0.07607, 10)
# pre-calculated distance is 17.8 meters
stepper.snap_to(51.50436, -0.07616, 11)
pgo = api_wrapper.get_api()
lat, lng, alt = pgo.get_position()
assert stepper.current_lat == 51.50451
assert stepper.current_lng == -0.07607
assert stepper.current_alt == 10
assert lat == 51.50451
assert lng == -0.07607
assert alt == 10
示例2: test_execute_fails
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_execute_fails(self):
engine = Mock()
engine.log = Mock()
engine.log.info = MagicMock()
engine.log.failed = MagicMock()
topics = [Mock()]
get_topics_mock = Mock(return_value=topics)
execute_mock1 = MagicMock(side_effect=Exception)
execute_mock2 = MagicMock(side_effect=Exception)
self.tracker1.execute = execute_mock1
self.tracker1.get_topics = get_topics_mock
self.tracker2.execute = execute_mock2
self.tracker2.get_topics = get_topics_mock
self.trackers_manager.execute(engine, None)
self.assertTrue(engine.log.info.called)
self.assertTrue(engine.log.failed.called)
get_topics_mock.assert_called_with(None)
execute_mock1.assert_called_with(topics, engine)
execute_mock2.assert_called_with(topics, engine)
示例3: test_navigate_campsite_last_position
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_navigate_campsite_last_position(self):
config = create_core_test_config({
"movement": {
"navigator_campsite": None
},
"mapping": {
"location": "0,0"
}
})
api_wrapper = create_mock_api_wrapper(config)
logger = Mock()
logger.log = Mock(return_value=None)
navigator = CamperNavigator(config, api_wrapper, logger)
map_cells = self._create_map_cells()
destinations = list()
for destination in navigator.navigate(map_cells):
assert isinstance(destination, Destination)
assert destination.target_lat == 0
assert destination.target_lng == 0
assert destination.name == "Camping position at 0,0"
destinations.append(destination)
assert len(destinations) == 1
示例4: test_execute_with_ids
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_execute_with_ids(self):
engine = Mock()
engine.log = Mock()
engine.log.info = MagicMock()
engine.log.failed = MagicMock()
topics1 = [Mock()]
get_topics_mock1 = Mock(return_value=topics1)
topics2 = []
get_topics_mock2 = Mock(return_value=topics2)
execute_mock1 = Mock()
# Exception shouldn't be thrown because there are no tocpis for plugin
execute_mock2 = Mock(return_value=Exception)
self.tracker1.execute = execute_mock1
self.tracker1.get_topics = get_topics_mock1
self.tracker2.execute = execute_mock2
self.tracker2.get_topics = get_topics_mock2
ids = [1, 2]
self.trackers_manager.execute(engine, ids)
self.assertTrue(engine.log.info.called)
self.assertFalse(engine.log.failed.called) # Check that exception from tracker2 wasn't raised
get_topics_mock1.assert_called_with(ids)
execute_mock1.assert_called_with(topics1, engine)
get_topics_mock2.assert_called_with(ids)
execute_mock2.assert_not_called()
示例5: test_navigate_campsite_add_before_start
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_navigate_campsite_add_before_start(self):
config = create_core_test_config({
"movement": {
"navigator_campsite": [51.5043872, -0.0741802]
},
})
api_wrapper = create_mock_api_wrapper(config)
logger = Mock()
logger.log = Mock(return_value=None)
navigator = CamperNavigator(config, api_wrapper, logger)
map_cells = self._create_map_cells()
navigator.set_campsite(51.5060435, -0.073983)
destinations = list()
for destination in navigator.navigate(map_cells):
assert isinstance(destination, Destination)
assert destination.target_lat == 51.5060435
assert destination.target_lng == -0.073983
assert destination.name == "Camping position at 51.5060435,-0.073983"
destinations.append(destination)
assert len(destinations) == 1
示例6: test_favorited_pokemon_filter
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_favorited_pokemon_filter(self):
event_manager = EventManager()
logger = Mock()
logger.log = Mock()
transfer_plugin = TransferPokemon(
{
'transfer_on_start': False
},
event_manager,
logger
)
bot = create_mock_bot()
transfer_list = [self._create_pokemon(unique_id=1, favorite=True),
self._create_pokemon(unique_id=2, favorite=True),
self._create_pokemon(unique_id=3, favorite=True),
self._create_pokemon(unique_id=4, favorite=False),
self._create_pokemon(unique_id=5, favorite=True),
self._create_pokemon(unique_id=6, favorite=False)]
result_dict = transfer_plugin.filter_favorited_pokemon(bot=bot, transfer_list=transfer_list)
filtered_list = result_dict["transfer_list"]
assert len(filtered_list) == 2
assert filtered_list[0].unique_id == 4
assert filtered_list[1].unique_id == 6
assert result_dict["filter_list"][0] == "excluding favorited Pokemon"
transfer_list = [self._create_pokemon(favorite=False)]
result_dict = transfer_plugin.filter_favorited_pokemon(bot=bot, transfer_list=transfer_list)
assert len(result_dict["transfer_list"]) == 1
assert len(result_dict["filter_list"]) == 0
self.set_empty_inventory(bot)
assert transfer_plugin.filter_favorited_pokemon(bot=bot) is False
示例7: test_start
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_start():
config = create_core_test_config({
"movement": {
"walk_speed": 4.16,
}
})
api_wrapper = create_mock_api_wrapper(config)
path_finder = DirectPathFinder(config)
logger = Mock()
logger.log = Mock(return_value=None)
stepper = Stepper(config, api_wrapper, path_finder, logger)
stepper.start(51.5044524, -0.0752479, 10)
assert stepper.origin_lat == 51.5044524
assert stepper.origin_lng == -0.0752479
assert stepper.origin_alt == 10
assert stepper.current_lat == 51.5044524
assert stepper.current_lng == -0.0752479
assert stepper.current_alt == 10
pgo = api_wrapper.get_api()
lat, lng, alt = pgo.get_position()
assert lat == 51.5044524
assert lng == -0.0752479
assert alt == 10
示例8: test_init
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_init():
logger = Mock()
logger.log = Mock(return_value=None)
config_namespace = create_core_test_config()
api_wrapper = create_mock_api_wrapper(config_namespace)
event_manager = EventManager()
player_service = Player(api_wrapper, event_manager, logger)
pokemon_service = PokemonService(api_wrapper)
mapper = Mapper(config_namespace, api_wrapper, Mock(), logger)
path_finder = DirectPathFinder(config_namespace)
stepper = Stepper(config_namespace, api_wrapper, path_finder, logger)
navigator = FortNavigator(config_namespace, api_wrapper)
bot = PokemonGoBot(config_namespace, api_wrapper, player_service, pokemon_service, event_manager, mapper, stepper, navigator, logger)
assert len(bot.pokemon_list) == 151
assert len(bot.item_list) == 30
assert bot.position == (0, 0, 0)
assert bot.config is config_namespace
assert bot.api_wrapper is api_wrapper
assert bot.player_service is player_service
assert bot.pokemon_service is pokemon_service
assert bot.event_manager is event_manager
assert bot.mapper is mapper
assert bot.stepper is stepper
assert bot.navigator is navigator
assert bot.logger is logger
示例9: test_init_path_finder_direct
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_init_path_finder_direct():
config = create_core_test_config({
"movement": {
"walk_speed": 4.16,
}
})
api_wrapper = create_mock_api_wrapper(config)
path_finder = DirectPathFinder(config)
logger = Mock()
logger.log = Mock(return_value=None)
stepper = Stepper(config, api_wrapper, path_finder, logger)
assert isinstance(stepper.path_finder, DirectPathFinder)
示例10: test_init_negative_walk
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_init_negative_walk():
config = create_core_test_config({
"movement": {
"walk_speed": -5,
}
})
api_wrapper = create_mock_api_wrapper(config)
path_finder = Mock()
logger = Mock()
logger.log = Mock(return_value=None)
stepper = Stepper(config, api_wrapper, path_finder, logger)
assert stepper.speed == 4.16
示例11: test_ignore_list_filter
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_ignore_list_filter(self):
event_manager = EventManager()
logger = Mock()
logger.log = Mock()
transfer_plugin = TransferPokemon(
{
'transfer_on_start': False,
'use_always_keep_filter': True,
'use_cp_iv_filter': False,
'always_keep': {
'Bulbasaur': True,
'Ivysaur': True,
'Venusaur': True,
}
},
event_manager,
logger
)
bot = create_mock_bot()
transfer_list = [self._create_pokemon(unique_id=1, species_id=1),
self._create_pokemon(unique_id=2, species_id=5),
self._create_pokemon(unique_id=3, species_id=2),
self._create_pokemon(unique_id=4, species_id=4),
self._create_pokemon(unique_id=5, species_id=3),
self._create_pokemon(unique_id=6, species_id=1),
self._create_pokemon(unique_id=7, species_id=5)]
result_dict = transfer_plugin.filter_pokemon_by_ignore_list(bot=bot, transfer_list=transfer_list)
filtered_list = result_dict["transfer_list"]
assert len(filtered_list) == 3
assert filtered_list[0].unique_id == 2
assert filtered_list[1].unique_id == 4
assert filtered_list[2].unique_id == 7
assert "Bulbasaurs" in result_dict["filter_list"][0]
assert "Ivysaurs" in result_dict["filter_list"][0]
assert "Venusaurs" in result_dict["filter_list"][0]
transfer_list = [self._create_pokemon(species_id=42)]
result_dict = transfer_plugin.filter_pokemon_by_ignore_list(bot=bot, transfer_list=transfer_list)
assert len(result_dict["transfer_list"]) == 1
assert len(result_dict["filter_list"]) == 0
transfer_list = [self._create_pokemon(species_id=1)]
result_dict = transfer_plugin.filter_pokemon_by_ignore_list(bot=bot, transfer_list=transfer_list)
assert len(result_dict["transfer_list"]) == 0
assert result_dict["filter_list"][0] == "excluding Bulbasaurs"
self.set_empty_inventory(bot)
assert transfer_plugin.filter_pokemon_by_ignore_list(bot=bot) is False
示例12: test_step
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_step():
config = create_core_test_config({
"movement": {
"walk_speed": 5,
"path_finder": "direct",
"distance_unit": "m"
}
})
api_wrapper = create_mock_api_wrapper(config)
path_finder = DirectPathFinder(config)
logger = Mock()
logger.log = Mock(return_value=None)
stepper = Stepper(config, api_wrapper, path_finder, logger)
stepper.start(51.50451, -0.07607, 10)
destination = Destination(51.506000, -0.075049, 11, name="Test Destination", exact_location=False)
steps = [
(51.504778, -0.075838, 10),
(51.505092, -0.075650, 11),
(51.505436, -0.075446, 11)
]
destination.set_steps(steps)
pgo = api_wrapper.get_api()
# This route is being walked: http://www.darrinward.com/lat-long/?id=2163411
# pre-calculated distance is 17.8 meters
pointer = 0
for _ in stepper.step(destination):
target_lat, target_lng, target_alt = steps[pointer]
assert stepper.current_lat == target_lat
assert stepper.current_lng == target_lng
assert stepper.current_alt == target_alt
bot_lat, bot_lng, bot_alt = pgo.get_position()
assert bot_lat == target_lat
assert bot_lng == target_lng
assert bot_alt == target_alt
pointer += 1
assert pointer == 3
bot_lat, bot_lng, bot_alt = pgo.get_position()
assert bot_lat == 51.505436
assert bot_lng == -0.075446
assert bot_alt == 11
assert stepper.current_lat == 51.505436
assert stepper.current_lng == -0.075446
assert stepper.current_alt == 11
示例13: __do_not_call
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def __do_not_call(self):
# s = Settings
s = Mock()
# methods:
s.isOptionWritable = Mock(return_value=True)
s.set = Mock(return_value=None)
s.save = Mock()
# props:
s.log = Mock()
# subobjects
s.p = Mock()
s.p.getboolean = Mock(return_value=True)
s.p.has_option = Mock
示例14: test_wrap_pokemon
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_wrap_pokemon(self):
event_manager = EventManager()
logger = Mock()
logger.log = Mock()
transfer_plugin = TransferPokemon(
{
'transfer_on_start': False
},
event_manager,
logger
)
transfer_list = [self._create_pokemon(unique_id=1)]
transfer_list = transfer_plugin.wrap_pokemon_in_list(transfer_list=transfer_list, pokemon=self._create_pokemon(unique_id=2))["transfer_list"]
assert len(transfer_list) == 2
assert transfer_list[0].unique_id == 1
assert transfer_list[1].unique_id == 2
示例15: test_navigate_campsite_invalid_index
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import log [as 别名]
def test_navigate_campsite_invalid_index(self):
config = create_core_test_config({
"movement": {
"navigator_campsite": [51.5043872, -0.0741802]
},
})
api_wrapper = create_mock_api_wrapper(config)
logger = Mock()
logger.log = Mock(return_value=None)
navigator = CamperNavigator(config, api_wrapper, logger)
navigator.pointer = 100
map_cells = self._create_map_cells()
destinations = list()
for _ in navigator.navigate(map_cells):
pass
assert len(destinations) == 0