[![Build Status](https://cloudzero.semaphoreci.com/badges/cz-common-python/branches/master.svg?key=1fb0a22b-ab5c-46d9-a0d4-4afa93bcde1a)](https://cloudzero.semaphoreci.com/projects/cz-common-python)

# Overview

`cz-common-python` provides the `czc` python package that contains useful feature modules like:

- `czc.authorization`: check the request parameters and token against role
- `czc.constants`: `FEATURE_NAME` and `PROJECT_NAME`
- `czc.concurrency`: `aync_map` function to turn a blocking function into async function
- `czc.concurrency_36`: `aync_map` function to turn a blocking function into async function (Python 3.6 version)
- `czc.date`: convert to/from iso and timestamp formats ... always in UTC
- `czc.domain_events`: create a schema or domain event
- `czc.json`: encode dictionaries with non-serializable elements, e.g. dates
- `czc.schema_validators`: validate common CZ values, e.g. `ORGANIZATION_ID`
- `czc.string`: convert between camel and snake; vacuum pack an unpack
- `czc.token`: decode and check JWTs, can still be referenced as `czc.jwt` for backwards compatibility
- `czc.unittest`: help write unit tests
    - `MockEx` class decorates mocks, adding assertable chainable methods, e.g. `MockEx(mock).was_called_once_with(*args, **kwargs)` does all of the nasty argument unpacking and comparison and compares call count.
    
# 2.0 Breaking Changes:
We upgraded AWS Lambda Powertools to 2.0.0+ (>=2.9.1 to be exact). Honestly, we don't know if this _will_ break you, but since we can't be sure based on your usage of Powertools, we bumped our major version.

# 1.0 Breaking Changes:

## Test Key Forwarding Support
In this version, when test keys are specified on any incoming API (web, iapi, domain events) that are test key aware, 
they will automatically be forwarded on to any other IAPI or domain event that is sent out due to the handler. If the 
receiving side of the IAPI validates the incoming parameters and DOES NOT ALLOW extra parameters, then the IAPI will fail. 

If this happens there are three possible remedies:

1. Fix the IAPI handler (in the server side repo) so that it handles test keys. If the IAPI adds/modifies any database records
than this would be the preferred remedy as it will ensure that those downstream changes are added via test keys and not visible
outside of the test
2. Modify the smoke test in the client repo to not use a test key (not preferred)
3. Use a test key value that ends with `-do-not-forward`. By adding this suffix, the test key will only be used internally and will
not be forwarded to any external calls or events.
