@@ -11,9 +11,9 @@ import { MUTEX_TIMEOUT } from '../../common/constants';
1111import { MutexManagerService } from '../mutex/mutex-manager.service' ;
1212import { RequestWithUser } from '../../common/types' ;
1313import { JwtAuthGuard } from '../../common/guards' ;
14- import { JobCvatDto , JobFortuneDto , JobQuickLaunchDto } from './job.dto' ;
14+ import { JobFortuneDto , JobQuickLaunchDto } from './job.dto' ;
1515import {
16- CvatJobType ,
16+ // CvatJobType,
1717 EscrowFundToken ,
1818 FortuneJobType ,
1919 JobRequestType ,
@@ -24,7 +24,7 @@ import {
2424 MOCK_REQUESTER_DESCRIPTION ,
2525 MOCK_REQUESTER_TITLE ,
2626} from '../../../test/constants' ;
27- import { AWSRegions , StorageProviders } from '../../common/enums/storage' ;
27+ // import { AWSRegions, StorageProviders } from '../../common/enums/storage';
2828import { Web3ConfigService } from '../../common/config/web3-config.service' ;
2929import { ConfigService } from '@nestjs/config' ;
3030import { PaymentCurrency } from '../../common/enums/payment' ;
@@ -269,107 +269,108 @@ describe('JobController', () => {
269269 } ) ;
270270 } ) ;
271271
272- describe ( 'createCvatJob' , ( ) => {
273- const jobCvatDto : JobCvatDto = {
274- requesterDescription : 'Sample description' ,
275- data : {
276- dataset : {
277- provider : 'AWS' as StorageProviders ,
278- region : 'us-east-1' as AWSRegions ,
279- bucketName : 'sample-bucket' ,
280- path : 'path/to/dataset' ,
281- } ,
282- } ,
283- labels : [
284- {
285- name : 'Label 1' ,
286- nodes : [ 'node1' , 'node2' ] ,
287- } ,
288- ] ,
289- minQuality : 90 ,
290- groundTruth : {
291- provider : 'AWS' as StorageProviders ,
292- region : 'us-west-1' as AWSRegions ,
293- bucketName : 'ground-truth-bucket' ,
294- path : 'path/to/groundtruth' ,
295- } ,
296- userGuide : 'https://example.com/user-guide' ,
297- type : CvatJobType . IMAGE_BOXES ,
298- paymentCurrency : PaymentCurrency . USDC ,
299- paymentAmount : 500 ,
300- escrowFundToken : EscrowFundToken . USDC ,
301- } ;
302-
303- it ( 'should create a CVAT job successfully' , async ( ) => {
304- mockJobService . createJob . mockResolvedValue ( 1 ) ;
305- mockMutexManagerService . runExclusive . mockImplementation (
306- async ( _lock , _timeout , fn ) => await fn ( ) ,
307- ) ;
308-
309- const result = await jobController . createCvatJob ( jobCvatDto , mockRequest ) ;
310-
311- expect ( result ) . toBe ( 1 ) ;
312- expect ( mockMutexManagerService . runExclusive ) . toHaveBeenCalledWith (
313- `user${ mockRequest . user . id } ` ,
314- expect . any ( Number ) ,
315- expect . any ( Function ) ,
316- ) ;
317- expect ( mockJobService . createJob ) . toHaveBeenCalledWith (
318- mockRequest . user ,
319- CvatJobType . IMAGE_BOXES ,
320- jobCvatDto ,
321- ) ;
322- } ) ;
323-
324- it ( 'should throw UnauthorizedException if user is not authorized' , async ( ) => {
325- mockMutexManagerService . runExclusive . mockRejectedValueOnce (
326- new UnauthorizedException ( ) ,
327- ) ;
328-
329- await expect (
330- jobController . createCvatJob ( jobCvatDto , mockRequest ) ,
331- ) . rejects . toThrow ( UnauthorizedException ) ;
332-
333- expect ( mockMutexManagerService . runExclusive ) . toHaveBeenCalledWith (
334- `user${ mockRequest . user . id } ` ,
335- expect . any ( Number ) ,
336- expect . any ( Function ) ,
337- ) ;
338- expect ( mockJobService . createJob ) . not . toHaveBeenCalled ( ) ;
339- } ) ;
340-
341- it ( 'should throw ConflictException if there is a conflict' , async ( ) => {
342- mockMutexManagerService . runExclusive . mockRejectedValueOnce (
343- new ConflictException ( ) ,
344- ) ;
345-
346- await expect (
347- jobController . createCvatJob ( jobCvatDto , mockRequest ) ,
348- ) . rejects . toThrow ( ConflictException ) ;
349-
350- expect ( mockMutexManagerService . runExclusive ) . toHaveBeenCalledWith (
351- `user${ mockRequest . user . id } ` ,
352- expect . any ( Number ) ,
353- expect . any ( Function ) ,
354- ) ;
355- expect ( mockJobService . createJob ) . not . toHaveBeenCalled ( ) ;
356- } ) ;
357-
358- it ( 'should throw BadRequestException for invalid input' , async ( ) => {
359- mockMutexManagerService . runExclusive . mockRejectedValueOnce (
360- new BadRequestException ( ) ,
361- ) ;
362-
363- await expect (
364- jobController . createCvatJob ( jobCvatDto , mockRequest ) ,
365- ) . rejects . toThrow ( BadRequestException ) ;
366-
367- expect ( mockMutexManagerService . runExclusive ) . toHaveBeenCalledWith (
368- `user${ mockRequest . user . id } ` ,
369- expect . any ( Number ) ,
370- expect . any ( Function ) ,
371- ) ;
372- expect ( mockJobService . createJob ) . not . toHaveBeenCalled ( ) ;
373- } ) ;
374- } ) ;
272+ //disabled CVAT jobs
273+ // describe('createCvatJob', () => {
274+ // const jobCvatDto: JobCvatDto = {
275+ // requesterDescription: 'Sample description',
276+ // data: {
277+ // dataset: {
278+ // provider: 'AWS' as StorageProviders,
279+ // region: 'us-east-1' as AWSRegions,
280+ // bucketName: 'sample-bucket',
281+ // path: 'path/to/dataset',
282+ // },
283+ // },
284+ // labels: [
285+ // {
286+ // name: 'Label 1',
287+ // nodes: ['node1', 'node2'],
288+ // },
289+ // ],
290+ // minQuality: 90,
291+ // groundTruth: {
292+ // provider: 'AWS' as StorageProviders,
293+ // region: 'us-west-1' as AWSRegions,
294+ // bucketName: 'ground-truth-bucket',
295+ // path: 'path/to/groundtruth',
296+ // },
297+ // userGuide: 'https://example.com/user-guide',
298+ // type: CvatJobType.IMAGE_BOXES,
299+ // paymentCurrency: PaymentCurrency.USDC,
300+ // paymentAmount: 500,
301+ // escrowFundToken: EscrowFundToken.USDC,
302+ // };
303+
304+ // it('should create a CVAT job successfully', async () => {
305+ // mockJobService.createJob.mockResolvedValue(1);
306+ // mockMutexManagerService.runExclusive.mockImplementation(
307+ // async (_lock, _timeout, fn) => await fn(),
308+ // );
309+
310+ // const result = await jobController.createCvatJob(jobCvatDto, mockRequest);
311+
312+ // expect(result).toBe(1);
313+ // expect(mockMutexManagerService.runExclusive).toHaveBeenCalledWith(
314+ // `user${mockRequest.user.id}`,
315+ // expect.any(Number),
316+ // expect.any(Function),
317+ // );
318+ // expect(mockJobService.createJob).toHaveBeenCalledWith(
319+ // mockRequest.user,
320+ // CvatJobType.IMAGE_BOXES,
321+ // jobCvatDto,
322+ // );
323+ // });
324+
325+ // it('should throw UnauthorizedException if user is not authorized', async () => {
326+ // mockMutexManagerService.runExclusive.mockRejectedValueOnce(
327+ // new UnauthorizedException(),
328+ // );
329+
330+ // await expect(
331+ // jobController.createCvatJob(jobCvatDto, mockRequest),
332+ // ).rejects.toThrow(UnauthorizedException);
333+
334+ // expect(mockMutexManagerService.runExclusive).toHaveBeenCalledWith(
335+ // `user${mockRequest.user.id}`,
336+ // expect.any(Number),
337+ // expect.any(Function),
338+ // );
339+ // expect(mockJobService.createJob).not.toHaveBeenCalled();
340+ // });
341+
342+ // it('should throw ConflictException if there is a conflict', async () => {
343+ // mockMutexManagerService.runExclusive.mockRejectedValueOnce(
344+ // new ConflictException(),
345+ // );
346+
347+ // await expect(
348+ // jobController.createCvatJob(jobCvatDto, mockRequest),
349+ // ).rejects.toThrow(ConflictException);
350+
351+ // expect(mockMutexManagerService.runExclusive).toHaveBeenCalledWith(
352+ // `user${mockRequest.user.id}`,
353+ // expect.any(Number),
354+ // expect.any(Function),
355+ // );
356+ // expect(mockJobService.createJob).not.toHaveBeenCalled();
357+ // });
358+
359+ // it('should throw BadRequestException for invalid input', async () => {
360+ // mockMutexManagerService.runExclusive.mockRejectedValueOnce(
361+ // new BadRequestException(),
362+ // );
363+
364+ // await expect(
365+ // jobController.createCvatJob(jobCvatDto, mockRequest),
366+ // ).rejects.toThrow(BadRequestException);
367+
368+ // expect(mockMutexManagerService.runExclusive).toHaveBeenCalledWith(
369+ // `user${mockRequest.user.id}`,
370+ // expect.any(Number),
371+ // expect.any(Function),
372+ // );
373+ // expect(mockJobService.createJob).not.toHaveBeenCalled();
374+ // });
375+ // });
375376} ) ;
0 commit comments