コード例 #1
0
    def test_logging_to_mocked(self):
        """Our mocked log is just a string, so make sure we stash it in the right place"""
        setuplogging.AWS_LOGGER = None
        setuplogging.LOGGING_HANDLER = None

        setuplogging.initialize_logging(mocking=True)

        string_to_log = "log this string"
        setuplogging.LOGGING_HANDLER(string_to_log)
        assert string_to_log == setuplogging.MOCK_LOG
コード例 #2
0
ファイル: test_logging.py プロジェクト: bp100a/JerseyTrains
    def test_logging_to_prod(self):
        """In this test we do all the prod setup but we change
        out where PROD logs to and log to a locally defined function"""
        setuplogging.AWS_LOGGER = None
        setuplogging.LOGGING_HANDLER = None

        setuplogging.initialize_logging(mocking=False)
        setuplogging.AWS_LOGGER = MockAWSLogging()

        string_to_log = "log this string"
        setuplogging.LOGGING_HANDLER(string_to_log)
コード例 #3
0
def get_taplist_response(intent: dict):
    """ return the taplist  """
    try:
        brewery_name = intent['slots']['brewery']['value']
        bobj, brewery_id = brewerylist.BREWERY_PAGES.find_brewery(
            brewery_name=brewery_name)

        # if we couldn't find the brewery, respond with a the list of breweries we know
        if brewery_id is None or bobj is None:
            setuplogging.LOGGING_HANDLER("GetTapList, brewery not found: \"{0}\""\
                                         .format(brewery_name))
            return list_of_breweries_response()

        if 'mocked' in intent:
            bobj.mocking = intent['mocked']
        bobj.fetch_taplist(brewery=brewery_id)
        beer_string = bobj.ssml_taplist()
        return response(speech_response_ssml(beer_string, True))
    except KeyError:
        return response(speech_response(ERROR_NO_BREWERY, True))
    except Exception:
        setuplogging.LOGGING_HANDLER("PAGELOAD failure!! brewery \"{0}\""\
                                     .format(brewery_name))
        return response(speech_response(ERROR_BREWERY_PAGE, True))
コード例 #4
0
def lambda_handler(event, context):
    """  App entry point  """
    setuplogging.initialize_logging(
        mocking=False)  # make sure logging is setup
    setuplogging.LOGGING_HANDLER('EVENT{}'.format(event))  # log the event

    if event['session']['new']:
        on_session_started()

    if event['request']['type'] == "LaunchRequest":
        return on_launch(event['request'])
    elif event['request']['type'] == "IntentRequest":
        return on_intent(event['request'], event['session'])
    elif event['request']['type'] == "SessionEndedRequest":
        return on_session_ended()

    return None
コード例 #5
0
def set_home_brewery(request: dict, session: dict):
    """set the home brewery for the user"""

    try:
        brewery = request['intent']['slots']['brewery']['value']
        aws_user_id = session['user']['userId']
        success = brewerylist.BREWERY_PAGES.add_home_brewery(
            brewery_name=brewery, user_id=aws_user_id)
        if success:
            return response(
                speech_response(HOME_BREWERY_SET.format(brewery), True))

        # some problem, tell the user. TBD validate brewery & other things,
        # perhaps ask for clarification
        setuplogging.LOGGING_HANDLER(
            "SetHomeBrewery, brewery not found:\"{0}\"".format(brewery))
        return response(speech_response(CANNOT_SET_HOME.format(brewery), True))
    except KeyError:
        return response(speech_response(ERROR_NO_BREWERY, True))
コード例 #6
0
def log(message: str) -> None:
    if not setuplogging.LOGGING_HANDLER:
        setuplogging.initialize_logging(mocking=True)
    setuplogging.LOGGING_HANDLER(message)