utf-queue-client 1.17.2b1__tar.gz → 1.17.2b2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/MANIFEST.in +6 -8
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/PKG-INFO +1 -1
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/setup.py +3 -2
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/async_consumer.py +1 -1
- utf-queue-client-1.17.2b2/utf_queue_client/models/schemas/utf_queue_models/models/python/__pycache__/__init__.cpython-39.pyc +0 -0
- utf-queue-client-1.17.2b2/utf_queue_client/models/schemas/utf_queue_models/models/python/__pycache__/generated_models.cpython-39.pyc +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client.egg-info/PKG-INFO +1 -1
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client.egg-info/SOURCES.txt +2 -17
- utf-queue-client-1.17.2b1/test/test_amqp_connections.py +0 -46
- utf-queue-client-1.17.2b1/test/test_async_consumer.py +0 -12
- utf-queue-client-1.17.2b1/test/test_connection_retry.py +0 -40
- utf-queue-client-1.17.2b1/test/test_data_lake_data_producer.py +0 -57
- utf-queue-client-1.17.2b1/test/test_http_producer.py +0 -90
- utf-queue-client-1.17.2b1/test/test_legacy_base_model.py +0 -47
- utf-queue-client-1.17.2b1/test/test_models.py +0 -125
- utf-queue-client-1.17.2b1/test/test_opentelemetry_data_producer.py +0 -168
- utf-queue-client-1.17.2b1/test/test_publish_release_info.py +0 -145
- utf-queue-client-1.17.2b1/test/test_publish_test_results.py +0 -160
- utf-queue-client-1.17.2b1/test/test_rail_data_producer_tests.py +0 -64
- utf-queue-client-1.17.2b1/test/test_sqa_test_result_producer.py +0 -48
- utf-queue-client-1.17.2b1/test/test_ubai_copy.py +0 -113
- utf-queue-client-1.17.2b1/test/test_ubai_search.py +0 -81
- utf-queue-client-1.17.2b1/test/test_ubai_update_retention.py +0 -61
- utf-queue-client-1.17.2b1/test/test_ubai_upload.py +0 -113
- utf-queue-client-1.17.2b1/test/test_utils.py +0 -77
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/README.md +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/setup.cfg +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/__init__.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/__init__.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/base_producer.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/data_lake_data_producer.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/http_producer.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/opentelemetry_data_producer.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/sqa_test_result_producer.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/test_rail_data_producer.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/clients/ubai_artifact_upload_request_producer.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/exceptions/__init__.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/models/__init__.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/models/base_model.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/models/model_factory.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/models/schemas/__init__.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/models/schemas/utf_queue_models/models/python/__init__.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/models/schemas/utf_queue_models/models/python/generated_models.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/models/schemas/utf_queue_models/schema/queue_message.json +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/models/schemas/utf_queue_models/schema/queue_message.ts +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/scripts/__init__.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/scripts/publish_release_info_cli.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/scripts/publish_test_results_cli.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/scripts/ubai_copy_cli.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/scripts/ubai_search_cli.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/scripts/ubai_update_retention_cli.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/scripts/ubai_upload_cli.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/utils/__init__.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/utils/queue_metrics_exporter.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client/utils/queue_span_exporter.py +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client.egg-info/dependency_links.txt +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client.egg-info/entry_points.txt +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client.egg-info/requires.txt +0 -0
- {utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# Include all JSON files in a specific folder
|
|
1
|
+
# Recursively include a directory and all of its contents
|
|
2
|
+
graft utf_queue_client/models/schemas/utf_queue_models/models/python
|
|
5
3
|
graft utf_queue_client/models/schemas/utf_queue_models/schema
|
|
6
4
|
|
|
7
5
|
# Exclude all compiled Python files
|
|
@@ -9,12 +7,12 @@ graft utf_queue_client/models/schemas/utf_queue_models/schema
|
|
|
9
7
|
# global-exclude *.pyo
|
|
10
8
|
|
|
11
9
|
# Exclude specific directories
|
|
12
|
-
prune __pycache__
|
|
13
|
-
prune tests/
|
|
14
|
-
prune test/
|
|
10
|
+
# prune __pycache__
|
|
11
|
+
# prune tests/
|
|
12
|
+
# prune test/
|
|
15
13
|
|
|
16
14
|
# Include specific text files
|
|
17
15
|
# include *.txt
|
|
18
16
|
|
|
19
17
|
# Exclude all files in a particular directory
|
|
20
|
-
|
|
18
|
+
recursive-exclude test *
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
from setuptools import setup, find_packages # noqa: H301
|
|
6
7
|
|
|
7
8
|
NAME = "utf-queue-client"
|
|
8
|
-
VERSION = "1.17.
|
|
9
|
+
VERSION = "1.17.2b2"
|
|
9
10
|
# To install the library, run the following
|
|
10
11
|
#
|
|
11
12
|
# python setup.py install
|
|
@@ -39,7 +40,7 @@ setup(
|
|
|
39
40
|
keywords=["UTF", ""],
|
|
40
41
|
python_requires=">=3.6",
|
|
41
42
|
install_requires=REQUIRES,
|
|
42
|
-
packages=find_packages(),
|
|
43
|
+
packages=find_packages(exclude=["test", "tests"]),
|
|
43
44
|
package_data={
|
|
44
45
|
"utf_queue_client": [
|
|
45
46
|
"models/schemas/utf_queue_models/models/python/*.py",
|
|
Binary file
|
|
Binary file
|
{utf-queue-client-1.17.2b1 → utf-queue-client-1.17.2b2}/utf_queue_client.egg-info/SOURCES.txt
RENAMED
|
@@ -2,23 +2,6 @@ MANIFEST.in
|
|
|
2
2
|
README.md
|
|
3
3
|
setup.cfg
|
|
4
4
|
setup.py
|
|
5
|
-
test/test_amqp_connections.py
|
|
6
|
-
test/test_async_consumer.py
|
|
7
|
-
test/test_connection_retry.py
|
|
8
|
-
test/test_data_lake_data_producer.py
|
|
9
|
-
test/test_http_producer.py
|
|
10
|
-
test/test_legacy_base_model.py
|
|
11
|
-
test/test_models.py
|
|
12
|
-
test/test_opentelemetry_data_producer.py
|
|
13
|
-
test/test_publish_release_info.py
|
|
14
|
-
test/test_publish_test_results.py
|
|
15
|
-
test/test_rail_data_producer_tests.py
|
|
16
|
-
test/test_sqa_test_result_producer.py
|
|
17
|
-
test/test_ubai_copy.py
|
|
18
|
-
test/test_ubai_search.py
|
|
19
|
-
test/test_ubai_update_retention.py
|
|
20
|
-
test/test_ubai_upload.py
|
|
21
|
-
test/test_utils.py
|
|
22
5
|
utf_queue_client/__init__.py
|
|
23
6
|
utf_queue_client.egg-info/PKG-INFO
|
|
24
7
|
utf_queue_client.egg-info/SOURCES.txt
|
|
@@ -42,6 +25,8 @@ utf_queue_client/models/model_factory.py
|
|
|
42
25
|
utf_queue_client/models/schemas/__init__.py
|
|
43
26
|
utf_queue_client/models/schemas/utf_queue_models/models/python/__init__.py
|
|
44
27
|
utf_queue_client/models/schemas/utf_queue_models/models/python/generated_models.py
|
|
28
|
+
utf_queue_client/models/schemas/utf_queue_models/models/python/__pycache__/__init__.cpython-39.pyc
|
|
29
|
+
utf_queue_client/models/schemas/utf_queue_models/models/python/__pycache__/generated_models.cpython-39.pyc
|
|
45
30
|
utf_queue_client/models/schemas/utf_queue_models/schema/queue_message.json
|
|
46
31
|
utf_queue_client/models/schemas/utf_queue_models/schema/queue_message.ts
|
|
47
32
|
utf_queue_client/scripts/__init__.py
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from utf_queue_client.clients.base_producer import BlockingProducer
|
|
3
|
-
import pytest
|
|
4
|
-
import logging
|
|
5
|
-
import pika
|
|
6
|
-
import time
|
|
7
|
-
from utf_queue_client.utils import UTF_QUEUE_REGION_MAP
|
|
8
|
-
from urllib.parse import quote
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
regions = list(UTF_QUEUE_REGION_MAP.values())
|
|
12
|
-
servers = [f"utf-queue-{region}" for region in regions]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@pytest.fixture(params=servers)
|
|
16
|
-
def queue_server(request):
|
|
17
|
-
yield request.param
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@pytest.mark.parametrize(
|
|
21
|
-
"username, password",
|
|
22
|
-
[
|
|
23
|
-
(os.environ["UTF_QUEUE_USERNAME_LDAP"], os.environ["UTF_QUEUE_PASSWORD_LDAP"]),
|
|
24
|
-
(os.environ["UTF_QUEUE_USERNAME"], os.environ["UTF_QUEUE_PASSWORD"]),
|
|
25
|
-
],
|
|
26
|
-
)
|
|
27
|
-
def test_producer(queue_server, username, password):
|
|
28
|
-
suffix = ".silabs.net"
|
|
29
|
-
queue_server = f"{queue_server}{suffix}"
|
|
30
|
-
l = logging.getLogger("test_producer")
|
|
31
|
-
l.info("Creating producer...")
|
|
32
|
-
p = BlockingProducer(
|
|
33
|
-
url=f"amqps://{username}:{quote(password)}@{queue_server}:443/testing?stack_timeout=30",
|
|
34
|
-
)
|
|
35
|
-
l.info(f"{queue_server}: Created producer")
|
|
36
|
-
params = pika.URLParameters(p.url)
|
|
37
|
-
l.info(f"stack timeout: {params.stack_timeout}")
|
|
38
|
-
begin = time.time()
|
|
39
|
-
for _ in range(0, 10):
|
|
40
|
-
l.info(f"{queue_server}: declaring queue...")
|
|
41
|
-
start = time.time()
|
|
42
|
-
p.queue_declare("default", durable=True)
|
|
43
|
-
stop = time.time()
|
|
44
|
-
l.info(
|
|
45
|
-
f"{queue_server}: done declaring queue in {stop - start} sec. Total time: {stop - begin}"
|
|
46
|
-
)
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from utf_queue_client.clients.async_consumer import AsyncConsumerBase
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def test_sanitize_url():
|
|
6
|
-
params = [
|
|
7
|
-
("amqp://www.ni.com", "amqp://www.ni.com"),
|
|
8
|
-
("amqps://utfsilabs:password1234@www.ni.com", "amqps://utfsilabs:******@www.ni.com"),
|
|
9
|
-
]
|
|
10
|
-
for url, display_url in params:
|
|
11
|
-
sanitized_url = AsyncConsumerBase.sanitize_url_for_display(url)
|
|
12
|
-
assert sanitized_url == display_url
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import logging.handlers
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
from utf_queue_client.clients.sqa_test_result_producer import (
|
|
6
|
-
SqaTestResultProducer,
|
|
7
|
-
)
|
|
8
|
-
from utf_queue_client.clients.base_producer import ConnectionError
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@pytest.fixture()
|
|
12
|
-
def pika_logging_handler():
|
|
13
|
-
"""Add a handler to the pika logger to capture its output."""
|
|
14
|
-
pika_logger = logging.getLogger("pika.adapters.utils.connection_workflow")
|
|
15
|
-
handler = logging.handlers.BufferingHandler(capacity=100)
|
|
16
|
-
pika_logger.addHandler(handler)
|
|
17
|
-
yield handler
|
|
18
|
-
pika_logger.removeHandler(handler)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@pytest.mark.parametrize(
|
|
22
|
-
"set_environment_variable",
|
|
23
|
-
[("UTF_QUEUE_SERVER_URL", "amqps://utfsilabs:utfsilabs@12.34.56.78:5671/%2f")],
|
|
24
|
-
indirect=True,
|
|
25
|
-
)
|
|
26
|
-
def test_result_producer_connection_retry(
|
|
27
|
-
set_environment_variable, mocker, pika_logging_handler
|
|
28
|
-
):
|
|
29
|
-
"""Test that the connection retry logic works as expected."""
|
|
30
|
-
mocker.patch("utf_queue_client.clients.base_producer.NUM_CONNECTION_TRIES", 2)
|
|
31
|
-
with pytest.raises(ConnectionError):
|
|
32
|
-
_ = SqaTestResultProducer()
|
|
33
|
-
error_records = [
|
|
34
|
-
record
|
|
35
|
-
for record in pika_logging_handler.buffer
|
|
36
|
-
if record.levelno == logging.ERROR
|
|
37
|
-
]
|
|
38
|
-
# The assertion below depends on the logging output of the pika library (version 1.3.2 as of this writing)
|
|
39
|
-
# so if that changes, the message below may need to be updated.
|
|
40
|
-
assert "2 exceptions in all" in error_records[-1].message
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import uuid
|
|
3
|
-
|
|
4
|
-
from utf_queue_client.clients.data_lake_data_producer import (
|
|
5
|
-
DataLakeDataProducer,
|
|
6
|
-
DataLakeDataProducerFactory,
|
|
7
|
-
)
|
|
8
|
-
import pytest
|
|
9
|
-
import os
|
|
10
|
-
import ndjson
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_data_lake_producer_empty_url():
|
|
14
|
-
with pytest.raises(RuntimeError):
|
|
15
|
-
_ = DataLakeDataProducer("dummy tenant")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@pytest.mark.parametrize("use_object_id", [True, False])
|
|
19
|
-
def test_data_lake_producer_central_queue(
|
|
20
|
-
request,
|
|
21
|
-
data_lake_tenant_key,
|
|
22
|
-
csv_file_path,
|
|
23
|
-
json_file_path,
|
|
24
|
-
parquet_file_path,
|
|
25
|
-
ndjson_file_path,
|
|
26
|
-
amqp_url,
|
|
27
|
-
queue_consumer,
|
|
28
|
-
use_object_id,
|
|
29
|
-
):
|
|
30
|
-
os.environ["UTF_PRODUCER_APP_ID"] = request.node.name
|
|
31
|
-
producer = DataLakeDataProducerFactory.create_producer(
|
|
32
|
-
data_lake_tenant_key, amqp_url
|
|
33
|
-
)
|
|
34
|
-
producer.publish_data_lake_csv_file(
|
|
35
|
-
csv_file_path, object_id=str(uuid.uuid4()) if use_object_id else None
|
|
36
|
-
)
|
|
37
|
-
queue_consumer.expect_messages(1)
|
|
38
|
-
producer.publish_data_lake_json_file(
|
|
39
|
-
json_file_path, object_id=str(uuid.uuid4()) if use_object_id else None
|
|
40
|
-
)
|
|
41
|
-
queue_consumer.expect_messages(2)
|
|
42
|
-
with open(json_file_path, "rb") as f:
|
|
43
|
-
producer.publish_data_lake_json(json.load(f))
|
|
44
|
-
producer.publish_data_lake_parquet_file(
|
|
45
|
-
parquet_file_path, object_id=str(uuid.uuid4()) if use_object_id else None
|
|
46
|
-
)
|
|
47
|
-
queue_consumer.expect_messages(3)
|
|
48
|
-
producer.publish_data_lake_ndjson_file(
|
|
49
|
-
ndjson_file_path, object_id=str(uuid.uuid4()) if use_object_id else None
|
|
50
|
-
)
|
|
51
|
-
queue_consumer.expect_messages(4)
|
|
52
|
-
with open(ndjson_file_path) as f:
|
|
53
|
-
data = ndjson.load(f)
|
|
54
|
-
producer.publish_data_lake_ndjson(
|
|
55
|
-
data, object_id=str(uuid.uuid4()) if use_object_id else None
|
|
56
|
-
)
|
|
57
|
-
queue_consumer.expect_messages(5)
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from utf_queue_client.clients.base_producer import (
|
|
3
|
-
ConnectionError as QueueServerConnectionError,
|
|
4
|
-
)
|
|
5
|
-
from utf_queue_client.clients.http_producer import (
|
|
6
|
-
HTTPProducer,
|
|
7
|
-
HTTPChannel,
|
|
8
|
-
CompositeHTTPProducer,
|
|
9
|
-
)
|
|
10
|
-
from pika.spec import BasicProperties, PERSISTENT_DELIVERY_MODE
|
|
11
|
-
from unittest.mock import patch
|
|
12
|
-
import utf_queue_client.clients.http_producer
|
|
13
|
-
|
|
14
|
-
FAKE_CREDS = "notarealusername:notarealpassword"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def test_basic_properties_to_json():
|
|
18
|
-
assert HTTPChannel.basic_properties_to_json(BasicProperties(app_id="foo")) == {
|
|
19
|
-
"app_id": "foo"
|
|
20
|
-
}
|
|
21
|
-
assert HTTPChannel.basic_properties_to_json(
|
|
22
|
-
BasicProperties(app_id="foo", delivery_mode=PERSISTENT_DELIVERY_MODE)
|
|
23
|
-
) == {"app_id": "foo", "delivery_mode": 2}
|
|
24
|
-
assert HTTPChannel.basic_properties_to_json(None) == {}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def test_http_channel_connection_error():
|
|
28
|
-
channel = HTTPChannel(
|
|
29
|
-
"https://localshmost", ("user", "pass"), "/", retries=0, retry_delay=0
|
|
30
|
-
)
|
|
31
|
-
with pytest.raises(QueueServerConnectionError):
|
|
32
|
-
channel.queue_declare("queue")
|
|
33
|
-
with pytest.raises(QueueServerConnectionError):
|
|
34
|
-
channel.basic_publish("exchange", "routing_key", b"foo", None)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def test_composite_producer_errors():
|
|
38
|
-
with patch.object(
|
|
39
|
-
utf_queue_client.clients.http_producer, "DEFAULT_NUM_CONNECTION_RETRIES", 0
|
|
40
|
-
):
|
|
41
|
-
composite_producer = CompositeHTTPProducer(
|
|
42
|
-
f"amqps://{FAKE_CREDS}@localshmost:443/%2F", "app_id"
|
|
43
|
-
)
|
|
44
|
-
composite_producer.producers.append(composite_producer.producers[0])
|
|
45
|
-
with pytest.raises(QueueServerConnectionError):
|
|
46
|
-
composite_producer.queue_declare("queue")
|
|
47
|
-
with pytest.raises(QueueServerConnectionError):
|
|
48
|
-
composite_producer.publish("exchange", "routing_key", {"foo": "bar"}, True)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
@pytest.mark.parametrize(
|
|
52
|
-
("amqp_url", "expected_http_urls"),
|
|
53
|
-
[
|
|
54
|
-
(
|
|
55
|
-
f"amqps://{FAKE_CREDS}@localshmost:443/%2F",
|
|
56
|
-
["https://localshmost-admin:443"],
|
|
57
|
-
),
|
|
58
|
-
(
|
|
59
|
-
f"amqps://{FAKE_CREDS}@utf-queue-central:443/%2F",
|
|
60
|
-
["https://utf-queue-central-admin:443"],
|
|
61
|
-
),
|
|
62
|
-
(
|
|
63
|
-
f"amqps://{FAKE_CREDS}@utf-queue-central.silabs.net:443/%2F",
|
|
64
|
-
[
|
|
65
|
-
"https://utf-queue-central-admin.silabs.net:443",
|
|
66
|
-
"https://utf-queue-aus-admin.silabs.net:443",
|
|
67
|
-
"https://utf-queue-bos-admin.silabs.net:443",
|
|
68
|
-
"https://utf-queue-bud-admin.silabs.net:443",
|
|
69
|
-
"https://utf-queue-hyd-admin.silabs.net:443",
|
|
70
|
-
"https://utf-queue-yul-admin.silabs.net:443",
|
|
71
|
-
],
|
|
72
|
-
),
|
|
73
|
-
(
|
|
74
|
-
f"amqps://{FAKE_CREDS}@utf-queue-aus.silabs.net:443/%2F",
|
|
75
|
-
[
|
|
76
|
-
"https://utf-queue-central-admin.silabs.net:443",
|
|
77
|
-
"https://utf-queue-aus-admin.silabs.net:443",
|
|
78
|
-
"https://utf-queue-bos-admin.silabs.net:443",
|
|
79
|
-
"https://utf-queue-bud-admin.silabs.net:443",
|
|
80
|
-
"https://utf-queue-hyd-admin.silabs.net:443",
|
|
81
|
-
"https://utf-queue-yul-admin.silabs.net:443",
|
|
82
|
-
],
|
|
83
|
-
),
|
|
84
|
-
],
|
|
85
|
-
)
|
|
86
|
-
def test_composite_producer_creation(amqp_url, expected_http_urls):
|
|
87
|
-
composite_producer = CompositeHTTPProducer(amqp_url, "app_id")
|
|
88
|
-
assert len(composite_producer.producers) == len(expected_http_urls)
|
|
89
|
-
for index, value in enumerate(expected_http_urls):
|
|
90
|
-
assert composite_producer.producers[index].channel.url == value
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from utf_queue_client.models.base_model import LegacyBaseModel as BaseModel
|
|
2
|
-
import pytest
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def test_base_model():
|
|
6
|
-
|
|
7
|
-
test_dict = {
|
|
8
|
-
"key1": "value1",
|
|
9
|
-
"key2": 2,
|
|
10
|
-
"key3": {"subkey1": "subvalue1"},
|
|
11
|
-
"key4": ["apple", "orange"],
|
|
12
|
-
"key5": [{"nested_dict_key": 1}, ["nested_list_val1", "nested_list_val2"]],
|
|
13
|
-
}
|
|
14
|
-
dot_dict_1 = BaseModel.convert_dict_to_model(test_dict)
|
|
15
|
-
|
|
16
|
-
def check_values(dot_dict: BaseModel):
|
|
17
|
-
assert dot_dict.key1 == "value1"
|
|
18
|
-
assert dot_dict.key2 == 2
|
|
19
|
-
assert dot_dict.key3.subkey1 == "subvalue1"
|
|
20
|
-
assert len(dot_dict.key4) == 2
|
|
21
|
-
assert dot_dict.key4[0] == "apple" and dot_dict.key4[1] == "orange"
|
|
22
|
-
assert len(dot_dict.key5) == 2
|
|
23
|
-
assert isinstance(dot_dict.key5[0], BaseModel)
|
|
24
|
-
assert dot_dict.key5[0].nested_dict_key == 1
|
|
25
|
-
assert isinstance(dot_dict.key5[1], list)
|
|
26
|
-
assert len(dot_dict.key5[1]) == 2
|
|
27
|
-
assert dot_dict.key5[1][0] == "nested_list_val1"
|
|
28
|
-
assert dot_dict.key5[1][1] == "nested_list_val2"
|
|
29
|
-
|
|
30
|
-
check_values(dot_dict_1)
|
|
31
|
-
dot_dict_copy = dot_dict_1.copy()
|
|
32
|
-
check_values(dot_dict_copy)
|
|
33
|
-
assert dot_dict_1 == dot_dict_copy
|
|
34
|
-
|
|
35
|
-
# test that apply returns true when a value is changed
|
|
36
|
-
apply_from = {"key1": "newvalue1", "new_key": "newvalue2"}
|
|
37
|
-
assert dot_dict_1.apply(apply_from)
|
|
38
|
-
assert dot_dict_1.key1 == "newvalue1"
|
|
39
|
-
assert dot_dict_1 != dot_dict_copy
|
|
40
|
-
assert not hasattr(dot_dict_1, "new_key")
|
|
41
|
-
# nothing changed so apply returns False
|
|
42
|
-
assert not dot_dict_1.apply(apply_from)
|
|
43
|
-
|
|
44
|
-
# apply should raise valueError if a type is changed
|
|
45
|
-
apply_from = {"key1": 2}
|
|
46
|
-
with pytest.raises(ValueError):
|
|
47
|
-
dot_dict_1.apply(apply_from)
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
from utf_queue_client.models import (
|
|
2
|
-
SqaAppBuildResult,
|
|
3
|
-
SqaTestResult,
|
|
4
|
-
SqaTestSession,
|
|
5
|
-
QueueMessage,
|
|
6
|
-
QueueMessageV1,
|
|
7
|
-
ArtifactUploadRequest,
|
|
8
|
-
ArtifactMetadata,
|
|
9
|
-
ArtifactBuildMetadata,
|
|
10
|
-
)
|
|
11
|
-
from utf_queue_client.exceptions import SchemaValidationError, ValidationError
|
|
12
|
-
from utf_queue_client.models.model_factory import (
|
|
13
|
-
create_model_with_defaults,
|
|
14
|
-
)
|
|
15
|
-
import pytest
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def test_model_factory_no_args_valid():
|
|
19
|
-
# these types support empty initializer
|
|
20
|
-
types_supporting_defaults_or_no_args = [
|
|
21
|
-
ArtifactMetadata,
|
|
22
|
-
ArtifactBuildMetadata,
|
|
23
|
-
]
|
|
24
|
-
for model_type in types_supporting_defaults_or_no_args:
|
|
25
|
-
create_model_with_defaults(model_type)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def test_model_factory_no_args_invalid():
|
|
29
|
-
# these types do not support creation with empty initializer
|
|
30
|
-
types_requiring_args = [
|
|
31
|
-
QueueMessage,
|
|
32
|
-
QueueMessageV1,
|
|
33
|
-
ArtifactUploadRequest,
|
|
34
|
-
SqaTestSession,
|
|
35
|
-
]
|
|
36
|
-
for model_type in types_requiring_args:
|
|
37
|
-
with pytest.raises(ValidationError):
|
|
38
|
-
create_model_with_defaults(model_type)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def test_sqa_appbuild_results_record_model_creation(sqa_app_build_result):
|
|
45
|
-
init_dict = {**sqa_app_build_result.dict(), "invalid_attr": True}
|
|
46
|
-
|
|
47
|
-
# kwarg creation
|
|
48
|
-
model = SqaAppBuildResult(**init_dict)
|
|
49
|
-
assert "invalid_attr" not in model.dict()
|
|
50
|
-
|
|
51
|
-
# dict creation
|
|
52
|
-
model = SqaAppBuildResult(init_dict)
|
|
53
|
-
assert "invalid_attr" not in model.dict()
|
|
54
|
-
|
|
55
|
-
with pytest.raises(ValidationError):
|
|
56
|
-
SqaAppBuildResult(dict(invalid_attr=True))
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def test_sqa_test_results_record_schema_validation(sqa_test_result):
|
|
60
|
-
model = SqaTestResult(sqa_test_result.dict())
|
|
61
|
-
model.validate_schema()
|
|
62
|
-
model.test_result = "fail"
|
|
63
|
-
model.validate_schema()
|
|
64
|
-
|
|
65
|
-
model = SqaTestResult(sqa_test_result.dict())
|
|
66
|
-
model.test_case_id = 4
|
|
67
|
-
with pytest.raises(SchemaValidationError):
|
|
68
|
-
model.validate_schema()
|
|
69
|
-
|
|
70
|
-
model = SqaTestResult(sqa_test_result.dict())
|
|
71
|
-
model.test_result = "PASS"
|
|
72
|
-
with pytest.raises(SchemaValidationError):
|
|
73
|
-
model.validate_schema()
|
|
74
|
-
|
|
75
|
-
model = SqaTestResult(sqa_test_result.dict())
|
|
76
|
-
model.test_case_id = "=" * 513
|
|
77
|
-
with pytest.raises(SchemaValidationError):
|
|
78
|
-
model.validate_schema()
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def test_sqa_test_session_creation(sqa_test_session):
|
|
82
|
-
with pytest.raises(ValidationError):
|
|
83
|
-
_ = SqaTestSession(eventType="TEST_RESULT", invalid_attr=True)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
@pytest.fixture()
|
|
87
|
-
def artifact_upload_request():
|
|
88
|
-
yield ArtifactUploadRequest(
|
|
89
|
-
name="foop",
|
|
90
|
-
extension=".py",
|
|
91
|
-
metadata={},
|
|
92
|
-
base64Content="6",
|
|
93
|
-
validateMetadata=False,
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def test_artifact_upload_request(artifact_upload_request):
|
|
98
|
-
model = artifact_upload_request
|
|
99
|
-
model.validate_schema()
|
|
100
|
-
with pytest.raises(SchemaValidationError):
|
|
101
|
-
model.base64Content = 6
|
|
102
|
-
model.validate_schema()
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def test_deserialize_queue_message_v1(artifact_upload_request):
|
|
106
|
-
message = {
|
|
107
|
-
"payload": artifact_upload_request.dict(),
|
|
108
|
-
"recordType": "ARTIFACT_UPLOAD_REQUEST",
|
|
109
|
-
"timestamp": 1649882203,
|
|
110
|
-
}
|
|
111
|
-
queue_message = QueueMessageV1(message)
|
|
112
|
-
if queue_message.recordType == "ARTIFACT_UPLOAD_REQUEST":
|
|
113
|
-
_ = ArtifactUploadRequest(queue_message.payload.dict())
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def test_deserialize_queue_message_v2(artifact_upload_request):
|
|
117
|
-
message = {
|
|
118
|
-
"payload": artifact_upload_request.dict(),
|
|
119
|
-
"recordType": "ARTIFACT_UPLOAD_REQUEST",
|
|
120
|
-
"tenantKey": "12345678",
|
|
121
|
-
"recordTimestamp": "2022-03-10T18:50:05Z",
|
|
122
|
-
}
|
|
123
|
-
queue_message = QueueMessage(message)
|
|
124
|
-
if queue_message.recordType == "ARTIFACT_UPLOAD_REQUEST":
|
|
125
|
-
_ = ArtifactUploadRequest(queue_message.payload.dict())
|