FreshPixels commited on
Commit
7595c34
·
verified ·
1 Parent(s): f155ba7

Create tests/conftest.py

Browse files
Files changed (1) hide show
  1. tests/conftest.py +49 -0
tests/conftest.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import pytest
5
+
6
+ from core.config.settings import get_settings
7
+
8
+
9
+ @pytest.fixture(autouse=True)
10
+ def _reset_settings_cache():
11
+ """Reset the lru_cache on get_settings() before each test.
12
+
13
+ This ensures that each test gets a fresh Settings instance
14
+ based on the environment variables active at that point.
15
+ """
16
+ get_settings.cache_clear()
17
+ yield
18
+ get_settings.cache_clear()
19
+
20
+
21
+ @pytest.fixture
22
+ def env_bot_token():
23
+ """Provide a valid test bot token in the environment."""
24
+ os.environ["BOT_TOKEN"] = "123456789:AAHdqTcvCH1vGWJxfSeofSAsQK6PALsAWo"
25
+ yield
26
+ os.environ.pop("BOT_TOKEN", None)
27
+
28
+
29
+ @pytest.fixture
30
+ def env_admin_id():
31
+ """Provide a valid test admin ID in the environment."""
32
+ os.environ["ADMIN_ID"] = "123456789"
33
+ yield
34
+ os.environ.pop("ADMIN_ID", None)
35
+
36
+
37
+ @pytest.fixture
38
+ def env_openai_key():
39
+ """Provide a dummy OpenAI API key in the environment."""
40
+ os.environ["OPENAI_API_KEY"] = "sk-test-key-for-unit-tests"
41
+ yield
42
+ os.environ.pop("OPENAI_API_KEY", None)
43
+
44
+
45
+ @pytest.fixture
46
+ def env_full(env_bot_token, env_admin_id, env_openai_key):
47
+ """Set all required environment variables for tests."""
48
+ pass
49
+