Skip to content

How to test append_keys? #1341

Closed Answered by peterschutt
lynkfox asked this question in Q&A
Jul 21, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Maybe something like logger.registered_formatter.log_format.get("quote_id") == "Test"?

Although, you should really take it for-granted that if you call logger.append_keys(quote_id=value_passed) that "quote_id" will be in your logs with the correct value. If there was an error in that component of the library, it would be found out pretty quickly by the community of users and addressed.

Assuming that standard_log_keys() is something like this:

def standard_log_keys(logger, **kwargs):
    allowed_keys = {"a", "b", "c"}
    for k in kwargs:
        if k not in allowed_keys:
            raise ValueError(f"'{k}' is not an allowed log key")
    logger.append_keys(**kwargs)

I'd have a test to en…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by heitorlessa
Comment options

You must be logged in to vote
1 reply
@peterschutt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants