1
- import os
1
+ import random
2
+ import string
2
3
import pytest
3
4
from seamapi import Seam
4
- import time
5
- import requests
6
5
from dotenv import load_dotenv
7
6
from typing import Any
8
7
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
13
8
14
9
15
10
@pytest .fixture (autouse = True )
@@ -27,55 +22,17 @@ class SeamBackend:
27
22
# dramatically reduce test time to switch
28
23
@pytest .fixture (scope = "function" )
29
24
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
+ )
73
30
74
31
75
32
@pytest .fixture
76
- def seam (seam_backend : Any , dotenv_fixture : Any ):
33
+ def seam (seam_backend : Any ):
77
34
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")
79
36
yield seam
80
37
81
38
0 commit comments