-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add REST API tests for /requests API && test both versions of the export API #8216
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe recent changes enhance the CVAT codebase by refining job handling, updating request filtering, and improving dataset export functionality. Key updates include introducing optional typing for job parameters, consolidating status checks, and implementing new exception handling for better error management. The testing suite has also been revamped to support API versioning and ensure robust coverage for various scenarios, making the code more maintainable and adaptable. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant JobManager
participant Database
User->>API: Request dataset export
API->>JobManager: Start export job
JobManager->>Database: Save job state
Database-->>JobManager: Job state confirmed
JobManager->>API: Return job ID
API-->>User: Provide job ID
User->>API: Check job status
API->>JobManager: Get job status
JobManager->>Database: Retrieve job state
Database-->>JobManager: Return job state
JobManager->>API: Send job status
API-->>User: Provide job status
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- cvat/apps/engine/background.py (16 hunks)
- cvat/apps/engine/filters.py (4 hunks)
- cvat/apps/engine/mixins.py (1 hunks)
- cvat/apps/engine/views.py (4 hunks)
- cvat/schema.yml (2 hunks)
- tests/python/rest_api/test_jobs.py (7 hunks)
- tests/python/rest_api/test_projects.py (16 hunks)
- tests/python/rest_api/test_requests.py (1 hunks)
- tests/python/rest_api/test_tasks.py (7 hunks)
- tests/python/rest_api/utils.py (2 hunks)
Files skipped from review due to trivial changes (1)
- cvat/apps/engine/mixins.py
Additional comments not posted (85)
tests/python/rest_api/test_requests.py (17)
27-28
: LGTM!The
validate_action
function is correct and concise.
31-32
: LGTM!The
validate_subresource
function is correct and concise.
35-36
: LGTM!The
validate_status
function is correct and concise.
39-40
: LGTM!The
validate_id
function is correct and concise.
43-44
: LGTM!The
validate_resource
function is correct and concise.
47-48
: LGTM!The
validate_format
function is correct and concise.
55-60
: LGTM!The
setup
method is correct and concise.
62-67
: LGTM!The
create_resources
method is correct and concise.
69-164
: LGTM!The
make_requests
method is correct and comprehensive.
166-180
: LGTM!The
create_tasks
method is correct and concise.
182-193
: LGTM!The
create_projects
method is correct and concise.
195-200
: LGTM!The
get_job_ids
method is correct and concise.
215-229
: LGTM!The
test_list_request_with_simple_filter
method is correct and comprehensive.
236-241
: LGTM!The
_test_get_request_200
method is correct and concise.
243-247
: LGTM!The
_test_get_request_403
method is correct and concise.
251-290
: LGTM!The
test_owner_can_retrieve_request
method is correct and comprehensive.
293-314
: LGTM!The
test_non_owner_cannot_retrieve_request
method is correct and comprehensive.tests/python/rest_api/utils.py (13)
Line range hint
25-82
: LGTM!The
export_v1
function is correct and comprehensive.
85-155
: LGTM!The
export_v2
function is correct and comprehensive.
158-186
: LGTM!The
export_dataset
function is correct and comprehensive.
190-192
: LGTM!The
export_project_dataset
function is correct and concise.
195-197
: LGTM!The
export_task_dataset
function is correct and concise.
200-202
: LGTM!The
export_job_dataset
function is correct and concise.
205-220
: LGTM!The
export_backup
function is correct and comprehensive.
223-225
: LGTM!The
export_project_backup
function is correct and concise.
228-230
: LGTM!The
export_task_backup
function is correct and concise.
233-277
: LGTM!The
import_resource
function is correct and comprehensive.
279-287
: LGTM!The
import_backup
function is correct and concise.
290-292
: LGTM!The
import_project_backup
function is correct and concise.
295-297
: LGTM!The
import_task_backup
function is correct and concise.cvat/apps/engine/filters.py (2)
415-419
: LGTM!The
filter_queryset
method in classNonModelSimpleFilter
is correct and concise.
Line range hint
468-472
: LGTM!The
filter_queryset
method in classNonModelOrderingFilter
is correct and concise.cvat/apps/engine/background.py (5)
86-86
: Ensurerq_job
parameter is optional.The method
_handle_rq_job_v1
now accepts an optionalrq_job
parameter, which is a good change to handle cases where the job may not exist.
89-89
: Ensurerq_job
parameter is optional.The method
_handle_rq_job_v2
now accepts an optionalrq_job
parameter, which is a good change to handle cases where the job may not exist.
90-105
: Ensure proper handling of job statuses.The method
_handle_rq_job_v2
includes logic for handling different job statuses and actions. Ensure that all possible job statuses are handled correctly.
148-155
: Ensure proper handling of job cancellation and re-enqueueing.The method
cancel_and_reenqueue
encapsulates the logic for canceling a job and re-adding it to the queue. Ensure that this method is invoked correctly in all required places.
175-175
: EnsureRequest
object is used correctly.The method
__init__
inDatasetExportManager
now accepts aRequest
object instead ofHttpRequest
, which aligns with the rest framework's request handling.tests/python/rest_api/test_projects.py (27)
189-189
: Class renamed toTestGetPostProjectBackup
.The class
TestGetProjectBackup
has been renamed toTestGetPostProjectBackup
to reflect the inclusion of both GET and POST operations for project backups.
198-214
: Ensureapi_version
parameter is used correctly in_test_can_get_project_backup
.The method
_test_can_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
215-224
: Ensureapi_version
parameter is used correctly in_test_cannot_get_project_backup
.The method
_test_cannot_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
225-228
: Ensureapi_version
parameter is used correctly intest_admin_can_get_project_backup
.The method
test_admin_can_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
231-243
: Ensureapi_version
parameter is used correctly intest_user_cannot_get_project_backup
.The method
test_user_cannot_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
246-262
: Ensureapi_version
parameter is used correctly intest_org_worker_cannot_get_project_backup
.The method
test_org_worker_cannot_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
265-283
: Ensureapi_version
parameter is used correctly intest_org_worker_can_get_project_backup
.The method
test_org_worker_can_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
286-300
: Ensureapi_version
parameter is used correctly intest_org_supervisor_can_get_project_backup
.The method
test_org_supervisor_can_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
303-323
: Ensureapi_version
parameter is used correctly intest_org_supervisor_cannot_get_project_backup
.The method
test_org_supervisor_cannot_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
326-344
: Ensureapi_version
parameter is used correctly intest_org_maintainer_can_get_project_backup
.The method
test_org_maintainer_can_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
347-361
: Ensureapi_version
parameter is used correctly intest_org_owner_can_get_project_backup
.The method
test_org_owner_can_get_project_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
363-373
: Ensureapi_version
parameter is used correctly intest_can_get_backup_project_when_some_tasks_have_no_data
.The method
test_can_get_backup_project_when_some_tasks_have_no_data
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
Line range hint
375-390
:
Ensureapi_version
parameter is used correctly intest_can_get_backup_project_when_all_tasks_have_no_data
.The method
test_can_get_backup_project_when_all_tasks_have_no_data
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
392-396
: Ensureapi_version
parameter is used correctly intest_can_get_backup_for_empty_project
.The method
test_can_get_backup_for_empty_project
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
397-416
: Ensureapi_version
parameter is used correctly intest_admin_can_get_project_backup_and_create_project_by_backup
.The method
test_admin_can_get_project_backup_and_create_project_by_backup
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
617-629
: Ensureapi_version
parameter is used correctly in_test_export_dataset
.The method
_test_export_dataset
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
630-640
: Ensureapi_version
parameter is used correctly in_test_export_annotations
.The method
_test_export_annotations
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
676-686
: Ensureapi_version
parameter is used correctly intest_can_import_dataset_in_org
.The method
test_can_import_dataset_in_org
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
Line range hint
706-729
:
Ensureapi_version
parameter is used correctly intest_can_export_and_import_dataset_with_skeletons
.The method
test_can_export_and_import_dataset_with_skeletons
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
739-754
: Ensureapi_version
parameter is used correctly intest_can_import_export_dataset_with_some_format
.The method
test_can_import_export_dataset_with_some_format
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
Line range hint
765-810
:
Ensureapi_version
parameter is used correctly intest_exported_project_dataset_structure
.The method
test_exported_project_dataset_structure
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
Line range hint
817-836
:
Ensureapi_version
parameter is used correctly intest_can_import_export_annotations_with_rotation
.The method
test_can_import_export_annotations_with_rotation
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
849-862
: Ensureapi_version
parameter is used correctly intest_can_export_dataset_with_skeleton_labels_with_spaces
.The method
test_can_export_dataset_with_skeleton_labels_with_spaces
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
864-873
: Ensureapi_version
parameter is used correctly intest_can_export_dataset_for_empty_project
.The method
test_can_export_dataset_for_empty_project
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
875-891
: Ensureapi_version
parameter is used correctly intest_can_export_project_dataset_when_some_tasks_have_no_data
.The method
test_can_export_project_dataset_when_some_tasks_have_no_data
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
Line range hint
893-914
:
Ensureapi_version
parameter is used correctly intest_can_export_project_dataset_when_all_tasks_have_no_data
.The method
test_can_export_project_dataset_when_all_tasks_have_no_data
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.
Line range hint
916-942
:
Ensureapi_version
parameter is used correctly intest_can_export_and_import_dataset_after_deleting_related_storage
.The method
test_can_export_and_import_dataset_after_deleting_related_storage
has been updated to includeapi_version
as a parameter, which allows for testing different API versions.tests/python/rest_api/test_jobs.py (9)
1331-1333
: LGTM!The
setup
function correctly initializes thetasks
attribute.
1335-1338
: LGTM!The
is_local_download
function correctly determines if a job is a local download based on thetarget_storage
attribute.
1340-1350
: LGTM!The
_test_export_dataset
function correctly tests the export of a job dataset and performs appropriate assertions.
1352-1362
: LGTM!The
_test_export_annotations
function correctly tests the export of job annotations and performs appropriate assertions.
1364-1369
: LGTM!The
test_can_export_dataset
function correctly tests the export of a dataset for an admin user with appropriate parameters.
1371-1384
: LGTM!The
test_non_admin_can_export_dataset
function correctly tests the export of a dataset for non-admin users with appropriate parameters.
1386-1400
: LGTM!The
test_non_admin_can_export_annotations
function correctly tests the export of annotations for non-admin users with appropriate parameters.
Line range hint
1402-1450
:
LGTM!The
test_exported_job_dataset_structure
function correctly tests the structure of the exported job dataset with comprehensive checks.
Line range hint
1451-1499
:
LGTM!The
test_export_job_among_several_jobs_in_task
function correctly tests the export of a job dataset among several jobs in a task with comprehensive checks.tests/python/rest_api/test_tasks.py (7)
659-669
: LGTM!The
_test_can_export_dataset
method is well-structured and handles dataset export validation correctly.
671-679
: LGTM!The
test_can_export_task_dataset
method is updated correctly to use_test_can_export_dataset
and include theapi_version
parameter.
681-696
: LGTM!The
test_can_export_task_with_several_jobs
method is updated correctly to use_test_can_export_dataset
and include theapi_version
parameter.
Line range hint
698-794
:
LGTM!The
test_can_export_task_to_coco_format
method is updated correctly to use_test_can_export_dataset
and include theapi_version
parameter.
Line range hint
805-826
:
LGTM!The
test_can_download_task_with_special_chars_in_name
method is updated correctly to include theapi_version
parameter and use_test_can_export_dataset
.
Line range hint
828-848
:
LGTM!The
test_export_dataset_after_deleting_related_cloud_storage
method is updated correctly to include theapi_version
parameter and use_test_can_export_dataset
.
2278-2287
: LGTM!The
test_can_export_backup_with_both_api_versions
method is well-structured and tests the backup export functionality correctly across different API versions.cvat/apps/engine/views.py (3)
83-83
: LGTM! Theresource
field is correctly added to thefields
list.This ensures that the
resource
field is included in the serialized output.
3277-3277
: LGTM! Theresource
field is correctly mapped inlookup_fields
.This ensures that the
resource
field can be queried based on the incoming request parameters.
3295-3295
: LGTM! Theresource
field is correctly added to the schema definition.This ensures that the
resource
field is validated against specific predefined values.cvat/schema.yml (2)
4580-4587
: Addition of 'resource' filter field is approved.The new 'resource' filter field with enumerated values ('project', 'task', 'job') enhances the API's filtering capabilities.
4544-4544
: Update to the filter fields list is approved.The inclusion of the 'resource' field in the filter fields list ensures consistency and informs users of the new filtering option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (11)
- cvat/apps/engine/background.py (16 hunks)
- cvat/apps/engine/filters.py (4 hunks)
- cvat/apps/engine/mixins.py (1 hunks)
- cvat/apps/engine/views.py (4 hunks)
- cvat/schema.yml (2 hunks)
- tests/python/rest_api/test_jobs.py (7 hunks)
- tests/python/rest_api/test_projects.py (17 hunks)
- tests/python/rest_api/test_requests.py (1 hunks)
- tests/python/rest_api/test_tasks.py (9 hunks)
- tests/python/rest_api/utils.py (2 hunks)
- tests/python/shared/fixtures/data.py (2 hunks)
Files skipped from review as they are similar to previous changes (5)
- cvat/apps/engine/filters.py
- cvat/apps/engine/mixins.py
- cvat/apps/engine/views.py
- cvat/schema.yml
- tests/python/rest_api/test_requests.py
Additional comments not posted (80)
tests/python/shared/fixtures/data.py (2)
93-98
: LGTM!The fixture correctly wraps the
filter_assets
function for filtering project resources.
101-106
: LGTM!The fixture correctly wraps the
filter_assets
function for filtering task resources.tests/python/rest_api/utils.py (10)
Line range hint
25-83
:
LGTM!The function is well-structured and includes parameters for handling forbidden requests and waiting for results. The logic for checking the response status and handling different scenarios is implemented correctly.
85-156
: LGTM!The function is well-structured and includes parameters for handling forbidden requests and waiting for results. The logic for retrieving the background request ID and checking the status is implemented correctly.
158-187
: LGTM!The function correctly handles both versions of the export API based on the
api_version
parameter. The logic for selecting the appropriate endpoint and calling the corresponding export function is implemented correctly.
189-193
: LGTM!The function correctly wraps the
export_dataset
function for exporting project datasets.
195-198
: LGTM!The function correctly wraps the
export_dataset
function for exporting task datasets.
200-203
: LGTM!The function correctly wraps the
export_dataset
function for exporting job datasets.
205-221
: LGTM!The function correctly handles both versions of the export API based on the
api_version
parameter. The logic for selecting the appropriate endpoint and calling the corresponding export function is implemented correctly.
223-226
: LGTM!The function correctly wraps the
export_backup
function for exporting project backups.
228-231
: LGTM!The function correctly wraps the
export_backup
function for exporting task backups.
233-277
: LGTM!The function is well-structured and includes parameters for handling forbidden requests and waiting for results. The logic for retrieving the background request ID and checking the status is implemented correctly.
cvat/apps/engine/background.py (5)
85-85
: LGTM!The function correctly handles the case where
rq_job
isNone
. The logic for managing job statuses and handling different scenarios is implemented correctly.
88-104
: LGTM!The function correctly handles the case where
rq_job
isNone
. The logic for managing job statuses and handling different scenarios is implemented correctly.
147-155
: LGTM!The function encapsulates the logic for canceling a job and re-enqueueing it, making the code cleaner and easier to maintain.
Line range hint
174-185
:
LGTM!The method correctly initializes the class with the new
Request
object. The logic for handling query parameters and location configuration is implemented correctly.
Line range hint
505-591
:
LGTM!The method correctly handles the case where
rq_job
isNone
. The logic for managing job statuses and handling different scenarios is implemented correctly.tests/python/rest_api/test_projects.py (47)
198-214
: Method_test_can_get_project_backup
: Ensure correct handling of local and cloud storageThe method
_test_can_get_project_backup
checks if a project backup can be obtained. Ensure that the handling of local and cloud storage is correct.
215-224
: Method_test_cannot_get_project_backup
: Ensure ForbiddenException is correctly raisedThe method
_test_cannot_get_project_backup
ensures that a forbidden exception is raised when a user cannot get a project backup. Ensure that theForbiddenException
is correctly raised and handled.
225-228
: Methodtest_admin_can_get_project_backup
: Ensure proper parameterizationThe method
test_admin_can_get_project_backup
tests if an admin can get a project backup for both API versions. Ensure that the parameterization is correct and covers both API versions.
231-243
: Methodtest_user_cannot_get_project_backup
: Ensure correct exclusion of admin usersThe method
test_user_cannot_get_project_backup
tests if a non-admin user cannot get a project backup. Ensure that admin users are correctly excluded.
246-262
: Methodtest_org_worker_cannot_get_project_backup
: Ensure correct exclusion of project staffThe method
test_org_worker_cannot_get_project_backup
tests if an org worker who is not project staff cannot get a project backup. Ensure that project staff are correctly excluded.
265-283
: Methodtest_org_worker_can_get_project_backup
: Ensure correct inclusion of project staffThe method
test_org_worker_can_get_project_backup
tests if an org worker who is project staff can get a project backup. Ensure that project staff are correctly included.
286-300
: Methodtest_org_supervisor_can_get_project_backup
: Ensure correct inclusion of project staffThe method
test_org_supervisor_can_get_project_backup
tests if an org supervisor who is project staff can get a project backup. Ensure that project staff are correctly included.
303-323
: Methodtest_org_supervisor_cannot_get_project_backup
: Ensure correct exclusion of project staffThe method
test_org_supervisor_cannot_get_project_backup
tests if an org supervisor who is not project staff cannot get a project backup. Ensure that project staff are correctly excluded.
326-344
: Methodtest_org_maintainer_can_get_project_backup
: Ensure correct inclusion of project staffThe method
test_org_maintainer_can_get_project_backup
tests if an org maintainer who is not project staff can get a project backup. Ensure that project staff are correctly included.
347-361
: Methodtest_org_owner_can_get_project_backup
: Ensure correct inclusion of project staffThe method
test_org_owner_can_get_project_backup
tests if an org owner who is not project staff can get a project backup. Ensure that project staff are correctly included.
363-373
: Methodtest_can_get_backup_project_when_some_tasks_have_no_data
: Ensure proper handling of projects with some empty tasksThe method
test_can_get_backup_project_when_some_tasks_have_no_data
tests if a project backup can be obtained when some tasks have no data. Ensure that the handling of such projects is correct.
Line range hint
375-390
:
Methodtest_can_get_backup_project_when_all_tasks_have_no_data
: Ensure proper handling of projects with all empty tasksThe method
test_can_get_backup_project_when_all_tasks_have_no_data
tests if a project backup can be obtained when all tasks have no data. Ensure that the handling of such projects is correct.
392-395
: Methodtest_can_get_backup_for_empty_project
: Ensure proper handling of empty projectsThe method
test_can_get_backup_for_empty_project
tests if a project backup can be obtained for an empty project. Ensure that the handling of empty projects is correct.
397-416
: Methodtest_admin_can_get_project_backup_and_create_project_by_backup
: Ensure proper backup and restore functionalityThe method
test_admin_can_get_project_backup_and_create_project_by_backup
tests if an admin can get a project backup and create a project from the backup. Ensure that the backup and restore functionality is correct.
610-613
: Setup method: Ensure proper initialization of projectsThe setup method initializes the projects for the test class. Ensure that the projects are correctly initialized.
617-629
: Method_test_export_dataset
: Ensure correct export of datasetsThe method
_test_export_dataset
tests the export of datasets. Ensure that the datasets are correctly exported and that local and cloud storage are correctly handled.
630-640
: Method_test_export_annotations
: Ensure correct export of annotationsThe method
_test_export_annotations
tests the export of annotations. Ensure that the annotations are correctly exported and that local and cloud storage are correctly handled.
676-686
: Methodtest_can_import_dataset_in_org
: Ensure proper import of datasets in organizationThe method
test_can_import_dataset_in_org
tests the import of datasets in an organization for both API versions. Ensure that the import functionality is correct.
Line range hint
706-731
:
Methodtest_can_export_and_import_dataset_with_skeletons
: Ensure proper export and import of datasets with skeletonsThe method
test_can_export_and_import_dataset_with_skeletons
tests the export and import of datasets with skeletons for both API versions. Ensure that the export and import functionality is correct.
739-755
: Methodtest_can_import_export_dataset_with_some_format
: Ensure proper import and export of datasets with specific formatsThe method
test_can_import_export_dataset_with_some_format
tests the import and export of datasets with specific formats for both API versions. Ensure that the import and export functionality is correct.
Line range hint
764-811
:
Methodtest_exported_project_dataset_structure
: Ensure correct structure of exported project datasetsThe method
test_exported_project_dataset_structure
tests the structure of exported project datasets for both API versions. Ensure that the structure of the exported datasets is correct.
Line range hint
815-847
:
Methodtest_can_import_export_annotations_with_rotation
: Ensure proper import and export of annotations with rotationThe method
test_can_import_export_annotations_with_rotation
tests the import and export of annotations with rotation for both API versions. Ensure that the import and export functionality is correct.
848-861
: Methodtest_can_export_dataset_with_skeleton_labels_with_spaces
: Ensure proper export of datasets with skeleton labels containing spacesThe method
test_can_export_dataset_with_skeleton_labels_with_spaces
tests the export of datasets with skeleton labels containing spaces for both API versions. Ensure that the export functionality is correct.
862-870
: Methodtest_can_export_dataset_for_empty_project
: Ensure proper export of datasets for empty projectsThe method
test_can_export_dataset_for_empty_project
tests the export of datasets for empty projects for both API versions. Ensure that the export functionality is correct.
873-888
: Methodtest_can_export_project_dataset_when_some_tasks_have_no_data
: Ensure proper export of datasets when some tasks have no dataThe method
test_can_export_project_dataset_when_some_tasks_have_no_data
tests the export of datasets when some tasks have no data for both API versions. Ensure that the export functionality is correct.
Line range hint
891-911
:
Methodtest_can_export_project_dataset_when_all_tasks_have_no_data
: Ensure proper export of datasets when all tasks have no dataThe method
test_can_export_project_dataset_when_all_tasks_have_no_data
tests the export of datasets when all tasks have no data for both API versions. Ensure that the export functionality is correct.
Line range hint
913-937
:
Methodtest_can_export_and_import_dataset_after_deleting_related_storage
: Ensure proper handling of cloud storage deletionThe method
test_can_export_and_import_dataset_after_deleting_related_storage
tests the export and import of datasets after deleting related cloud storage for both API versions. Ensure that the handling of cloud storage deletion is correct.
Line range hint
970-988
:
Methodtest_creates_subfolders_for_subsets_on_export
: Ensure proper creation of subfolders for subsets on exportThe method
test_creates_subfolders_for_subsets_on_export
tests the creation of subfolders for subsets on export for both API versions. Ensure that the subfolders are correctly created.
Line range hint
1042-1046
:
Methodtest_can_delete_label
: Ensure proper deletion of labelsThe method
test_can_delete_label
tests if a label can be deleted from a project. Ensure that the label deletion functionality is correct.
Line range hint
1048-1059
:
Methodtest_can_delete_skeleton_label
: Ensure proper deletion of skeleton labelsThe method
test_can_delete_skeleton_label
tests if a skeleton label can be deleted from a project. Ensure that the skeleton label deletion functionality is correct.
Line range hint
1061-1071
:
Methodtest_can_rename_label
: Ensure proper renaming of labelsThe method
test_can_rename_label
tests if a label can be renamed in a project. Ensure that the label renaming functionality is correct.
Line range hint
1073-1082
:
Methodtest_cannot_rename_label_to_duplicate_name
: Ensure proper handling of duplicate label namesThe method
test_cannot_rename_label_to_duplicate_name
tests if a label cannot be renamed to a duplicate name in a project. Ensure that the handling of duplicate label names is correct.
Line range hint
1084-1091
:
Methodtest_cannot_add_foreign_label
: Ensure proper handling of foreign labelsThe method
test_cannot_add_foreign_label
tests if a foreign label cannot be added to a project. Ensure that the handling of foreign labels is correct.
Line range hint
1093-1100
:
Methodtest_admin_can_add_label
: Ensure proper addition of labels by adminThe method
test_admin_can_add_label
tests if an admin can add a label to a project. Ensure that the label addition functionality is correct.
Line range hint
1102-1118
:
Methodtest_non_project_staff_privileged_org_members_can_add_label
: Ensure proper addition of labels by non-project staff privileged org membersThe method
test_non_project_staff_privileged_org_members_can_add_label
tests if non-project staff privileged org members can add a label to a project. Ensure that the label addition functionality is correct.
Line range hint
1120-1131
:
Methodtest_non_project_staff_org_members_cannot_add_label
: Ensure proper restriction of label addition by non-project staff org membersThe method
test_non_project_staff_org_members_cannot_add_label
tests if non-project staff org members cannot add a label to a project. Ensure that the restriction of label addition is correct.
Line range hint
1133-1147
:
Methodtest_project_staff_org_members_can_add_label
: Ensure proper addition of labels by project staff org membersThe method
test_project_staff_org_members_can_add_label
tests if project staff org members can add a label to a project. Ensure that the label addition functionality is correct.
Line range hint
1149-1165
:
Methodtest_admin_can_add_skeleton
: Ensure proper addition of skeleton labels by adminThe method
test_admin_can_add_skeleton
tests if an admin can add a skeleton label to a project. Ensure that the skeleton label addition functionality is correct.
Line range hint
1197-1204
:
Method_test_response_200
: Ensure proper retrieval of project previewsThe method
_test_response_200
tests if a project preview can be retrieved successfully. Ensure that the project preview retrieval functionality is correct.
Line range hint
1206-1212
:
Method_test_response_403
: Ensure proper handling of forbidden project previewsThe method
_test_response_403
tests if a forbidden response is correctly handled when retrieving a project preview. Ensure that the forbidden response handling is correct.
Line range hint
1214-1220
:
Method_test_response_404
: Ensure proper handling of not found project previewsThe method
_test_response_404
tests if a not found response is correctly handled when retrieving a project preview. Ensure that the not found response handling is correct.
Line range hint
1223-1231
:
Methodtest_project_preview_admin_accessibility
: Ensure proper access to project previews by adminThe method
test_project_preview_admin_accessibility
tests if an admin can access project previews. Ensure that the project preview access by admin is correct.
Line range hint
1234-1244
:
Methodtest_project_preview_owner_accessibility
: Ensure proper access to project previews by project owner or assigneeThe method
test_project_preview_owner_accessibility
tests if a project owner or assignee can access project previews. Ensure that the project preview access by project owner or assignee is correct.
Line range hint
1246-1256
:
Methodtest_project_preview_not_found
: Ensure proper handling of not found project previewsThe method
test_project_preview_not_found
tests if a not found response is correctly handled when retrieving a project preview. Ensure that the not found response handling is correct.
Line range hint
1258-1265
:
Methodtest_user_cannot_see_project_preview
: Ensure proper restriction of project preview access by non-admin usersThe method
test_user_cannot_see_project_preview
tests if non-admin users cannot access project previews. Ensure that the restriction of project preview access is correct.
Line range hint
1267-1276
:
**Methodtest_if_supervisor_or_worker_cannot_see_project_preview
: Ensure proper
189-189
: Class Renaming: Ensure consistencyThe class
TestGetProjectBackup
has been renamed toTestGetPostProjectBackup
. Ensure that this new class name is consistently used across the codebase.Verification successful
Class Renaming Verified: Consistent Usage
The class
TestGetProjectBackup
has been successfully renamed toTestGetPostProjectBackup
, and the new class name is consistently used across the codebase.
- No occurrences of the old class name
TestGetProjectBackup
were found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new class name `TestGetPostProjectBackup` in the codebase. # Test: Search for the class usage. Expect: Only occurrences of the new class name. rg --type python -A 5 $'class TestGetPostProjectBackup'Length of output: 87
Script:
#!/bin/bash # Description: Verify the usage of the new class name `TestGetPostProjectBackup` in the codebase. # Test: Search for the class usage. Expect: Only occurrences of the new class name. rg --type py -A 5 $'class TestGetPostProjectBackup'Length of output: 418
Script:
#!/bin/bash # Description: Verify that the old class name `TestGetProjectBackup` is no longer used in the codebase. # Test: Search for any occurrences of the old class name. Expect: No occurrences of the old class name. rg --type py $'TestGetProjectBackup'Length of output: 35
tests/python/rest_api/test_jobs.py (9)
1331-1333
: LGTM!The
setup
function correctly initializes thetasks
attribute.
1335-1338
: LGTM!The
is_local_download
function correctly determines if a job is a local download.
1340-1350
: LGTM!The
_test_export_dataset
function correctly handles the export of a job dataset and includes appropriate assertions.
1352-1362
: LGTM!The
_test_export_annotations
function correctly handles the export of job annotations and includes appropriate assertions.
1364-1373
: LGTM!The
test_can_export_dataset
function correctly tests the export of a dataset for both API versions.
1374-1387
: LGTM!The
test_non_admin_can_export_dataset
function correctly tests the export of a dataset by a non-admin user for both API versions.
1389-1403
: LGTM!The
test_non_admin_can_export_annotations
function correctly tests the export of annotations by a non-admin user for both API versions.
Line range hint
1405-1453
:
LGTM!The
test_exported_job_dataset_structure
function correctly tests the structure of the exported job dataset for different annotation formats and API versions.
Line range hint
1454-1502
:
LGTM!The
test_export_job_among_several_jobs_in_task
function correctly tests the export of a job dataset among several jobs in a task for different annotation formats and API versions.tests/python/rest_api/test_tasks.py (7)
659-669
: LGTM!The function
_test_can_export_dataset
is well-structured and includes appropriate assertions to validate the dataset export.
671-679
: LGTM!The function
test_can_export_task_dataset
is correctly updated to handle different API versions and includes appropriate checks based on the task's storage.
681-696
: LGTM!The function
test_can_export_task_with_several_jobs
is correctly updated to handle different API versions and dataset formats, with appropriate checks based on the task's storage.
Line range hint
698-805
:
LGTM!The function
test_can_export_task_to_coco_format
is correctly updated to handle different API versions and includes appropriate checks based on the task's storage. The annotations update and validation are handled correctly.
Line range hint
807-824
:
LGTM!The function
test_can_download_task_with_special_chars_in_name
is correctly updated to handle different API versions and includes appropriate checks for special characters in the task name.
Line range hint
826-846
:
LGTM!The function
test_export_dataset_after_deleting_related_cloud_storage
is correctly updated to handle different API versions and includes appropriate checks for dataset export after deleting related cloud storage.
2289-2298
: LGTM!The function
test_can_export_backup_with_both_api_versions
is well-structured and includes appropriate assertions to validate the backup export for different API versions.
tests/python/shared/fixtures/data.py
Outdated
def filter_assets(resources: Iterable, **kwargs): | ||
filtered_resources = [] | ||
exclude_prefix = "exclude_" | ||
|
||
for resource in resources: | ||
for key, value in kwargs.items(): | ||
if exclude := key.startswith(exclude_prefix): | ||
key = key[len(exclude_prefix) :] | ||
|
||
op = operator.ne if exclude else operator.eq | ||
cur_value, rest = resource, key | ||
while rest: | ||
field_and_rest = rest.split("__", maxsplit=1) | ||
if 2 == len(field_and_rest): | ||
field, rest = field_and_rest | ||
else: | ||
field, rest = field_and_rest[0], None | ||
cur_value = cur_value[field] | ||
# e.g. task has null target_storage | ||
if not cur_value: | ||
break | ||
|
||
if not rest and op(cur_value, value) or rest and op == operator.ne: | ||
filtered_resources.append(resource) | ||
|
||
return filtered_resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle potential issue with nested field access when cur_value
is None
.
If cur_value
is None
before accessing nested fields, it may lead to a TypeError
. Consider adding a check to handle this case.
- while rest:
+ while rest and cur_value:
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def filter_assets(resources: Iterable, **kwargs): | |
filtered_resources = [] | |
exclude_prefix = "exclude_" | |
for resource in resources: | |
for key, value in kwargs.items(): | |
if exclude := key.startswith(exclude_prefix): | |
key = key[len(exclude_prefix) :] | |
op = operator.ne if exclude else operator.eq | |
cur_value, rest = resource, key | |
while rest: | |
field_and_rest = rest.split("__", maxsplit=1) | |
if 2 == len(field_and_rest): | |
field, rest = field_and_rest | |
else: | |
field, rest = field_and_rest[0], None | |
cur_value = cur_value[field] | |
# e.g. task has null target_storage | |
if not cur_value: | |
break | |
if not rest and op(cur_value, value) or rest and op == operator.ne: | |
filtered_resources.append(resource) | |
return filtered_resources | |
def filter_assets(resources: Iterable, **kwargs): | |
filtered_resources = [] | |
exclude_prefix = "exclude_" | |
for resource in resources: | |
for key, value in kwargs.items(): | |
if exclude := key.startswith(exclude_prefix): | |
key = key[len(exclude_prefix) :] | |
op = operator.ne if exclude else operator.eq | |
cur_value, rest = resource, key | |
while rest and cur_value: | |
field_and_rest = rest.split("__", maxsplit=1) | |
if 2 == len(field_and_rest): | |
field, rest = field_and_rest | |
else: | |
field, rest = field_and_rest[0], None | |
cur_value = cur_value[field] | |
# e.g. task has null target_storage | |
if not cur_value: | |
break | |
if not rest and op(cur_value, value) or rest and op == operator.ne: | |
filtered_resources.append(resource) | |
return filtered_resources |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8216 +/- ##
===========================================
+ Coverage 83.40% 83.57% +0.17%
===========================================
Files 393 393
Lines 41579 41608 +29
Branches 3843 3843
===========================================
+ Hits 34678 34774 +96
+ Misses 6901 6834 -67
|
@zhiltsov-max, @SpecLad Before fix:
After fix:
|
Co-authored-by: Maxim Zhiltsov <zhiltsov.max35@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a rebase, but otherwise LGTM.
Quality Gate failedFailed conditions |
Motivation and context
This PR fixes the following issues:
rq_id
for all requests with 202 status code (not only for initialization requests)REST API tests updates:
import/export
bucket to exclude the same bucket usage as a data source in several tests (when bucket content is used as task data) and as a bucket for resultsHow has this been tested?
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
New Features
resource
field in the request handling system to improve data categorization.resource
field.Bug Fixes
Tests