Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
37 changes: 25 additions & 12 deletions tests/reports/usage/testUsageReports.py
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -17,21 +20,31 @@ 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))

assert_that(len(report) > 0).is_true()
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")
9 changes: 1 addition & 8 deletions tests/seatsioClientTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading