diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b578e7..fb0f1a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,8 @@ jobs: timezone: Europe/Brussels - run: uv run pytest env: - API_URL: https://api-staging-eu.seatsio.net + API_URL: https://api-staging-na.seatsio.net HTTPBIN_URL: http://localhost:8080 - DEMO_COMPANY_SECRET_KEY: ${{ secrets.DEMO_COMPANY_SECRET_KEY }} - CORE_V2_STAGING_EU_SYSTEM_API_SECRET: ${{ secrets.CORE_V2_STAGING_EU_SYSTEM_API_SECRET }} + USAGE_REPORTING_TESTS_API_URL: https://api-staging-eu.seatsio.net + USAGE_REPORTING_TESTS_SECRET_KEY: ${{ secrets.DEMO_COMPANY_SECRET_KEY }} + CORE_V2_API_SECRET: ${{ secrets.CORE_V2_STAGING_NA_SYSTEM_API_SECRET }} diff --git a/tests/reports/usage/testUsageReports.py b/tests/reports/usage/testUsageReports.py index ac74b33..1a648a4 100644 --- a/tests/reports/usage/testUsageReports.py +++ b/tests/reports/usage/testUsageReports.py @@ -1,13 +1,16 @@ +import os +import unittest + +import seatsio from seatsio import Month -from tests.seatsioClientTest import SeatsioClientTest +from seatsio.region import Region from tests.util.asserts import assert_that -class UsageReportTest(SeatsioClientTest): +class UsageReportTest(unittest.TestCase): def test_usage_report_for_all_months(self): - self.assert_demo_company_secret_key_set() - client = self.create_client(self.demo_company_secret_key(), None) + client = self.create_client() report = client.usage_reports.summary_for_all_months() @@ -17,8 +20,7 @@ def test_usage_report_for_all_months(self): assert_that(report.usage[0].month.month).is_equal_to(2) def test_usage_report_month(self): - self.assert_demo_company_secret_key_set() - client = self.create_client(self.demo_company_secret_key(), None) + client = self.create_client() report = client.usage_reports.details_for_month(Month(2021, 11)) @@ -26,12 +28,23 @@ def test_usage_report_month(self): assert_that(len(report[0].usage_by_chart) > 0).is_true() assert_that(report[0].usage_by_chart[0].usage_by_event[0].num_used_objects).is_equal_to(143) - def test_usage_report_event_in_month(self): - self.assert_demo_company_secret_key_set() - client = self.create_client(self.demo_company_secret_key(), None) + client = self.create_client() + + report = client.usage_reports.details_for_event_in_month(580293, Month(2021, 11)) + + assert_that(len(report) > 0).is_true() + assert_that(report[0].num_first_selections).is_equal_to(1) + + def create_client(self): + if not self.api_url() or not self.secret_key(): + self.skipTest("USAGE_REPORTING_TESTS_API_URL or USAGE_REPORTING_TESTS_SECRET_KEY not set, skipping test") + return seatsio.Client(Region(self.api_url()), self.secret_key()) - report = client.usage_reports.details_for_event_in_month(580293, Month(2021, 11)) + @staticmethod + def api_url(): + return os.getenv("USAGE_REPORTING_TESTS_API_URL") - assert_that(len(report) > 0).is_true() - assert_that(report[0].num_first_selections).is_equal_to(1) + @staticmethod + def secret_key(): + return os.getenv("USAGE_REPORTING_TESTS_SECRET_KEY") diff --git a/tests/seatsioClientTest.py b/tests/seatsioClientTest.py index 60e94b9..2f3f309 100644 --- a/tests/seatsioClientTest.py +++ b/tests/seatsioClientTest.py @@ -97,11 +97,4 @@ def httpbin_url(): @staticmethod def system_api_secret(): - return os.getenv("CORE_V2_STAGING_EU_SYSTEM_API_SECRET") or "superSecretSystemApi" - - def demo_company_secret_key(self): - return os.environ["DEMO_COMPANY_SECRET_KEY"] - - def assert_demo_company_secret_key_set(self): - if "DEMO_COMPANY_SECRET_KEY" not in os.environ: - self.skipTest("DEMO_COMPANY_SECRET_KEY environment variable not set, skipping test") + return os.getenv("CORE_V2_API_SECRET") or "superSecretSystemApi"