77
88
99@pytest .fixture
10- def mock_env (monkeypatch ):
11- "Set up environment variables for testing."
12- monkeypatch .setenv ("ESA_TOKEN" , "test_token" )
13- monkeypatch .setenv ("ESA_TEAM_NAME" , "test_team" )
14-
15-
16- @pytest .fixture
17- def client (mock_env ):
18- "Return an instance of EsaClient with mocked env vars."
19- return EsaClient ()
10+ def client ():
11+ "Return an instance of EsaClient with specified token and team_name."
12+ return EsaClient (token = "test_token" , team_name = "test_team" )
2013
2114
2215def test_esa_client_initialization (client ):
@@ -27,20 +20,20 @@ def test_esa_client_initialization(client):
2720 assert client .session .headers ["Authorization" ] == f"Bearer { client .token } "
2821
2922
30- def test_esa_client_initialization_missing_token (monkeypatch ):
31- "Test ValueError is raised if ESA_TOKEN is missing."
32- monkeypatch .delenv ("ESA_TOKEN" , raising = False ) # Ensure it's removed if exists
33- monkeypatch .setenv ("ESA_TEAM_NAME" , "test_team" )
23+ def test_esa_client_initialization_missing_token ():
24+ "Test ValueError is raised if token is missing or invalid."
3425 with pytest .raises (ValueError , match = "ESA_TOKEN is required" ):
35- EsaClient ()
26+ EsaClient (token = None , team_name = "test_team" )
27+ with pytest .raises (ValueError , match = "ESA_TOKEN is required" ):
28+ EsaClient (token = "" , team_name = "test_team" )
3629
3730
38- def test_esa_client_initialization_missing_team_name (monkeypatch ):
39- "Test ValueError is raised if ESA_TEAM_NAME is missing."
40- monkeypatch . setenv ( "ESA_TOKEN" , "test_token" )
41- monkeypatch . delenv ( "ESA_TEAM_NAME " , raising = False ) # Ensure it's removed if exists
31+ def test_esa_client_initialization_missing_team_name ():
32+ "Test ValueError is raised if team_name is missing or invalid ."
33+ with pytest . raises ( ValueError , match = "ESA_TEAM_NAME is required" ):
34+ EsaClient ( token = "test_token " , team_name = None )
4235 with pytest .raises (ValueError , match = "ESA_TEAM_NAME is required" ):
43- EsaClient ()
36+ EsaClient (token = "test_token" , team_name = "" )
4437
4538
4639@patch ("esa_client.requests.Session.request" )
0 commit comments