Skip to content

Commit

Permalink
Add six unit tests for aws/triggers (#38819)
Browse files Browse the repository at this point in the history
* Remove test references from test_project_structure.py
  • Loading branch information
slycyberguy authored Apr 15, 2024
1 parent 1aa25f1 commit 76e2b72
Show file tree
Hide file tree
Showing 7 changed files with 680 additions and 6 deletions.
6 changes: 0 additions & 6 deletions tests/always/test_project_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@ def test_providers_modules_should_have_tests(self):
"tests/providers/amazon/aws/sensors/test_emr.py",
"tests/providers/amazon/aws/sensors/test_sagemaker.py",
"tests/providers/amazon/aws/test_exceptions.py",
"tests/providers/amazon/aws/triggers/test_athena.py",
"tests/providers/amazon/aws/triggers/test_batch.py",
"tests/providers/amazon/aws/triggers/test_eks.py",
"tests/providers/amazon/aws/triggers/test_emr.py",
"tests/providers/amazon/aws/triggers/test_glue_crawler.py",
"tests/providers/amazon/aws/triggers/test_lambda_function.py",
"tests/providers/amazon/aws/triggers/test_rds.py",
"tests/providers/amazon/aws/triggers/test_step_function.py",
"tests/providers/amazon/aws/utils/test_rds.py",
"tests/providers/amazon/aws/utils/test_sagemaker.py",
Expand Down
42 changes: 42 additions & 0 deletions tests/providers/amazon/aws/triggers/test_athena.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import annotations

from airflow.providers.amazon.aws.triggers.athena import AthenaTrigger


class TestAthenaTrigger:
def test_serialization(self):
query_execution_id = "test_query_execution_id"
waiter_delay = 30
waiter_max_attempts = 60
aws_conn_id = "aws_default"

trigger = AthenaTrigger(
query_execution_id=query_execution_id,
waiter_delay=waiter_delay,
waiter_max_attempts=waiter_max_attempts,
aws_conn_id=aws_conn_id,
)
classpath, kwargs = trigger.serialize()
assert classpath == "airflow.providers.amazon.aws.triggers.athena.AthenaTrigger"
assert kwargs == {
"query_execution_id": "test_query_execution_id",
"waiter_delay": 30,
"waiter_max_attempts": 60,
"aws_conn_id": "aws_default",
}
43 changes: 43 additions & 0 deletions tests/providers/amazon/aws/triggers/test_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from __future__ import annotations

from airflow.providers.amazon.aws.triggers.batch import BatchJobTrigger


class TestBatchJobTrigger:
def test_serialization(self):
job_id = "test_job_id"
aws_conn_id = "aws_default"
region_name = "us-west-2"

trigger = BatchJobTrigger(
job_id=job_id,
aws_conn_id=aws_conn_id,
region_name=region_name,
)

classpath, kwargs = trigger.serialize()
assert classpath == "airflow.providers.amazon.aws.triggers.batch.BatchJobTrigger"
assert kwargs == {
"job_id": "test_job_id",
"waiter_delay": 5,
"waiter_max_attempts": 720,
"aws_conn_id": "aws_default",
"region_name": "us-west-2",
}
Loading

0 comments on commit 76e2b72

Please sign in to comment.