aws-solutions / content-localization-on-aws

Automatically generate multi-language subtitles using AWS AI/ML services. Machine generated subtitles can be edited to improve accuracy and downstream tracks will automatically be regenerated based on the edits. Built on Media Insights Engine (https://github.com/awslabs/aws-media-insights-engine)
Apache License 2.0
41 stars 17 forks source link

Add unit tests for lambda code written in Python #367

Closed colinazn closed 1 year ago

colinazn commented 1 year ago

The solution had end-to-end tests but no unit tests so code coverage scans reported 0% coverage. The solution includes code for three Lambda functions under the source directory in addition to the website code located in source/website. For now, we are not creating unit tests for the web UI code so that leaves the Lambda functions, which are all implemented in Python.

Added a unit directory under the test directory including a set of unit tests for each of the three Lambda functions, plus a runner script to run the test cases. Also, updated deployment/run-unit-tests.sh to run the new unit tests script so they will run in the build pipeline.

Note: Tests for anonymous-data-logger were copied from the media-insights-on-aws solution, which includes the same Lambda function and already includes unit tests.

This change also includes some refactoring of the Lambda functions code to resolve issues flagged by SonarQube scans.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.