@@ -588,6 +588,66 @@ def test_can_list_jobs_200_with_filters(client: TestClient, session: Session):
588588 )
589589
590590
591+ def test_can_list_jobs_200_can_show_only_active_jobs_with_free_assignments (
592+ client : TestClient , session : Session
593+ ):
594+ session .begin ()
595+
596+ user = User (
597+ wallet_address = WALLET_ADDRESS1 ,
598+ cvat_email = cvat_email ,
599+ cvat_id = 1 ,
600+ )
601+ session .add (user )
602+
603+ cvat_project1 , _ , _ = create_project_task_and_job (
604+ session , "0x86e83d346041E8806e352681f3F14549C0d2001" , 1
605+ )
606+ cvat_project1 .status = ProjectStatuses .annotation
607+ session .add (cvat_project1 )
608+
609+ cvat_project2 , _ , cvat_job2 = create_project_task_and_job (
610+ session , "0x86e83d346041E8806e352681f3F14549C0d2002" , 2
611+ )
612+ cvat_project2 .status = ProjectStatuses .annotation
613+ cvat_job2 .status = JobStatuses .in_progress
614+ session .add (cvat_project2 )
615+ session .add (cvat_job2 )
616+
617+ assignment = Assignment (
618+ id = str (uuid .uuid4 ()),
619+ user_wallet_address = user .wallet_address ,
620+ cvat_job_id = cvat_job2 .cvat_id ,
621+ status = AssignmentStatuses .created ,
622+ created_at = utcnow () - timedelta (hours = 1 ),
623+ expires_at = utcnow () + timedelta (hours = 1 ),
624+ )
625+ session .add (assignment )
626+
627+ session .commit ()
628+
629+ with (
630+ open ("tests/utils/manifest.json" ) as data ,
631+ patch ("src.endpoints.serializers.get_escrow_manifest" ) as mock_get_manifest ,
632+ patch (
633+ "src.endpoints.serializers.get_escrow_fund_token_symbol"
634+ ) as mock_get_escrow_fund_token_symbol ,
635+ ):
636+ manifest = json .load (data )
637+ mock_get_manifest .return_value = manifest
638+ mock_get_escrow_fund_token_symbol .return_value = "HMT"
639+
640+ response = client .get (
641+ "/job" ,
642+ headers = get_auth_header (token = generate_jwt_token ()),
643+ params = {"status" : APIJobStatuses .active .value },
644+ )
645+
646+ assert response .status_code == 200
647+ paginated_result = response .json ()
648+ assert paginated_result ["total_results" ] == 1
649+
650+
591651def test_can_list_jobs_200_check_values (client : TestClient , session : Session ) -> None :
592652 session .begin ()
593653 user = User (
0 commit comments