forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
52 lines (40 loc) · 1.6 KB
/
Copy pathconftest.py
File metadata and controls
52 lines (40 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Pytest configuration for integration tests.
"""
import os
import sys
import firebase_admin
import pytest
from dotenv import load_dotenv
from firebase_admin import credentials
# Add project root to path (go up from integration -> tests -> backend -> root)
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..'))
sys.path.insert(0, project_root)
# Also add backend directory
backend_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))
if backend_dir not in sys.path:
sys.path.insert(0, backend_dir)
env_file = os.path.join(backend_dir, '.env')
if os.path.exists(env_file):
load_dotenv(env_file)
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = backend_dir + "/" + os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
@pytest.fixture(scope="session", autouse=True)
def initialize_firebase():
"""Initialize Firebase Admin SDK before running tests"""
try:
cred = credentials.ApplicationDefault()
firebase_admin.initialize_app(cred)
print("✅ Firebase initialized successfully")
except Exception as e:
print(f"❌ Failed to initialize Firebase: {e}")
print("Make sure GOOGLE_APPLICATION_CREDENTIALS is set")
raise
yield
def pytest_configure(config):
"""Configure pytest with custom markers"""
config.addinivalue_line("markers", "integration: mark test as an integration test")
def pytest_collection_modifyitems(config, items):
"""Automatically mark all tests in integration folder"""
for item in items:
if "integration" in str(item.fspath):
item.add_marker(pytest.mark.integration)