コード例 #1
0
    def test_add_candy_new(self):
        config = create_core_test_config()
        api_wrapper = create_mock_api_wrapper(config)
        event_manager = Mock()
        logger = Mock()
        logger.log = Mock()
        player_service = Player(api_wrapper, event_manager, logger)

        pgo = api_wrapper.get_api()
        pgo.set_response('get_player', self._create_generic_player_response())
        pgo.set_response('get_inventory', self._create_generic_inventory_response())

        before_candies = player_service.get_candy(1)
        assert before_candies == 100

        player_service.add_candy(10, 3)
        after_candies = player_service.get_candy(10)

        assert after_candies == 3
        assert pgo.call_stack_size() == 0
コード例 #2
0
    def test_get_candy_key_error(self):
        config = create_core_test_config()
        api_wrapper = create_mock_api_wrapper(config)
        event_manager = Mock()
        logger = Mock()
        logger.log = Mock()
        player_service = Player(api_wrapper, event_manager, logger)

        pgo = api_wrapper.get_api()
        pgo.set_response('get_player', self._create_generic_player_response())
        pgo.set_response('get_inventory', self._create_generic_inventory_response())

        candies = player_service.get_candy(100)

        assert candies == 0
        assert pgo.call_stack_size() == 0