2121 "use_args" , (True , False ),
2222 ids = ("args" , "no_args" )
2323)
24+ @pytest .mark .parametrize (
25+ "profile" , ("default" , "other" ),
26+ ids = ("default_profile" , "alt_profile" )
27+ )
2428def test_config_setup (
2529 use_env : bool ,
26- use_file : str | None ,
30+ use_file : typing . Literal [ "basic" , "extended" , "pyproject.toml" ] | None ,
2731 use_args : bool ,
32+ profile : typing .Literal ["default" , "other" ],
2833 monkeypatch : pytest .MonkeyPatch ,
2934 mocker : pytest_mock .MockerFixture
3035) -> None :
3136 _token : str = f"{ uuid .uuid4 ()} " .replace ('-' , '' )
3237 _other_token : str = f"{ uuid .uuid4 ()} " .replace ('-' , '' )
3338 _arg_token : str = f"{ uuid .uuid4 ()} " .replace ('-' , '' )
39+ _alt_token : str = f"{ uuid .uuid4 ()} " .replace ("-" , "" )
3440 _url : str = "https://simvue.example.com/"
3541 _other_url : str = "http://simvue.example.com/"
42+ _alt_url : str = "https://simvue-dev.example.com/"
3643 _arg_url : str = "http://simvue.example.io/"
3744 _description : str = "test case for runs"
3845 _description_ppt : str = "test case for runs using pyproject.toml"
@@ -75,6 +82,10 @@ def test_config_setup(
7582 url = "{ _url } "
7683 token = "{ _token } "
7784
85+ [profiles.other]
86+ url = "{ _alt_url } "
87+ token = "{ _alt_token } "
88+
7889 [offline]
7990 cache = "{ _windows_safe } "
8091 """
@@ -104,14 +115,22 @@ def _mocked_find(file_names: list[str], *_, ppt_file=_ppt_file, conf_file=_confi
104115 simvue .config .user .SimvueConfiguration .fetch (mode = "online" )
105116 return
106117 elif use_args :
107- _config = simvue .config .user .SimvueConfiguration .fetch (
118+ _config : SimvueConfiguration = simvue .config .user .SimvueConfiguration .fetch (
108119 server_url = _arg_url ,
109120 server_token = _arg_token ,
110121 mode = "online"
111122 )
123+ elif profile == "other" :
124+ if not use_file :
125+ with pytest .raises (RuntimeError ):
126+ _ = simvue .config .user .SimvueConfiguration .fetch (mode = "online" , profile = "other" )
127+ return
128+ else :
129+ _config = simvue .config .user .SimvueConfiguration .fetch (mode = "online" , profile = "other" )
130+
112131 else :
113132 _config = simvue .config .user .SimvueConfiguration .fetch (mode = "online" )
114-
133+
115134 if use_file and use_file != "pyproject.toml" :
116135 assert _config .config_file () == _config_file
117136
@@ -121,6 +140,10 @@ def _mocked_find(file_names: list[str], *_, ppt_file=_ppt_file, conf_file=_confi
121140 elif use_args :
122141 assert _config .server .url == f"{ _arg_url } api"
123142 assert _config .server .token .get_secret_value () == _arg_token
143+ elif use_file and profile == "other" :
144+ assert _config .server .url == f"{ _alt_url } api"
145+ assert _config .server .token .get_secret_value () == _alt_token
146+ assert f"{ _config .offline .cache } " == temp_d
124147 elif use_file and use_file != "pyproject.toml" :
125148 assert _config .server .url == f"{ _url } api"
126149 assert _config .server .token .get_secret_value () == _token
0 commit comments