This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
forked from cvat-ai/cvat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbd15c0
commit c11cb89
Showing
7 changed files
with
109 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright (C) 2022 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
from time import sleep | ||
from http import HTTPStatus | ||
from .utils.config import get_method, post_method | ||
|
||
|
||
def _post_task_remote_data(username, task_id, resources): | ||
data = { | ||
'remote_files': resources, | ||
'image_quality': 30, | ||
} | ||
|
||
return post_method(username, f'tasks/{task_id}/data', data) | ||
|
||
def _wait_until_task_is_created(username, task_id): | ||
url = f'tasks/{task_id}/status' | ||
|
||
while True: | ||
response = get_method(username, url) | ||
response_json = response.json() | ||
if response_json['state'] == 'Finished' or response_json['state'] == 'Failed': | ||
return response | ||
sleep(1) | ||
|
||
|
||
class TestGetAnalytics: | ||
task_id = 8 | ||
def _test_can_create(self, user, task_id, resources): | ||
response = _post_task_remote_data(user, task_id, resources) | ||
assert response.status_code == HTTPStatus.ACCEPTED | ||
|
||
response = _wait_until_task_is_created(user, task_id) | ||
response_json = response.json() | ||
assert response_json['state'] == 'Finished' | ||
|
||
def _test_cannot_create(self, user, task_id, resources): | ||
response = _post_task_remote_data(user, task_id, resources) | ||
assert response.status_code == HTTPStatus.ACCEPTED | ||
|
||
response = _wait_until_task_is_created(user, task_id) | ||
response_json = response.json() | ||
assert response_json['state'] == 'Failed' | ||
|
||
def test_cannot_create(self, find_users): | ||
user = find_users(privilege='admin')[0]['username'] | ||
remote_resources = ['http://localhost/favicon.ico'] | ||
|
||
self._test_cannot_create(user, self.task_id, remote_resources) | ||
|
||
def test_can_create(self, find_users): | ||
user = find_users(privilege='admin')[0]['username'] | ||
remote_resources = ['https://openvinotoolkit.github.io/cvat/favicons/favicon-32x32.png'] | ||
|
||
self._test_can_create(user, self.task_id, remote_resources) |