From 657494764292c919451bc1dfe53e76c91e64200a Mon Sep 17 00:00:00 2001 From: Ben Verbeken Date: Tue, 27 Jan 2026 16:33:17 +0100 Subject: [PATCH] Set default API URL and secret for local testing --- .github/workflows/build.yml | 1 + tests/seatsioClientTest.py | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82a3f4b..a1d1056 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,5 +27,6 @@ jobs: timezone: Europe/Brussels - run: uv run pytest -n 16 env: + API_URL: https://api-staging-eu.seatsio.net DEMO_COMPANY_SECRET_KEY: ${{ secrets.DEMO_COMPANY_SECRET_KEY }} CORE_V2_STAGING_EU_SYSTEM_API_SECRET: ${{ secrets.CORE_V2_STAGING_EU_SYSTEM_API_SECRET }} diff --git a/tests/seatsioClientTest.py b/tests/seatsioClientTest.py index 4f5e703..b47f401 100644 --- a/tests/seatsioClientTest.py +++ b/tests/seatsioClientTest.py @@ -1,15 +1,13 @@ import os +import time import unittest import uuid -import time import requests import seatsio from seatsio.region import Region -BASE_URL = "https://api-staging-eu.seatsio.net" - class SeatsioClientTest(unittest.TestCase): @@ -24,11 +22,11 @@ def tearDown(self): super(SeatsioClientTest, self).tearDown() def newClient(self, secret_key): - return seatsio.Client(Region(BASE_URL), secret_key) + return seatsio.Client(Region(self.base_url()), secret_key) def create_test_company(self): response = requests.post( - url=BASE_URL + "/system/private/create-test-company", + url=self.base_url() + "/system/private/create-test-company", auth=(self.system_api_secret(), '') ) if response.ok: @@ -36,9 +34,8 @@ def create_test_company(self): else: raise Exception("Failed to create a test user") - @staticmethod - def create_client(secret_key, workspace_key): - return seatsio.Client(Region(BASE_URL), secret_key, workspace_key) + def create_client(self, secret_key, workspace_key): + return seatsio.Client(Region(self.base_url()), secret_key, workspace_key) @staticmethod def random_email(): @@ -66,7 +63,7 @@ def create_test_chart_from_file(self, file): with open(os.path.join(os.path.dirname(__file__), file), 'r') as test_chart_json: data = test_chart_json.read().replace('\n', '') chart_key = str(uuid.uuid4()) - url = BASE_URL + "/system/public/charts/" + chart_key + url = self.base_url() + "/system/public/charts/" + chart_key response = requests.post( url=url, headers={"Accept": "application/json"}, @@ -90,10 +87,13 @@ def wait_for_status_changes(self, event, num_status_changes): else: return status_changes - def system_api_secret(self): - secret = os.getenv("CORE_V2_STAGING_EU_SYSTEM_API_SECRET") - assert secret, "Missing CORE_V2_STAGING_EU_SYSTEM_API_SECRET" - return secret + @staticmethod + def base_url(): + return os.getenv("API_URL") or "http://localhost:9001" + + @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"]