Skip to content

add test #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-devops/azure/devops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _get_resource_locations(self, url, all_host_types):
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)
Expand Down
5 changes: 3 additions & 2 deletions azure-devops/azure/devops/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ def _get_resource_areas(self, force=False):
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)
Expand Down
7 changes: 7 additions & 0 deletions azure-devops/azure/devops/issue_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
# --------------------------------------------------------------------------------------------
47 changes: 47 additions & 0 deletions azure-devops/azure/devops/issue_tests/test_issue_268.py
Original file line number Diff line number Diff line change
@@ -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}'