66
77from collector_db .AsyncDatabaseClient import AsyncDatabaseClient
88from collector_db .DTOs .BatchInfo import BatchInfo
9+ from collector_db .DTOs .InsertURLsInfo import InsertURLsInfo
910from collector_db .DTOs .LogInfo import LogInfo
1011from collector_db .DTOs .URLErrorInfos import URLErrorPydanticInfo
1112from collector_db .DTOs .URLInfo import URLInfo
1213from collector_db .DTOs .URLMetadataInfo import URLMetadataInfo
1314from collector_db .enums import URLMetadataAttributeType , ValidationStatus , ValidationSource
14- from collector_db .models import URL , ApprovingUserURL , URLOptionalDataSourceMetadata , ConfirmedURLAgency
15+ from collector_db .models import URL , ApprovingUserURL , URLOptionalDataSourceMetadata , ConfirmedURLAgency , \
16+ UserRelevantSuggestion
1517from collector_manager .enums import URLStatus
1618from core .DTOs .FinalReviewApprovalInfo import FinalReviewApprovalInfo
1719from core .enums import BatchStatus , RecordType , SuggestionType
@@ -421,3 +423,67 @@ async def test_approval_url_error(db_data_creator: DBDataCreator):
421423 user_id = 1
422424 )
423425
426+ @pytest .mark .asyncio
427+ async def test_get_next_url_for_user_relevance_annotation_pending (
428+ db_data_creator : DBDataCreator
429+ ):
430+
431+ batch_id = db_data_creator .batch ()
432+
433+ # Create 2 URLs with outcome `pending`
434+ iui : InsertURLsInfo = db_data_creator .urls (
435+ batch_id = batch_id ,
436+ url_count = 1 ,
437+ outcome = URLStatus .PENDING
438+ )
439+
440+ url_1 = iui .url_mappings [0 ]
441+
442+ # Add `Relevancy` attribute with value `True`
443+ await db_data_creator .auto_relevant_suggestions (
444+ url_id = url_1 .url_id ,
445+ relevant = True
446+ )
447+
448+ # Add HTML data
449+ await db_data_creator .html_data ([url_1 .url_id ])
450+
451+ adb_client = db_data_creator .adb_client
452+ url = await adb_client .get_next_url_for_relevance_annotation (
453+ user_id = 1
454+ )
455+ assert url is not None
456+
457+ @pytest .mark .asyncio
458+ async def test_get_next_url_for_user_relevance_annotation_validated (
459+ db_data_creator : DBDataCreator
460+ ):
461+ """
462+ A validated URL should not turn up in get_next_url_for_user_annotation
463+ """
464+
465+ batch_id = db_data_creator .batch ()
466+
467+ # Create 2 URLs with outcome `pending`
468+ iui : InsertURLsInfo = db_data_creator .urls (
469+ batch_id = batch_id ,
470+ url_count = 1 ,
471+ outcome = URLStatus .VALIDATED
472+ )
473+
474+ url_1 = iui .url_mappings [0 ]
475+
476+ # Add `Relevancy` attribute with value `True`
477+ await db_data_creator .auto_relevant_suggestions (
478+ url_id = url_1 .url_id ,
479+ relevant = True
480+ )
481+
482+ # Add HTML data
483+ await db_data_creator .html_data ([url_1 .url_id ])
484+
485+ adb_client = db_data_creator .adb_client
486+ url = await adb_client .get_next_url_for_relevance_annotation (
487+ user_id = 1
488+ )
489+ assert url is None
0 commit comments