|
5 | 5 | import json |
6 | 6 | from http import HTTPMethod, HTTPStatus |
7 | 7 | from typing import Any |
| 8 | +from uuid import uuid4 |
8 | 9 |
|
9 | 10 | import pytest |
10 | 11 | from urllib3.filepost import encode_multipart_formdata |
|
13 | 14 |
|
14 | 15 | from mock_vws._constants import ResultCodes |
15 | 16 | from mock_vws.database import VuforiaDatabase |
| 17 | +from tests.mock_vws.fixtures.credentials import VuMarkVuforiaDatabase |
16 | 18 | from tests.mock_vws.utils import Endpoint |
17 | 19 | from tests.mock_vws.utils.retries import RETRY_ON_TOO_MANY_REQUESTS |
18 | 20 |
|
@@ -451,3 +453,49 @@ def query( |
451 | 453 | access_key=access_key, |
452 | 454 | secret_key=secret_key, |
453 | 455 | ) |
| 456 | + |
| 457 | + |
| 458 | +@pytest.fixture |
| 459 | +def vumark_generate_instance( |
| 460 | + vumark_vuforia_database: VuMarkVuforiaDatabase, |
| 461 | +) -> Endpoint: |
| 462 | + """Return details of the endpoint for generating a VuMark instance.""" |
| 463 | + request_path = f"/targets/{vumark_vuforia_database.target_id}/instances" |
| 464 | + content_type = "application/json" |
| 465 | + method = HTTPMethod.POST |
| 466 | + content = json.dumps(obj={"instance_id": uuid4().hex}).encode( |
| 467 | + encoding="utf-8" |
| 468 | + ) |
| 469 | + date = rfc_1123_date() |
| 470 | + |
| 471 | + access_key = vumark_vuforia_database.server_access_key |
| 472 | + secret_key = vumark_vuforia_database.server_secret_key |
| 473 | + authorization_string = authorization_header( |
| 474 | + access_key=access_key, |
| 475 | + secret_key=secret_key, |
| 476 | + method=method, |
| 477 | + content=content, |
| 478 | + content_type=content_type, |
| 479 | + date=date, |
| 480 | + request_path=request_path, |
| 481 | + ) |
| 482 | + |
| 483 | + headers = { |
| 484 | + "Accept": "image/png", |
| 485 | + "Authorization": authorization_string, |
| 486 | + "Content-Length": str(object=len(content)), |
| 487 | + "Content-Type": content_type, |
| 488 | + "Date": date, |
| 489 | + } |
| 490 | + |
| 491 | + return Endpoint( |
| 492 | + successful_headers_status_code=HTTPStatus.OK, |
| 493 | + successful_headers_result_code=None, |
| 494 | + base_url=VWS_HOST, |
| 495 | + path_url=request_path, |
| 496 | + method=method, |
| 497 | + headers=headers, |
| 498 | + data=content, |
| 499 | + access_key=access_key, |
| 500 | + secret_key=secret_key, |
| 501 | + ) |
0 commit comments