Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit 2b0efac

Browse files
committed
use fakeseamconnect to run tests
1 parent 906bc1f commit 2b0efac

File tree

1 file changed

+9
-52
lines changed

1 file changed

+9
-52
lines changed

tests/conftest.py

+9-52
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import os
1+
import random
2+
import string
23
import pytest
34
from seamapi import Seam
4-
import time
5-
import requests
65
from dotenv import load_dotenv
76
from typing import Any
87
from dataclasses import dataclass
9-
import sys
10-
from testcontainers.postgres import PostgresContainer
11-
from testcontainers.core.container import DockerContainer
12-
from testcontainers.core.waiting_utils import wait_for_logs
138

149

1510
@pytest.fixture(autouse=True)
@@ -27,55 +22,17 @@ class SeamBackend:
2722
# dramatically reduce test time to switch
2823
@pytest.fixture(scope="function")
2924
def seam_backend():
30-
with PostgresContainer("postgres:15", dbname="postgres") as pg:
31-
db_host = pg.get_container_host_ip()
32-
db_url = pg.get_connection_url()
33-
34-
# UPSTREAM: https://github.com/testcontainers/testcontainers-python/issues/159
35-
docker_info = pg.get_docker_client().client.info()
36-
if docker_info["OperatingSystem"] == "Docker Desktop":
37-
container_host = "host.docker.internal"
38-
db_url = db_url.replace(db_host, container_host)
39-
db_host = container_host
40-
elif db_host == "localhost":
41-
container_host = "172.17.0.1" # linux equivalent of host.docker.internal
42-
db_url = db_url.replace(db_host, container_host)
43-
db_host = container_host
44-
45-
with DockerContainer(
46-
os.environ.get("SEAM_CONNECT_IMAGE", "ghcr.io/seamapi/seam-connect")
47-
).with_env("DATABASE_URL", db_url).with_env(
48-
"POSTGRES_DATABASE", "postgres"
49-
).with_env(
50-
"NODE_ENV", "test"
51-
).with_env(
52-
"POSTGRES_HOST",
53-
db_host,
54-
).with_env(
55-
"SERVER_BASE_URL", "http://localhost:3020"
56-
).with_env(
57-
"SEAMTEAM_ADMIN_PASSWORD", "1234"
58-
).with_env(
59-
"PORT", "3020"
60-
).with_env(
61-
"ENABLE_UNMANAGED_DEVICES", "true"
62-
).with_bind_ports(
63-
3020, 3020
64-
).with_command(
65-
"start:for-integration-testing"
66-
) as sc_container:
67-
wait_for_logs(sc_container, r"started server", timeout=20)
68-
requests.get("http://localhost:3020/health")
69-
yield SeamBackend(
70-
url="http://localhost:3020",
71-
sandbox_api_key="seam_sandykey_0000000000000000000sand",
72-
)
25+
random_string = ''.join(random.choices(string.ascii_uppercase + string.digits, k=10))
26+
yield SeamBackend(
27+
url=f"https://{random_string}.fakeseamconnect.seam.vc",
28+
sandbox_api_key="seam_apikey1_token",
29+
)
7330

7431

7532
@pytest.fixture
76-
def seam(seam_backend: Any, dotenv_fixture: Any):
33+
def seam(seam_backend: Any):
7734
seam = Seam(api_url=seam_backend.url, api_key=seam_backend.sandbox_api_key)
78-
seam.make_request("POST", "/workspaces/reset_sandbox")
35+
# seam.make_request("POST", "/workspaces/reset_sandbox")
7936
yield seam
8037

8138

0 commit comments

Comments
 (0)