diff --git a/src/superannotate/lib/app/interface/sdk_interface.py b/src/superannotate/lib/app/interface/sdk_interface.py index ad4b4324e..364ac128e 100644 --- a/src/superannotate/lib/app/interface/sdk_interface.py +++ b/src/superannotate/lib/app/interface/sdk_interface.py @@ -2087,7 +2087,7 @@ def delete_annotations( :param project: project name or folder path (e.g., "project1/folder1") :type project: str - :param item_names: image names. If None, all image annotations from a given project/folder will be deleted. + :param item_names: item names. If None, all the items in the specified directory will be deleted. :type item_names: list of strs """ @@ -2192,7 +2192,7 @@ def get_annotations( :param project: project name or folder path (e.g., “project1/folder1”). :type project: str - :param items: item names. If None all items in specified directory + :param items: item names. If None, all the items in the specified directory will be used. :type items: list of strs :return: list of annotations @@ -2232,7 +2232,7 @@ def get_annotations_per_frame( return response.data def upload_priority_scores(self, project: NotEmptyStr, scores: List[PriorityScore]): - """Returns per frame annotations for the given video. + """Upload priority scores for the given list of items. :param project: project name or folder path (e.g., “project1/folder1”) :type project: str @@ -2673,7 +2673,7 @@ def set_annotation_statuses( ♦ “Skipped” \n :type annotation_status: str - :param items: item names to set the mentioned status for. If None, all the items in the project will be used. + :param items: item names. If None, all the items in the specified directory will be used. :type items: list of strs """ diff --git a/src/superannotate/lib/infrastructure/controller.py b/src/superannotate/lib/infrastructure/controller.py index 7b3cb3574..881df1234 100644 --- a/src/superannotate/lib/infrastructure/controller.py +++ b/src/superannotate/lib/infrastructure/controller.py @@ -795,8 +795,8 @@ def __init__(self, config: ConfigEntity): ) self.service_provider = ServiceProvider(http_client) - self._team = self.get_team().data self._user = self.get_current_user() + self._team = self.get_team().data self.annotation_classes = AnnotationClassManager(self.service_provider) self.projects = ProjectManager(self.service_provider) self.folders = FolderManager(self.service_provider) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index e69de29bb..e6b6f186e 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -0,0 +1 @@ +from superannotate.lib.infrastructure.validators import validators \ No newline at end of file diff --git a/tests/unit/test_init.py b/tests/unit/test_init.py index d882ba293..5e51081b6 100644 --- a/tests/unit/test_init.py +++ b/tests/unit/test_init.py @@ -19,17 +19,20 @@ def test_init_via_invalid_token(self): with self.assertRaisesRegexp(AppException, r"(\s+)token(\s+)Invalid token."): SAClient(token=_token) + @patch("lib.infrastructure.controller.Controller.get_current_user") @patch("lib.core.usecases.GetTeamUseCase") - def test_init_via_token(self, get_team_use_case): + def test_init_via_token(self, get_team_use_case, get_current_user): sa = SAClient(token=self._token) assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int( self._token.split("=")[-1] ) + assert get_current_user.call_count == 1 assert sa.controller._config.API_TOKEN == self._token assert sa.controller._config.API_URL == constants.BACKEND_URL + @patch("lib.infrastructure.controller.Controller.get_current_user") @patch("lib.core.usecases.GetTeamUseCase") - def test_init_via_config_json(self, get_team_use_case): + def test_init_via_config_json(self, get_team_use_case, get_current_user): with tempfile.TemporaryDirectory() as config_dir: config_ini_path = f"{config_dir}/config.ini" config_json_path = f"{config_dir}/config.json" @@ -40,11 +43,13 @@ def test_init_via_config_json(self, get_team_use_case): json.dump({"token": self._token}, config_json) for kwargs in ({}, {"config_path": f"{config_dir}/config.json"}): sa = SAClient(**kwargs) + assert sa.controller._config.API_TOKEN == self._token assert sa.controller._config.API_URL == constants.BACKEND_URL assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int( self._token.split("=")[-1] ) + assert get_current_user.call_count == 2 def test_init_via_config_json_invalid_json(self): with tempfile.TemporaryDirectory() as config_dir: @@ -61,8 +66,9 @@ def test_init_via_config_json_invalid_json(self): ): SAClient(**kwargs) + @patch("lib.infrastructure.controller.Controller.get_current_user") @patch("lib.core.usecases.GetTeamUseCase") - def test_init_via_config_ini(self, get_team_use_case): + def test_init_via_config_ini(self, get_team_use_case, get_current_user): with tempfile.TemporaryDirectory() as config_dir: config_ini_path = f"{config_dir}/config.ini" config_json_path = f"{config_dir}/config.json" @@ -85,9 +91,11 @@ def test_init_via_config_ini(self, get_team_use_case): assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int( self._token.split("=")[-1] ) + assert get_current_user.call_count == 2 + @patch("lib.infrastructure.controller.Controller.get_current_user") @patch("lib.core.usecases.GetTeamUseCase") - def test_init_via_config_relative_filepath(self, get_team_use_case): + def test_init_via_config_relative_filepath(self, get_team_use_case, get_current_user): with tempfile.TemporaryDirectory(dir=Path("~").expanduser()) as config_dir: config_ini_path = f"{config_dir}/config.ini" config_json_path = f"{config_dir}/config.json" @@ -113,14 +121,17 @@ def test_init_via_config_relative_filepath(self, get_team_use_case): assert get_team_use_case.call_args_list[0].kwargs["team_id"] == int( self._token.split("=")[-1] ) + assert get_current_user.call_count == 2 - @patch("lib.core.usecases.GetTeamUseCase") + @patch("lib.infrastructure.controller.Controller.get_current_user") + @patch("lib.infrastructure.controller.Controller.get_team") @patch.dict(os.environ, {"SA_URL": "SOME_URL", "SA_TOKEN": "SOME_TOKEN=123"}) - def test_init_env(self, get_team_use_case): + def test_init_env(self, get_team, get_current_user): sa = SAClient() assert sa.controller._config.API_TOKEN == "SOME_TOKEN=123" assert sa.controller._config.API_URL == "SOME_URL" - assert get_team_use_case.call_args_list[0].kwargs["team_id"] == 123 + assert get_team.call_count == 1 + assert get_current_user.call_count == 1 @patch.dict(os.environ, {"SA_URL": "SOME_URL", "SA_TOKEN": "SOME_TOKEN"}) def test_init_env_invalid_token(self):