Skip to content

Commit

Permalink
Removed config objects from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
annatisch committed May 17, 2016
1 parent 42219a6 commit 64e0b96
Show file tree
Hide file tree
Showing 31 changed files with 99 additions and 276 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 @@ -45,20 +45,14 @@
from msrest.serialization import Deserializer
from msrest.exceptions import DeserializationError

from autorestswaggerbatarrayservice import (
AutoRestSwaggerBATArrayService,
AutoRestSwaggerBATArrayServiceConfiguration)

from autorestswaggerbatarrayservice import AutoRestSwaggerBATArrayService
from autorestswaggerbatarrayservice.models import Product


class ArrayTests(unittest.TestCase):

def test_array(self):

config = AutoRestSwaggerBATArrayServiceConfiguration(base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestSwaggerBATArrayService(config)
client = AutoRestSwaggerBATArrayService(base_url="http://localhost:3000")

self.assertListEqual([], client.array.get_empty())
self.assertIsNone(client.array.get_null())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,13 @@
from msrest.serialization import Deserializer
from msrest.exceptions import DeserializationError

from autorestbooltestservice import (
AutoRestBoolTestService,
AutoRestBoolTestServiceConfiguration)

from autorestbooltestservice import AutoRestBoolTestService
from autorestbooltestservice.models import ErrorException

class BoolTests(unittest.TestCase):

def test_bool(self):

config = AutoRestBoolTestServiceConfiguration(base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestBoolTestService(config)
client = AutoRestBoolTestService(base_url="http://localhost:3000")

self.assertTrue(client.bool_model.get_true())
self.assertFalse(client.bool_model.get_false())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,13 @@
from msrest.serialization import Deserializer
from msrest.exceptions import DeserializationError

from autorestswaggerbatbyteservice import (
AutoRestSwaggerBATByteService,
AutoRestSwaggerBATByteServiceConfiguration)
from autorestswaggerbatbyteservice import AutoRestSwaggerBATByteService


class ByteTests(unittest.TestCase):

def test_byte(self):

config = AutoRestSwaggerBATByteServiceConfiguration(base_url="http://localhost:3000")
config.log_level = log_level
client = AutoRestSwaggerBATByteService(config)
client = AutoRestSwaggerBATByteService(base_url="http://localhost:3000")

test_bytes = bytearray([0x0FF, 0x0FE, 0x0FD, 0x0FC, 0x0FB, 0x0FA, 0x0F9, 0x0F8, 0x0F7, 0x0F6])
client.byte.put_non_ascii(test_bytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
from msrest.serialization import Deserializer
from msrest.exceptions import DeserializationError, SerializationError, ValidationError

from autorestcomplextestservice import (
AutoRestComplexTestService,
AutoRestComplexTestServiceConfiguration)

from autorestcomplextestservice import AutoRestComplexTestService
from autorestcomplextestservice.models import *

class UTC(tzinfo):
Expand All @@ -65,10 +62,7 @@ def dst(self,dt):
class ComplexTests(unittest.TestCase):

def test_complex(self):

config = AutoRestComplexTestServiceConfiguration(base_url="http://localhost:3000",api_version="2015-01-01")
config.log_level = log_level
client = AutoRestComplexTestService(config)
client = AutoRestComplexTestService(base_url="http://localhost:3000",api_version="2015-01-01")

# GET basic/valid
basic_result = client.basic_operations.get_valid()
Expand Down
Loading

0 comments on commit 64e0b96

Please sign in to comment.