From 7f99bccc584b1f7faaebb9ea930d5a5c1c707cdf Mon Sep 17 00:00:00 2001 From: Phellippe Lima Date: Thu, 23 May 2024 12:11:49 +0100 Subject: [PATCH] CP-2063 - test examples --- streaming/test/test_streaming_api.py | 321 --------------------------- 1 file changed, 321 deletions(-) delete mode 100644 streaming/test/test_streaming_api.py diff --git a/streaming/test/test_streaming_api.py b/streaming/test/test_streaming_api.py deleted file mode 100644 index 418cd8f4..00000000 --- a/streaming/test/test_streaming_api.py +++ /dev/null @@ -1,321 +0,0 @@ -# coding: utf-8 - -""" - ThousandEyes for OpenTelemetry API - - ThousandEyes for OpenTelemetry provides machine-to-machine integration between ThousandEyes and its customers. It allows you to export ThousandEyes telemetry data in OTel format, which is widely used in the industry. With ThousandEyes for OTel, you can leverage frameworks widely used in the observability domain - such as Splunk, Grafana, and Honeycomb - to capture and analyze ThousandEyes data. Any client that supports OTel can use ThousandEyes for OpenTelemetry. ThousandEyes for OTel is made up of the following components: * Data streaming APIs that you can use to configure and enable your ThousandEyes tests with OTel-compatible streams, in particular to configure how ThousandEyes telemetry data is exported to client integrations. * A set of streaming pipelines called _collectors_ that actively fetch ThousandEyes network test data, enrich the data with some additional detail, filter, and push the data to the customer-configured endpoints, depending on what you configure via the public APIs. * Third-party OTel collectors that receive, transform, filter, and export different metrics to client applications such as AppD, or any other OTel-capable client configuration. For more information about ThousandEyes for OpenTelemetry, see the [documentation](https://docs.thousandeyes.com/product-documentation/api/opentelemetry). - - The version of the OpenAPI document: 7.0.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import json -import unittest -import streaming.models - -from streaming.api.streaming_api import StreamingApi -from pydantic import BaseModel - - -class TestStreamingApi(unittest.TestCase): - """StreamingApi unit test stubs""" - - def setUp(self) -> None: - self.api = StreamingApi() - - def tearDown(self) -> None: - pass - - def test_create_stream_models_validation(self) -> None: - """Test case for create_stream request a nd response models""" - request_body_json = """ - { - "endpointType" : "grpc", - "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", - "tagMatch" : [ { - "objectType" : "test", - "key" : "keyA", - "value" : "valueA" - }, { - "objectType" : "test", - "key" : "keyB", - "value" : "valueB" - } ], - "type" : "opentelemetry", - "customHeaders" : { - "Authorization" : "*****", - "Content-Type" : "*****" - }, - "enabled" : true - }""" - - request_loaded_json = json.loads(request_body_json) - request_from_constructor = streaming.models.Stream(**request_loaded_json) - self.recursive_assert_no_extra_fields(request_from_constructor) - - request_from_json = streaming.models.Stream.from_json(request_body_json) - self.assertIsNotNone(request_from_json) - self.assertCountEqual(request_from_constructor.model_fields_set, - request_from_json.model_fields_set, - "Request model from constructor fields do not match model from json fields") - - response_body_json = """ - { - "endpointType" : "grpc", - "_links" : { - "self" : { - "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" - } - }, - "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", - "tagMatch" : [ { - "objectType" : "test", - "key" : "keyA", - "value" : "valueA" - }, { - "objectType" : "test", - "key" : "keyB", - "value" : "valueB" - } ], - "id" : "342ieu09", - "type" : "opentelemetry", - "auditOperation" : { - "createdDate" : 1679677853573, - "createdBy" : 3962 - }, - "enabled" : true, - "customHeaders" : { - "Authorization" : "*****", - "Content-Type" : "*****" - } - }""" - - response_loaded_json = json.loads(response_body_json) - response_from_constructor = streaming.models.CreateStreamResponse(**response_loaded_json) - self.recursive_assert_no_extra_fields(response_from_constructor) - - response_from_json = streaming.models.CreateStreamResponse.from_json(response_body_json) - self.assertIsNotNone(response_from_json) - self.assertCountEqual(response_from_constructor.model_fields_set, - response_from_json.model_fields_set, - "Response model from constructor fields do not match model from json fields") - - def test_delete_stream_models_validation(self) -> None: - """Test case for delete_stream request a nd response models""" - - - def test_get_stream_models_validation(self) -> None: - """Test case for get_stream request a nd response models""" - - response_body_json = """ - { - "endpointType" : "grpc", - "_links" : { - "self" : { - "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" - } - }, - "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", - "tagMatch" : [ { - "objectType" : "test", - "key" : "keyA", - "value" : "valueA" - }, { - "objectType" : "test", - "key" : "keyB", - "value" : "valueB" - } ], - "id" : "342ieu09", - "type" : "opentelemetry", - "auditOperation" : { - "createdDate" : 1679677853573, - "updatedBy" : 3962, - "createdBy" : 3962, - "updatedDate" : 1679677853573 - }, - "enabled" : true, - "customHeaders" : { - "Authorization" : "*****", - "Content-Type" : "*****" - } - }""" - - response_loaded_json = json.loads(response_body_json) - response_from_constructor = streaming.models.GetStreamResponse(**response_loaded_json) - self.recursive_assert_no_extra_fields(response_from_constructor) - - response_from_json = streaming.models.GetStreamResponse.from_json(response_body_json) - self.assertIsNotNone(response_from_json) - self.assertCountEqual(response_from_constructor.model_fields_set, - response_from_json.model_fields_set, - "Response model from constructor fields do not match model from json fields") - - def test_get_streams_models_validation(self) -> None: - """Test case for get_streams request a nd response models""" - - response_body_json = """ - [ { - "endpointType" : "grpc", - "_links" : { - "self" : { - "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" - } - }, - "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", - "tagMatch" : [ { - "objectType" : "test", - "key" : "keyA", - "value" : "valueA" - }, { - "objectType" : "test", - "key" : "keyB", - "value" : "valueB" - } ], - "id" : "342ieu09", - "type" : "opentelemetry", - "auditOperation" : { - "createdDate" : 1679677853573, - "updatedBy" : 3962, - "createdBy" : 3962, - "updatedDate" : 1679677853573 - }, - "enabled" : true, - "customHeaders" : { - "Authorization" : "*****", - "Content-Type" : "*****" - } - }, { - "endpointType" : "grpc", - "_links" : { - "self" : { - "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" - } - }, - "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", - "tagMatch" : [ { - "objectType" : "test", - "key" : "keyA", - "value" : "valueA" - }, { - "objectType" : "test", - "key" : "keyB", - "value" : "valueB" - } ], - "id" : "342ieu09", - "type" : "opentelemetry", - "auditOperation" : { - "createdDate" : 1679677853573, - "updatedBy" : 3962, - "createdBy" : 3962, - "updatedDate" : 1679677853573 - }, - "enabled" : true, - "customHeaders" : { - "Authorization" : "*****", - "Content-Type" : "*****" - } - } ]""" - - response_loaded_json = json.loads(response_body_json) - response_from_constructor = [streaming.models.GetStreamResponse(**value) for value in response_loaded_json] - for element in response_from_constructor: - self.recursive_assert_no_extra_fields(element) - - response_from_dict = [streaming.models.GetStreamResponse.from_dict(value) for value in response_loaded_json] - self.assertCountEqual(response_from_constructor, response_from_dict) - for index, element in enumerate(response_from_dict): - self.assertIsNotNone(element) - self.assertCountEqual(response_from_constructor[index], element, - "Response model from constructor fields do not match model from json fields") - - def test_put_stream_models_validation(self) -> None: - """Test case for put_stream request a nd response models""" - request_body_json = """ - { - "tagMatch" : [ { - "objectType" : "test", - "key" : "keyA", - "value" : "valueA" - }, { - "objectType" : "test", - "key" : "keyB", - "value" : "valueB" - } ], - "customHeaders" : { - "Authorization" : "*****", - "Content-Type" : "*****" - }, - "enabled" : true - }""" - - request_loaded_json = json.loads(request_body_json) - request_from_constructor = streaming.models.PutStream(**request_loaded_json) - self.recursive_assert_no_extra_fields(request_from_constructor) - - request_from_json = streaming.models.PutStream.from_json(request_body_json) - self.assertIsNotNone(request_from_json) - self.assertCountEqual(request_from_constructor.model_fields_set, - request_from_json.model_fields_set, - "Request model from constructor fields do not match model from json fields") - - response_body_json = """ - { - "endpointType" : "grpc", - "_links" : { - "self" : { - "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" - } - }, - "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", - "tagMatch" : [ { - "objectType" : "test", - "key" : "keyA", - "value" : "valueA" - }, { - "objectType" : "test", - "key" : "keyB", - "value" : "valueB" - } ], - "id" : "342ieu09", - "type" : "opentelemetry", - "auditOperation" : { - "createdDate" : 1679677853573, - "updatedBy" : 3962, - "createdBy" : 3962, - "updatedDate" : 1679677853573 - }, - "enabled" : true, - "customHeaders" : { - "Authorization" : "*****", - "Content-Type" : "*****" - } - }""" - - response_loaded_json = json.loads(response_body_json) - response_from_constructor = streaming.models.GetStreamResponse(**response_loaded_json) - self.recursive_assert_no_extra_fields(response_from_constructor) - - response_from_json = streaming.models.GetStreamResponse.from_json(response_body_json) - self.assertIsNotNone(response_from_json) - self.assertCountEqual(response_from_constructor.model_fields_set, - response_from_json.model_fields_set, - "Response model from constructor fields do not match model from json fields") - - def recursive_assert_no_extra_fields(self, model: BaseModel): - self.assertIsNotNone(model) - self.assertGreater(model.model_fields_set.__len__(), 0) - self.assertEquals(model.model_extra.__len__(), 0, - 'model {0}.{1} has unmapped extra fields {2}' - .format(model.__class__.__module__, model.__class__.__name__, - model.model_extra)) - for f in model.model_fields_set: - field = model.__dict__.get(f) - if isinstance(field, BaseModel): - self.recursive_assert_no_extra_fields(field) - - -if __name__ == '__main__': - unittest.main()