Skip to content

Commit

Permalink
Use modern tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 13, 2024
1 parent 9725272 commit abbfef0
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from unittest.mock import patch

import boto3
import pytest
from botocore.stub import Stubber
from freezegun import freeze_time
from singer_sdk.testing import get_standard_tap_tests
from singer_sdk.testing import get_tap_test_class

from tap_cloudwatch.cloudwatch_api import CloudwatchAPI
from tap_cloudwatch.tap import TapCloudWatch
Expand All @@ -23,12 +24,12 @@
client = boto3.client("logs", region_name="us-east-1")
stubber = Stubber(client)

BaseTapTests = get_tap_test_class(TapCloudWatch, config=SAMPLE_CONFIG)

# Run standard built-in tap tests from the SDK:
@freeze_time("2022-12-30")
@patch.object(CloudwatchAPI, "_create_client", return_value=client)
def test_standard_tap_tests(patch_client):
"""Run standard tap tests from the SDK."""

@pytest.fixture
def stub():
"""Return a stubber."""
stubber.add_response(
"start_query",
{"queryId": "123"},
Expand All @@ -40,6 +41,7 @@ def test_standard_tap_tests(patch_client):
"startTime": int(datetime_from_str("2022-12-29 00:00:00").timestamp()),
},
)

stubber.add_response(
"get_query_results",
{
Expand All @@ -55,8 +57,14 @@ def test_standard_tap_tests(patch_client):
},
{"queryId": "123"},
)

stubber.activate()

tests = get_standard_tap_tests(TapCloudWatch, config=SAMPLE_CONFIG)
for test in tests:
test()
yield


@patch.object(CloudwatchAPI, "_create_client", return_value=client)
@freeze_time("2022-12-30")
@pytest.mark.usefixtures("stub", "patch_cloudwatch")
class TestTapCloudWatch(BaseTapTests):
"""Tests for tap-cloudwatch."""

0 comments on commit abbfef0

Please sign in to comment.