|
| 1 | +# -------------------------------------------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | +# -------------------------------------------------------------------------------------------- |
| 5 | + |
| 6 | +import pprint |
| 7 | +import unittest |
| 8 | + |
| 9 | +from msrest import Deserializer |
| 10 | +from msrest.universal_http import HTTPClientResponse |
| 11 | + |
| 12 | + |
| 13 | +class _TestResponse(HTTPClientResponse): |
| 14 | + def __init__(self, text): |
| 15 | + super(_TestResponse, self).__init__(request=None, internal_response=None) |
| 16 | + self._text = text |
| 17 | + |
| 18 | + def text(self, encoding=None): |
| 19 | + return self._text |
| 20 | + |
| 21 | + |
| 22 | +class TestDeserialization(unittest.TestCase): |
| 23 | + |
| 24 | + # https://github.com/microsoft/azure-devops-python-api/issues/268 |
| 25 | + def test_deserialization_issue_268_50(self): |
| 26 | + from azure.devops.v5_0.task_agent import models |
| 27 | + self._test_deserialization(models.__dict__.items(), _268_type, _268_json) |
| 28 | + |
| 29 | + # https://github.com/microsoft/azure-devops-python-api/issues/268 |
| 30 | + def test_deserialization_issue_268_51(self): |
| 31 | + from azure.devops.v5_1.task_agent import models |
| 32 | + self._test_deserialization(models.__dict__.items(), _268_type, _268_json) |
| 33 | + |
| 34 | + @staticmethod |
| 35 | + def _test_deserialization(models, data_type, json): |
| 36 | + client_models = {k: v for k, v in models if isinstance(v, type)} |
| 37 | + deserializer = Deserializer(client_models) |
| 38 | + response = _TestResponse(json) |
| 39 | + task_agent_response = deserializer(data_type, response) |
| 40 | + pprint.pprint(task_agent_response.__dict__) |
| 41 | + |
| 42 | + |
| 43 | +if __name__ == '__main__': |
| 44 | + unittest.main() |
| 45 | + |
| 46 | +_268_type = 'TaskAgentReference' |
| 47 | +_268_json = '{"id":0,"name":null,"version":null,"osDescription":"Foo","provisioningState":null}' |
0 commit comments