Merge pull request #297 from microsoft/users/tedchamb/test

add test
This commit is contained in:
Ted Chambers 2019-11-23 12:55:47 -05:00 коммит произвёл GitHub
Родитель 52a007a0e3 4d48646403
Коммит 7adf4a94a8
4 изменённых файлов: 58 добавлений и 3 удалений

Просмотреть файл

@ -187,7 +187,7 @@ class Client(object):
try:
logger.debug('File cache hit for options on: %s', url)
self._locations[url] = self._base_deserialize.deserialize_data(OPTIONS_FILE_CACHE[url],
'[ApiResourceLocation]')
'[ApiResourceLocation]')
return self._locations[url]
except DeserializationError as ex:
logger.debug(ex, exc_info=True)

Просмотреть файл

@ -109,8 +109,9 @@ class Connection(object):
if not force and RESOURCE_FILE_CACHE[location_client.normalized_url]:
try:
logger.debug('File cache hit for resources on: %s', location_client.normalized_url)
self._resource_areas = location_client._base_deserialize.deserialize_data(RESOURCE_FILE_CACHE[location_client.normalized_url],
'[ResourceAreaInfo]')
self._resource_areas = location_client._base_deserialize.deserialize_data(
RESOURCE_FILE_CACHE[location_client.normalized_url],
'[ResourceAreaInfo]')
return self._resource_areas
except Exception as ex:
logger.debug(ex, exc_info=True)

Просмотреть файл

@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# Generated file, DO NOT EDIT
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

Просмотреть файл

@ -0,0 +1,47 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import pprint
import unittest
from msrest import Deserializer
from msrest.universal_http import HTTPClientResponse
class _TestResponse(HTTPClientResponse):
def __init__(self, text):
super(_TestResponse, self).__init__(request=None, internal_response=None)
self._text = text
def text(self, encoding=None):
return self._text
class TestDeserialization(unittest.TestCase):
# https://github.com/microsoft/azure-devops-python-api/issues/268
def test_deserialization_issue_268_50(self):
from azure.devops.v5_0.task_agent import models
self._test_deserialization(models.__dict__.items(), _268_type, _268_json)
# https://github.com/microsoft/azure-devops-python-api/issues/268
def test_deserialization_issue_268_51(self):
from azure.devops.v5_1.task_agent import models
self._test_deserialization(models.__dict__.items(), _268_type, _268_json)
@staticmethod
def _test_deserialization(models, data_type, json):
client_models = {k: v for k, v in models if isinstance(v, type)}
deserializer = Deserializer(client_models)
response = _TestResponse(json)
task_agent_response = deserializer(data_type, response)
pprint.pprint(task_agent_response.__dict__)
if __name__ == '__main__':
unittest.main()
_268_type = 'TaskAgentReference'
_268_json = '{"id":0,"name":null,"version":null,"osDescription":"Foo","provisioningState":null}'