@@ -18,6 +18,7 @@ def test_from_env(self):
1818 "client_id" : "test_client_id" ,
1919 "client_secret" : "test_secret" ,
2020 "login_url" : "https://test.login.url" ,
21+ "dataspace" : "test_dataspace" , # Added dataspace
2122 }
2223
2324 with patch .dict (
@@ -30,6 +31,30 @@ def test_from_env(self):
3031 assert creds .client_id == test_creds ["client_id" ]
3132 assert creds .client_secret == test_creds ["client_secret" ]
3233 assert creds .login_url == test_creds ["login_url" ]
34+ assert creds .dataspace == test_creds ["dataspace" ] # Added dataspace assertion
35+
36+ def test_from_env_without_dataspace (self ):
37+ """Test loading credentials from environment variables without dataspace."""
38+ test_creds = {
39+ "username" : "test_user" ,
40+ "password" : "test_pass" ,
41+ "client_id" : "test_client_id" ,
42+ "client_secret" : "test_secret" ,
43+ "login_url" : "https://test.login.url" ,
44+ }
45+
46+ # Create env dict without dataspace
47+ env_dict = {v : test_creds [k ] for k , v in ENV_CREDENTIALS .items () if k != "dataspace" }
48+
49+ with patch .dict (os .environ , env_dict , clear = True ):
50+ creds = Credentials .from_env ()
51+
52+ assert creds .username == test_creds ["username" ]
53+ assert creds .password == test_creds ["password" ]
54+ assert creds .client_id == test_creds ["client_id" ]
55+ assert creds .client_secret == test_creds ["client_secret" ]
56+ assert creds .login_url == test_creds ["login_url" ]
57+ assert creds .dataspace is None # Should default to None
3358
3459 def test_from_env_missing_vars (self ):
3560 """Test that missing environment variables raise appropriate error."""
@@ -47,13 +72,15 @@ def test_from_ini(self):
4772 client_id = ini_client_id
4873 client_secret = ini_secret
4974 login_url = https://ini.login.url
75+ dataspace = ini_dataspace
5076
5177 [other_profile]
5278 username = other_user
5379 password = other_pass
5480 client_id = other_client_id
5581 client_secret = other_secret
5682 login_url = https://other.login.url
83+ dataspace = other_dataspace
5784 """
5885
5986 with (
@@ -73,6 +100,7 @@ def test_from_ini(self):
73100 assert creds .client_id == "ini_client_id"
74101 assert creds .client_secret == "ini_secret"
75102 assert creds .login_url == "https://ini.login.url"
103+ assert creds .dataspace == "ini_dataspace"
76104
77105 # Test other profile
78106 creds = Credentials .from_ini (
@@ -83,6 +111,7 @@ def test_from_ini(self):
83111 assert creds .client_id == "other_client_id"
84112 assert creds .client_secret == "other_secret"
85113 assert creds .login_url == "https://other.login.url"
114+ assert creds .dataspace == "other_dataspace"
86115
87116 def test_from_available_env (self ):
88117 """Test that from_available uses environment variables when available."""
@@ -92,6 +121,7 @@ def test_from_available_env(self):
92121 "client_id" : "test_client_id" ,
93122 "client_secret" : "test_secret" ,
94123 "login_url" : "https://test.login.url" ,
124+ "dataspace" : "test_dataspace" , # Added dataspace
95125 }
96126
97127 with (
@@ -107,6 +137,7 @@ def test_from_available_env(self):
107137 assert creds .client_id == test_creds ["client_id" ]
108138 assert creds .client_secret == test_creds ["client_secret" ]
109139 assert creds .login_url == test_creds ["login_url" ]
140+ assert creds .dataspace == test_creds ["dataspace" ] # Added dataspace assertion
110141
111142 def test_from_available_ini (self ):
112143 """Test that from_available uses INI file when env vars not available."""
@@ -117,6 +148,7 @@ def test_from_available_ini(self):
117148 client_id = ini_client_id
118149 client_secret = ini_secret
119150 login_url = https://ini.login.url
151+ dataspace = ini_dataspace
120152 """
121153
122154 with (
@@ -137,6 +169,7 @@ def test_from_available_ini(self):
137169 assert creds .client_id == "ini_client_id"
138170 assert creds .client_secret == "ini_secret"
139171 assert creds .login_url == "https://ini.login.url"
172+ assert creds .dataspace == "ini_dataspace"
140173
141174 def test_from_available_no_creds (self ):
142175 """Test that from_available raises error when no credentials are found."""
0 commit comments