@@ -51,29 +51,39 @@ def test_check_conditions_and_set_auto_train_readiness_debounce(self, fxt_projec
5151 [True , False ],
5252 ids = ["enough annotations" , "not enough annotations" ],
5353 )
54+ @pytest .mark .parametrize (
55+ "project_fixture,auto_train_enabled" ,
56+ [
57+ ("fxt_project" , True ),
58+ ("fxt_project_with_anomaly_task" , False ),
59+ ],
60+ ids = ["Standard Project" , "Anomaly Project" ],
61+ )
5462 def test_check_conditions_and_set_auto_train_readiness (
5563 self ,
5664 request ,
5765 enough_annotations ,
5866 fxt_organization_id ,
59- fxt_project ,
6067 fxt_missing_annotations ,
6168 fxt_missing_annotations_zero_missing ,
69+ project_fixture ,
70+ auto_train_enabled ,
6271 ) -> None :
6372 """Checks that an auto-training request is submitted if and only if the conditions are met"""
64- dataset_storage = fxt_project .get_training_dataset_storage ()
65- task_node = fxt_project .get_trainable_task_nodes ()[0 ]
73+ project = request .getfixturevalue (project_fixture )
74+ dataset_storage = project .get_training_dataset_storage ()
75+ task_node = project .get_trainable_task_nodes ()[0 ]
6676
6777 request .addfinalizer (lambda : ProjectBasedAutoTrainActivationRepo (fxt_project .identifier ).delete_all ())
6878 ProjectConfigurationRepo (fxt_project .identifier ).create_default_configuration ([task_node .id_ ])
6979
7080 session = make_session (
7181 organization_id = fxt_organization_id ,
72- workspace_id = fxt_project .identifier .workspace_id ,
82+ workspace_id = project .identifier .workspace_id ,
7383 )
7484 with (
7585 session_context (session ),
76- patch .object (ProjectRepo , "get_by_id" , return_value = fxt_project ) as mock_get_project ,
86+ patch .object (ProjectRepo , "get_by_id" , return_value = project ) as mock_get_project ,
7787 patch .object (
7888 ProjectBasedAutoTrainActivationRepo ,
7989 "set_auto_train_readiness_by_task_id" ,
@@ -86,15 +96,22 @@ def test_check_conditions_and_set_auto_train_readiness(
8696 ) as mock_get_missing_annotations ,
8797 ):
8898 AutoTrainUseCase ._check_conditions_and_set_auto_train_readiness (
89- session = session , project_identifier = fxt_project .identifier
99+ session = session , project_identifier = project .identifier
90100 )
91101
92- mock_get_project .assert_called_once_with (fxt_project .id_ )
102+ mock_get_project .assert_called_once_with (project .id_ )
93103 mock_get_missing_annotations .assert_called_once_with (
94104 dataset_storage_identifier = dataset_storage .identifier ,
95105 task_node = task_node ,
96106 )
97- if enough_annotations :
107+ if not auto_train_enabled :
108+ mock_set_readiness .assert_called_once_with (
109+ task_node_id = task_node .id_ ,
110+ readiness = False ,
111+ bypass_debouncer = True ,
112+ raise_exc_on_missing = False ,
113+ )
114+ elif enough_annotations :
98115 mock_set_readiness .assert_called_once_with (
99116 task_node_id = task_node .id_ ,
100117 readiness = True ,
0 commit comments