Skip to content

Commit

Permalink
Merge branch 'netcore' of github.com:Azure/AutoRest into netcore
Browse files Browse the repository at this point in the history
  • Loading branch information
Hovsep Mkrtchyan committed May 18, 2016
2 parents 5681eea + 02f34b8 commit 773e9f1
Show file tree
Hide file tree
Showing 196 changed files with 2,088 additions and 1,667 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
from msrest.exceptions import DeserializationError, SerializationError, ClientRequestError
from msrest.authentication import BasicTokenAuthentication

from autorestparameterizedhosttestclient import (
AutoRestParameterizedHostTestClient,
AutoRestParameterizedHostTestClientConfiguration)
from autorestparameterizedhosttestclient import AutoRestParameterizedHostTestClient

from autorestparameterizedhosttestclient.exceptions import ValidationError
from autorestparameterizedhosttestclient.models import Error, ErrorException
Expand All @@ -60,19 +58,13 @@ class CustomBaseUriTests(unittest.TestCase):

def test_custom_base_uri_positive(self):
cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestParameterizedHostTestClientConfiguration(cred, host="host:3000")

config.log_level = log_level
client = AutoRestParameterizedHostTestClient(config)
client = AutoRestParameterizedHostTestClient(cred, host="host:3000")
client.paths.get_empty("local")

def test_custom_base_uri_negative(self):
cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestParameterizedHostTestClientConfiguration(cred, host="host:3000")

config.log_level = log_level
config.retry_policy.retries = 0
client = AutoRestParameterizedHostTestClient(config)
client = AutoRestParameterizedHostTestClient(cred, host="host:3000")
client.config.retry_policy.retries = 0
with self.assertRaises(ClientRequestError):
client.paths.get_empty("bad")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
from msrest.exceptions import DeserializationError
from msrest.authentication import BasicTokenAuthentication

from microsoftazuretesturl import (
MicrosoftAzureTestUrl,
MicrosoftAzureTestUrlConfiguration)
from microsoftazuretesturl import MicrosoftAzureTestUrl

from microsoftazuretesturl.models import ErrorException, SampleResourceGroup

Expand All @@ -62,10 +60,7 @@ def test_azure_url(self):
client_id = str(uuid4())

cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = MicrosoftAzureTestUrlConfiguration(cred, sub_id, base_url="http://localhost:3000")

config.log_level = log_level
client = MicrosoftAzureTestUrl(config)
client = MicrosoftAzureTestUrl(cred, sub_id, base_url="http://localhost:3000")

group = client.group.get_sample_resource_group("testgoup101")
self.assertEqual(group.name, "testgroup101")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,15 @@
from msrest.exceptions import DeserializationError
from msrest.authentication import BasicTokenAuthentication

from autorestdurationtestservice import (
AutoRestDurationTestService,
AutoRestDurationTestServiceConfiguration)
from autorestdurationtestservice import AutoRestDurationTestService


class DurationTests(unittest.TestCase):

def test_duration(self):

cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestDurationTestServiceConfiguration(cred, base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestDurationTestService(config)
client = AutoRestDurationTestService(cred, base_url="http://localhost:3000")

self.assertIsNone(client.duration.get_null())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,15 @@
from msrest.authentication import BasicTokenAuthentication
from msrestazure.azure_exceptions import CloudError, CloudErrorData

from autorestheadtestservice import (
AutoRestHeadTestService,
AutoRestHeadTestServiceConfiguration)

from autorestheadexceptiontestservice import (
AutoRestHeadExceptionTestService,
AutoRestHeadExceptionTestServiceConfiguration)
from autorestheadtestservice import AutoRestHeadTestService
from autorestheadexceptiontestservice import AutoRestHeadExceptionTestService

class HeadTests(unittest.TestCase):

def test_head(self):

cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestHeadTestServiceConfiguration(cred, base_url="http://localhost:3000")

config.log_level = log_level
client = AutoRestHeadTestService(config)
client = AutoRestHeadTestService(cred, base_url="http://localhost:3000")

self.assertTrue(client.http_success.head200())
self.assertTrue(client.http_success.head204())
Expand All @@ -77,10 +69,7 @@ class HeadExceptionTest(unittest.TestCase):
def test_head_exception(self):

cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestHeadExceptionTestServiceConfiguration(cred, base_url="http://localhost:3000")

config.log_level = log_level
client = AutoRestHeadExceptionTestService(config)
client = AutoRestHeadExceptionTestService(cred, base_url="http://localhost:3000")

client.head_exception.head200()
client.head_exception.head204()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,15 @@
from msrest.authentication import BasicTokenAuthentication
from msrestazure.azure_exceptions import CloudError, CloudErrorData

from autorestlongrunningoperationtestservice import (
AutoRestLongRunningOperationTestService,
AutoRestLongRunningOperationTestServiceConfiguration)

from autorestlongrunningoperationtestservice import AutoRestLongRunningOperationTestService
from autorestlongrunningoperationtestservice.models import *

class LroTests(unittest.TestCase):

def setUp(self):

cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestLongRunningOperationTestServiceConfiguration(cred, base_url="http://localhost:3000")

config.log_level = log_level
self.client = AutoRestLongRunningOperationTestService(config)
self.client = AutoRestLongRunningOperationTestService(cred, base_url="http://localhost:3000")

self.client.config.long_running_operation_timeout = 0
self.client._client._adapter.add_hook("request", self.client._client._adapter._test_pipeline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,14 @@
from msrestazure.azure_exceptions import CloudError
from msrest.authentication import BasicTokenAuthentication

from autorestpagingtestservice import (
AutoRestPagingTestService,
AutoRestPagingTestServiceConfiguration)
from autorestpagingtestservice import AutoRestPagingTestService
from autorestpagingtestservice.models import PagingGetMultiplePagesWithOffsetOptions

class PagingTests(unittest.TestCase):

def setUp(self):
cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestPagingTestServiceConfiguration(cred, base_url="http://localhost:3000")
config.log_level = log_level
self.client = AutoRestPagingTestService(config)
self.client = AutoRestPagingTestService(cred, base_url="http://localhost:3000")
self.client._client._adapter.add_hook("request", self.client._client._adapter._test_pipeline)
return super(PagingTests, self).setUp()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@
sys.path.append(join(tests, "AzureSpecials"))
from msrest.exceptions import DeserializationError

from autorestparametergroupingtestservice import AutoRestParameterGroupingTestServiceConfiguration, AutoRestParameterGroupingTestService
from microsoftazuretesturl import MicrosoftAzureTestUrl, MicrosoftAzureTestUrlConfiguration
from autorestdurationtestservice import AutoRestDurationTestService, AutoRestDurationTestServiceConfiguration
from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient, AutoRestAzureSpecialParametersTestClientConfiguration
from autorestparametergroupingtestservice import AutoRestParameterGroupingTestService
from microsoftazuretesturl import MicrosoftAzureTestUrl
from autorestdurationtestservice import AutoRestDurationTestService
from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient

from autorestparameterizedhosttestclient.exceptions import ValidationError
from autorestparametergroupingtestservice.models import ParameterGroupingPostMultiParamGroupsSecondParamGroup, ParameterGroupingPostOptionalParameters, ParameterGroupingPostRequiredParameters, FirstParameterGroup
from autorestparametergroupingtestservice.models import (
ParameterGroupingPostMultiParamGroupsSecondParamGroup,
ParameterGroupingPostOptionalParameters,
ParameterGroupingPostRequiredParameters,
FirstParameterGroup)

from msrest.authentication import BasicTokenAuthentication

Expand All @@ -71,9 +75,7 @@ def test_parameter_grouping(self):
pathParameter = 'path'

cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestParameterGroupingTestServiceConfiguration(cred, base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestParameterGroupingTestService(config)
client = AutoRestParameterGroupingTestService(cred, base_url="http://localhost:3000")

# Valid required parameters
requiredParameters = ParameterGroupingPostRequiredParameters(body=bodyParameter, path=pathParameter, custom_header=headerParameter, query=queryParameter)
Expand Down Expand Up @@ -118,9 +120,7 @@ def test_azure_special_parameters(self):
unencodedPath = 'path1/path2/path3'
unencodedQuery = 'value1&q2=value2&q3=value3'
cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestAzureSpecialParametersTestClient(config)
client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000")

client.subscription_in_credentials.post_method_global_not_provided_valid()
client.subscription_in_credentials.post_method_global_valid()
Expand Down Expand Up @@ -154,9 +154,7 @@ def test_azure_odata(self):

validSubscription = '1234-5678-9012-3456'
cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestAzureSpecialParametersTestClient(config)
client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000")
client.odata.get_with_filter(filter="id gt 5 and name eq 'foo'", top=10, orderby="id")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from msrest.authentication import BasicTokenAuthentication
from msrestazure.azure_exceptions import CloudError, CloudErrorData

from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient, AutoRestAzureSpecialParametersTestClientConfiguration
from autorestazurespecialparameterstestclient import AutoRestAzureSpecialParametersTestClient


class XmsRequestClientIdTests(unittest.TestCase):
Expand All @@ -60,9 +60,7 @@ def test_xms_request_client_id(self):
validClientId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

cred = BasicTokenAuthentication({"access_token":123})
config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestAzureSpecialParametersTestClient(config)
client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000")

custom_headers = {"x-ms-client-request-id": validClientId }

Expand All @@ -79,9 +77,7 @@ def test_custom_named_request_id(self):
expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

cred = BasicTokenAuthentication({"access_token":123})
config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestAzureSpecialParametersTestClient(config)
client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000")

response = client.header.custom_named_request_id(expectedRequestId, raw=True)
self.assertEqual("123", response.response.headers.get("foo-request-id"))
Expand All @@ -91,9 +87,7 @@ def test_client_request_id_in_exception(self):
expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

cred = BasicTokenAuthentication({"access_token":123})
config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestAzureSpecialParametersTestClient(config)
client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000")

try:
client.xms_client_request_id.get()
Expand All @@ -107,10 +101,8 @@ def test_xms_request_client_id_in_client(self):
expectedRequestId = '9C4D50EE-2D56-4CD3-8152-34347DC9F2B0'

cred = BasicTokenAuthentication({"access_token":123})
config = AutoRestAzureSpecialParametersTestClientConfiguration(cred, validSubscription, base_url="http://localhost:3000")
config.log_level = log_level
config.generate_client_request_id = False
client = AutoRestAzureSpecialParametersTestClient(config)
client = AutoRestAzureSpecialParametersTestClient(cred, validSubscription, base_url="http://localhost:3000")
client.config.generate_client_request_id = False
client.xms_client_request_id.get()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

from msrest.exceptions import DeserializationError

from autorestreportserviceforazure import AutoRestReportServiceForAzureConfiguration, AutoRestReportServiceForAzure
from autorestreportserviceforazure import AutoRestReportServiceForAzure
from msrest.authentication import BasicTokenAuthentication


Expand All @@ -57,9 +57,7 @@ class AcceptanceTests(unittest.TestCase):
def test_ensure_coverage(self):

cred = BasicTokenAuthentication({"access_token" :str(uuid4())})
config = AutoRestReportServiceForAzureConfiguration(cred, base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestReportServiceForAzure(config)
client = AutoRestReportServiceForAzure(cred, base_url="http://localhost:3000")
report = client.get_report()

skipped = [k for k, v in report.items() if v == 0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
# regenerated.
# --------------------------------------------------------------------------

from .auto_rest_duration_test_service import AutoRestDurationTestService, AutoRestDurationTestServiceConfiguration
from .auto_rest_duration_test_service import AutoRestDurationTestService
from .version import VERSION

__all__ = [
'AutoRestDurationTestService',
'AutoRestDurationTestServiceConfiguration'
]
__all__ = ['AutoRestDurationTestService']

__version__ = VERSION

Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,38 @@ def __init__(
class AutoRestDurationTestService(object):
"""Test Infrastructure for AutoRest
:param config: Configuration for client.
:type config: AutoRestDurationTestServiceConfiguration
:ivar config: Configuration for client.
:vartype config: AutoRestDurationTestServiceConfiguration
:ivar duration: Duration operations
:vartype duration: .operations.DurationOperations
:param credentials: Gets Azure subscription credentials.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param accept_language: Gets or sets the preferred language for the
response.
:type accept_language: str
:param long_running_operation_retry_timeout: Gets or sets the retry
timeout in seconds for Long Running Operations. Default value is 30.
:type long_running_operation_retry_timeout: int
:param generate_client_request_id: When set to true a unique
x-ms-client-request-id value is generated and included in each request.
Default is true.
:type generate_client_request_id: bool
:param str base_url: Service URL
:param str filepath: Existing config
"""

def __init__(self, config):
def __init__(
self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None):

self._client = ServiceClient(config.credentials, config)
self.config = AutoRestDurationTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath)
self._client = ServiceClient(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer()
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.config = config
self.duration = DurationOperations(
self._client, self.config, self._serialize, self._deserialize)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer):
self.config = config

def get_null(
self, custom_headers={}, raw=False, **operation_config):
self, custom_headers=None, raw=False, **operation_config):
"""
Get null duration value
Expand Down Expand Up @@ -81,7 +81,7 @@ def get_null(
return deserialized

def put_positive_duration(
self, duration_body, custom_headers={}, raw=False, **operation_config):
self, duration_body, custom_headers=None, raw=False, **operation_config):
"""
Put a positive duration value
Expand Down Expand Up @@ -128,7 +128,7 @@ def put_positive_duration(
return client_raw_response

def get_positive_duration(
self, custom_headers={}, raw=False, **operation_config):
self, custom_headers=None, raw=False, **operation_config):
"""
Get a positive duration value
Expand Down Expand Up @@ -176,7 +176,7 @@ def get_positive_duration(
return deserialized

def get_invalid(
self, custom_headers={}, raw=False, **operation_config):
self, custom_headers=None, raw=False, **operation_config):
"""
Get an invalid duration value
Expand Down
Loading

0 comments on commit 773e9f1

Please sign in to comment.