|
1 | 1 | # flake8: noqa: F405
|
| 2 | +import os |
2 | 3 | from copy import deepcopy
|
| 4 | +from unittest.mock import patch |
3 | 5 |
|
4 |
| -from .base import * # noqa: F403, F401 |
| 6 | +from dotenv import dotenv_values |
| 7 | + |
| 8 | +# Create a .env.testing file in the backend directory to store different test settings and |
| 9 | +# override the default ones. For different test settings, provide the TEST_ENV_FILE |
| 10 | +# environment variable with the name of the file to use. Everything that starts with |
| 11 | +# .env.testing will be ignored by git. |
| 12 | +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 13 | +TEST_ENV_FILE = os.getenv("TEST_ENV_FILE", ".env.testing") |
| 14 | +TEST_ENV_VARS = dotenv_values(os.path.join(BASE_DIR, f"../../../{TEST_ENV_FILE}")) |
| 15 | + |
| 16 | + |
| 17 | +def getenv_for_tests(key: str, default: str = "") -> str: |
| 18 | + return TEST_ENV_VARS.get(key, default) |
| 19 | + |
| 20 | + |
| 21 | +with patch("os.getenv", getenv_for_tests) as load_dotenv: |
| 22 | + # Avoid loading .env settings to prevent conflicts with the test settings, |
| 23 | + # but allow custom settings to be loaded from the .env.test file in the |
| 24 | + # backend root directory. |
| 25 | + from .base import * # noqa: F403, F401 |
5 | 26 |
|
6 | 27 | TESTS = True
|
7 | 28 |
|
|
67 | 88 | if "baserow.middleware.ConcurrentUserRequestsMiddleware" in MIDDLEWARE:
|
68 | 89 | MIDDLEWARE.remove("baserow.middleware.ConcurrentUserRequestsMiddleware")
|
69 | 90 |
|
70 |
| - |
71 |
| -BASEROW_OPENAI_API_KEY = None |
72 |
| -BASEROW_OPENAI_ORGANIZATION = None |
73 |
| -BASEROW_OPENAI_MODELS = [] |
74 |
| -BASEROW_OPENROUTER_API_KEY = None |
75 |
| -BASEROW_OPENROUTER_ORGANIZATION = None |
76 |
| -BASEROW_OPENROUTER_MODELS = [] |
77 |
| -BASEROW_ANTHROPIC_API_KEY = None |
78 |
| -BASEROW_ANTHROPIC_MODELS = [] |
79 |
| -BASEROW_MISTRAL_API_KEY = None |
80 |
| -BASEROW_MISTRAL_MODELS = [] |
81 |
| -BASEROW_OLLAMA_HOST = None |
82 |
| -BASEROW_OLLAMA_MODELS = [] |
83 |
| - |
84 | 91 | PUBLIC_BACKEND_URL = "http://localhost:8000"
|
85 | 92 | PUBLIC_WEB_FRONTEND_URL = "http://localhost:3000"
|
86 | 93 | BASEROW_EMBEDDED_SHARE_URL = "http://localhost:3000"
|
|
0 commit comments