-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MAINTENANCE] Unit tests for allure report and report push lambdas (#88)
* feat: pack unit test into docker
- Loading branch information
1 parent
c49aedc
commit 3bda82c
Showing
15 changed files
with
119 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
FROM public.ecr.aws/lambda/python:3.9 | ||
COPY ./*.py ./ | ||
ADD ./requirements.txt ./requirements.txt | ||
RUN pip3 install -r requirements.txt | ||
COPY ./*.py ./ | ||
CMD ["push_data_report.handler"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ARG IMAGE_NAME=allure_report | ||
ARG VERSION=latest | ||
FROM ${IMAGE_NAME}:${VERSION} | ||
RUN pip install pytest==7.3.1 | ||
ENV BUCKET=test-bucket | ||
COPY ./test*.py ./ | ||
ENTRYPOINT ["pytest", "-qvs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from mapper import get_test_name | ||
|
||
|
||
def test_get_test_name(): | ||
file = { | ||
"expectation_config": { | ||
"expectation_type": "expect_column_values_to_not_be_null", | ||
"kwargs": { | ||
"column": "age" | ||
} | ||
} | ||
} | ||
assert get_test_name(file) == "expect_column_values_to_not_be_null" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ARG IMAGE_NAME=report_push | ||
ARG VERSION=latest | ||
FROM ${IMAGE_NAME}:${VERSION} | ||
RUN pip install pytest==7.3.1 moto==4.1.6 | ||
ENV ENVIRONMENT=local \ | ||
BUCKET=test-bucket \ | ||
DYNAMODB_TABLE=test-table \ | ||
AWS_ACCESS_KEY_ID=test \ | ||
AWS_SECRET_ACCESS_KEY=test \ | ||
AWS_DEFAULT_REGION=us-east-1 \ | ||
SNS_BUGS_TOPIC_ARN=test-topic-arn \ | ||
JIRA_URL=https://jira.localhost \ | ||
DATAQA_JIRA_USERNAME=qauser \ | ||
DATAQA_JIRA_PASSWORD=qapassword | ||
COPY ./test*.py ./ | ||
ENTRYPOINT ["pytest", "-qvs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
from push_data_report import push_cloudwatch_metrics | ||
from moto import mock_cloudwatch | ||
import boto3 | ||
|
||
|
||
suite = 'test_suite' | ||
environment = 'test_environment' | ||
|
||
|
||
@pytest.fixture | ||
@mock_cloudwatch | ||
def conn(): | ||
return boto3.client('cloudwatch') | ||
|
||
|
||
@mock_cloudwatch | ||
def test_push_cloudwatch_metrics_bug_created(conn): | ||
# Define test input | ||
failed = 0 | ||
created_bug_count = 3 | ||
|
||
# Call the method under test | ||
push_cloudwatch_metrics(suite, environment, failed, created_bug_count, | ||
conn) | ||
metrics = conn.list_metrics()["Metrics"] | ||
assert metrics[0]['MetricName'] == 'bug_created_count' | ||
assert metrics[0]['Dimensions'][0]['Value'] == 'test_suite' | ||
assert metrics[0]['Dimensions'][1]['Value'] == 'test_environment' | ||
|
||
|
||
@mock_cloudwatch | ||
def test_push_cloudwatch_metrics(conn): | ||
# Define test input | ||
failed = 5 | ||
created_bug_count = 0 | ||
|
||
# Call the method under test | ||
push_cloudwatch_metrics(suite, environment, failed, created_bug_count, | ||
conn) | ||
metrics = conn.list_metrics()["Metrics"] | ||
assert metrics[0]['MetricName'] == 'suite_failed_count' | ||
assert metrics[0]['Dimensions'][0]['Value'] == 'test_suite' | ||
assert metrics[0]['Dimensions'][1]['Value'] == 'test_environment' |