test(phase-17): add automated tests for Red/Blue workflow, templates CRUD, and V2 metrics (T-125, T-126, T-127)
This commit is contained in:
@@ -86,6 +86,54 @@ def red_tech_user(db):
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def blue_tech_user(db):
|
||||
"""Create a blue_tech user for testing."""
|
||||
user = User(
|
||||
username="bluetech",
|
||||
email="bluetech@test.com",
|
||||
hashed_password=hash_password("bluetech123"),
|
||||
role="blue_tech",
|
||||
is_active=True,
|
||||
)
|
||||
db.add(user)
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def red_lead_user(db):
|
||||
"""Create a red_lead user for testing."""
|
||||
user = User(
|
||||
username="redlead",
|
||||
email="redlead@test.com",
|
||||
hashed_password=hash_password("redlead123"),
|
||||
role="red_lead",
|
||||
is_active=True,
|
||||
)
|
||||
db.add(user)
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def blue_lead_user(db):
|
||||
"""Create a blue_lead user for testing."""
|
||||
user = User(
|
||||
username="bluelead",
|
||||
email="bluelead@test.com",
|
||||
hashed_password=hash_password("bluelead123"),
|
||||
role="blue_lead",
|
||||
is_active=True,
|
||||
)
|
||||
db.add(user)
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def admin_token(client, admin_user):
|
||||
"""Get an auth token for the admin user."""
|
||||
@@ -116,3 +164,51 @@ def auth_headers(admin_token):
|
||||
def red_tech_headers(red_tech_token):
|
||||
"""Return authorization headers for red_tech user."""
|
||||
return {"Authorization": f"Bearer {red_tech_token}"}
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def blue_tech_token(client, blue_tech_user):
|
||||
"""Get an auth token for the blue_tech user."""
|
||||
response = client.post(
|
||||
"/api/v1/auth/login",
|
||||
data={"username": "bluetech", "password": "bluetech123"},
|
||||
)
|
||||
return response.json()["access_token"]
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def blue_tech_headers(blue_tech_token):
|
||||
"""Return authorization headers for blue_tech user."""
|
||||
return {"Authorization": f"Bearer {blue_tech_token}"}
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def red_lead_token(client, red_lead_user):
|
||||
"""Get an auth token for the red_lead user."""
|
||||
response = client.post(
|
||||
"/api/v1/auth/login",
|
||||
data={"username": "redlead", "password": "redlead123"},
|
||||
)
|
||||
return response.json()["access_token"]
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def red_lead_headers(red_lead_token):
|
||||
"""Return authorization headers for red_lead user."""
|
||||
return {"Authorization": f"Bearer {red_lead_token}"}
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def blue_lead_token(client, blue_lead_user):
|
||||
"""Get an auth token for the blue_lead user."""
|
||||
response = client.post(
|
||||
"/api/v1/auth/login",
|
||||
data={"username": "bluelead", "password": "bluelead123"},
|
||||
)
|
||||
return response.json()["access_token"]
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def blue_lead_headers(blue_lead_token):
|
||||
"""Return authorization headers for blue_lead user."""
|
||||
return {"Authorization": f"Bearer {blue_lead_token}"}
|
||||
|
||||
Reference in New Issue
Block a user