@@ -19,17 +19,20 @@ def test_init_via_invalid_token(self):
1919 with self .assertRaisesRegexp (AppException , r"(\s+)token(\s+)Invalid token." ):
2020 SAClient (token = _token )
2121
22+ @patch ("lib.infrastructure.controller.Controller.get_current_user" )
2223 @patch ("lib.core.usecases.GetTeamUseCase" )
23- def test_init_via_token (self , get_team_use_case ):
24+ def test_init_via_token (self , get_team_use_case , get_current_user ):
2425 sa = SAClient (token = self ._token )
2526 assert get_team_use_case .call_args_list [0 ].kwargs ["team_id" ] == int (
2627 self ._token .split ("=" )[- 1 ]
2728 )
29+ assert get_current_user .call_count == 1
2830 assert sa .controller ._config .API_TOKEN == self ._token
2931 assert sa .controller ._config .API_URL == constants .BACKEND_URL
3032
33+ @patch ("lib.infrastructure.controller.Controller.get_current_user" )
3134 @patch ("lib.core.usecases.GetTeamUseCase" )
32- def test_init_via_config_json (self , get_team_use_case ):
35+ def test_init_via_config_json (self , get_team_use_case , get_current_user ):
3336 with tempfile .TemporaryDirectory () as config_dir :
3437 config_ini_path = f"{ config_dir } /config.ini"
3538 config_json_path = f"{ config_dir } /config.json"
@@ -40,11 +43,13 @@ def test_init_via_config_json(self, get_team_use_case):
4043 json .dump ({"token" : self ._token }, config_json )
4144 for kwargs in ({}, {"config_path" : f"{ config_dir } /config.json" }):
4245 sa = SAClient (** kwargs )
46+
4347 assert sa .controller ._config .API_TOKEN == self ._token
4448 assert sa .controller ._config .API_URL == constants .BACKEND_URL
4549 assert get_team_use_case .call_args_list [0 ].kwargs ["team_id" ] == int (
4650 self ._token .split ("=" )[- 1 ]
4751 )
52+ assert get_current_user .call_count == 2
4853
4954 def test_init_via_config_json_invalid_json (self ):
5055 with tempfile .TemporaryDirectory () as config_dir :
@@ -61,8 +66,9 @@ def test_init_via_config_json_invalid_json(self):
6166 ):
6267 SAClient (** kwargs )
6368
69+ @patch ("lib.infrastructure.controller.Controller.get_current_user" )
6470 @patch ("lib.core.usecases.GetTeamUseCase" )
65- def test_init_via_config_ini (self , get_team_use_case ):
71+ def test_init_via_config_ini (self , get_team_use_case , get_current_user ):
6672 with tempfile .TemporaryDirectory () as config_dir :
6773 config_ini_path = f"{ config_dir } /config.ini"
6874 config_json_path = f"{ config_dir } /config.json"
@@ -85,9 +91,11 @@ def test_init_via_config_ini(self, get_team_use_case):
8591 assert get_team_use_case .call_args_list [0 ].kwargs ["team_id" ] == int (
8692 self ._token .split ("=" )[- 1 ]
8793 )
94+ assert get_current_user .call_count == 2
8895
96+ @patch ("lib.infrastructure.controller.Controller.get_current_user" )
8997 @patch ("lib.core.usecases.GetTeamUseCase" )
90- def test_init_via_config_relative_filepath (self , get_team_use_case ):
98+ def test_init_via_config_relative_filepath (self , get_team_use_case , get_current_user ):
9199 with tempfile .TemporaryDirectory (dir = Path ("~" ).expanduser ()) as config_dir :
92100 config_ini_path = f"{ config_dir } /config.ini"
93101 config_json_path = f"{ config_dir } /config.json"
@@ -113,14 +121,17 @@ def test_init_via_config_relative_filepath(self, get_team_use_case):
113121 assert get_team_use_case .call_args_list [0 ].kwargs ["team_id" ] == int (
114122 self ._token .split ("=" )[- 1 ]
115123 )
124+ assert get_current_user .call_count == 2
116125
117- @patch ("lib.core.usecases.GetTeamUseCase" )
126+ @patch ("lib.infrastructure.controller.Controller.get_current_user" )
127+ @patch ("lib.infrastructure.controller.Controller.get_team" )
118128 @patch .dict (os .environ , {"SA_URL" : "SOME_URL" , "SA_TOKEN" : "SOME_TOKEN=123" })
119- def test_init_env (self , get_team_use_case ):
129+ def test_init_env (self , get_team , get_current_user ):
120130 sa = SAClient ()
121131 assert sa .controller ._config .API_TOKEN == "SOME_TOKEN=123"
122132 assert sa .controller ._config .API_URL == "SOME_URL"
123- assert get_team_use_case .call_args_list [0 ].kwargs ["team_id" ] == 123
133+ assert get_team .call_count == 1
134+ assert get_current_user .call_count == 1
124135
125136 @patch .dict (os .environ , {"SA_URL" : "SOME_URL" , "SA_TOKEN" : "SOME_TOKEN" })
126137 def test_init_env_invalid_token (self ):
0 commit comments