Skip to content
This repository was archived by the owner on May 22, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4def7dc
ensure version tolerant is executed last in release checks, add dpg t…
iscai-msft Feb 11, 2022
0f6e2ec
update coverage test files
iscai-msft Feb 11, 2022
87d117b
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Feb 11, 2022
ef5c352
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python…
iscai-msft Feb 24, 2022
147ae4c
add some dpg tests
iscai-msft Feb 24, 2022
c2d79fe
don't install report
iscai-msft Feb 24, 2022
0ba3ce1
add flag appendcoverage, bump testserver dep
iscai-msft Feb 24, 2022
6f51fde
upgrade node check and bump testserver
iscai-msft Feb 24, 2022
aad6602
only publish for 3.10 run
iscai-msft Feb 24, 2022
d65de77
skip some vanilla features for now
iscai-msft Feb 24, 2022
3e8af46
skip more dpg tests
iscai-msft Feb 24, 2022
b5bb2c7
skip regenerating
iscai-msft Feb 24, 2022
ee73d2f
bump testserver version
iscai-msft Feb 24, 2022
c207dff
add coverage to gitignore
iscai-msft Feb 24, 2022
3e4178f
bump testserver version to 3.3.3
iscai-msft Feb 24, 2022
f61ec15
update multiapi to use appendcoverage
iscai-msft Feb 24, 2022
69dbcef
add passenv to dpg tox, cat dpg report
iscai-msft Feb 25, 2022
4ef9bda
don't fail on missed optional tests
iscai-msft Feb 25, 2022
8b1c751
fix multiapi node module initialization
iscai-msft Feb 25, 2022
c8dd20f
add new media types tests
iscai-msft Feb 25, 2022
237dd11
fix media types tests
iscai-msft Feb 25, 2022
3226ebf
add back regeneration and remove logging
iscai-msft Feb 25, 2022
ac2518f
remove report low level generation
iscai-msft Feb 25, 2022
1467aab
fix for 2.7
iscai-msft Feb 25, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ wheels/
MANIFEST
package.json
package-lock.json
coverage/

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pr:
- autorestv3

variables:
NodeVersion: "12.x"
NodeVersion: "14.x"
PythonVersion: "3.7"
TestFolder: "$(Build.SourcesDirectory)/test/"
AUTOREST_TESTSERVER_COVERAGE_DIRECTORY: "$(Build.SourcesDirectory)/coverage/"
Expand Down Expand Up @@ -62,7 +62,6 @@ jobs:
npm install -g autorest
npm install
displayName: 'Prepare Environment for Generation'

- script: |
pylint autorest
displayName: 'Pylint'
Expand Down Expand Up @@ -207,6 +206,7 @@ jobs:
npm run coverage -- publish --repo=$(Build.Repository.Name) --ref=$(Build.SourceBranch) --githubToken=$(github-token) --azStorageAccount=$(storage-coverage-user) --azStorageAccessKey=$(storage-coverage-pass) --coverageDirectory=$(AUTOREST_TESTSERVER_COVERAGE_DIRECTORY)
workingDirectory: node_modules/@microsoft.azure/autorest.testserver
displayName: "Publish coverage report to storage account"
condition: and(succeededOrFailed(), eq(variables['PythonVersion'], '3.10'))

- ${{ if eq(and(ne(variables['Build.Reason'], 'PullRequest'), ne(variables['PythonVersion'], '2.7')), 'True') }}:
- script: |
Expand Down
32 changes: 21 additions & 11 deletions eng/pipelines/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,41 @@ steps:
cd $(TestFolder)/azure/legacy
tox -e ci
displayName: 'Execute legacy "azure" Tests - Python $(PythonVersion)'

- script: |
cd $(TestFolder)/azure/version-tolerant
tox -e ci
displayName: 'Execute version tolerant "azure" Tests - Python $(PythonVersion)'


- script: |
cd $(TestFolder)/azure/low-level
tox -e ci
displayName: 'Execute low level "azure" Tests - Python $(PythonVersion)'


- script: |
cd $(TestFolder)/azure/version-tolerant
tox -e ci
displayName: 'Execute version tolerant "azure" Tests - Python $(PythonVersion)'

- script: |
cd $(TestFolder)/vanilla/legacy
tox -e ci
displayName: 'Execute legacy "vanilla" Tests - Python $(PythonVersion)'


- script: |
cd $(TestFolder)/vanilla/low-level
tox -e ci
displayName: 'Execute low level "vanilla" Tests - Python $(PythonVersion)'

- script: |
cd $(TestFolder)/vanilla/version-tolerant
tox -e ci
displayName: 'Execute version tolerant "vanilla" Tests - Python $(PythonVersion)'

- script: |
cd $(TestFolder)/vanilla/low-level
cd $(TestFolder)/dpg/low-level
tox -e ci
displayName: 'Execute low level "vanilla" Tests - Python $(PythonVersion)'
displayName: 'Execute low level "dpg" Tests - Python $(PythonVersion)'

- script: |
cd $(TestFolder)/dpg/version-tolerant
tox -e ci
displayName: 'Execute version tolerant "dpg" Tests - Python $(PythonVersion)'

- script: |
export RELEASE_VERSION=$(node -p -e "require('./package.json').version")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@azure-tools/extension": "~3.2.1"
},
"devDependencies": {
"@microsoft.azure/autorest.testserver": "^3.2.0"
"@microsoft.azure/autorest.testserver": "^3.3.5"
},
"files": [
"autorest/**/*.py",
Expand Down
2 changes: 1 addition & 1 deletion test/azure/legacy/AcceptanceTests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#Ideally this would be in a common helper library shared between the tests
def start_server_process():
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd)
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver/dist/cli/cli.js run --appendCoverage".format(cwd)
if os.name == 'nt': #On windows, subprocess creation works without being in the shell
return subprocess.Popen(cmd)

Expand Down
8 changes: 4 additions & 4 deletions test/azure/legacy/AcceptanceTests/test_zzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def test_ensure_coverage(self):
report = client.get_report(platform.python_version())

# Add tests that wont be supported due to the nature of Python here
not_supported = {}

# Please add missing features or failing tests here
missing_features_or_bugs = {
not_supported = {
"LROPatchInlineCompleteIgnoreHeaders": 1,
}

# Please add missing features or failing tests here
missing_features_or_bugs = {}

print("Coverage:")
self._print_report(report, not_supported, missing_features_or_bugs)

Expand Down
2 changes: 1 addition & 1 deletion test/azure/low-level/AcceptanceTests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#Ideally this would be in a common helper library shared between the tests
def start_server_process():
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd)
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver/dist/cli/cli.js run --appendCoverage".format(cwd)
if os.name == 'nt': #On windows, subprocess creation works without being in the shell
return subprocess.Popen(cmd)

Expand Down
16 changes: 16 additions & 0 deletions test/azure/low-level/coverage/report-dpg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"GetRawModel": 0,
"GetHandwrittenModel": 0,
"PostRawModel": 0,
"PostHandwrittenModel": 0,
"GetRawPages": 0,
"GetHandwrittenModelPages": 0,
"RawLRO": 0,
"HandwrittenModelLRO": 0,
"DPGAddOptionalInput": 8,
"DPGNewBodyType.JSON": 0,
"DPGNewBodyType.JPEG": 0,
"DPGNewBodyType": 0,
"DPGAddNewOperation": 0,
"DPGAddNewPath": 0
}
2 changes: 1 addition & 1 deletion test/azure/version-tolerant/AcceptanceTests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#Ideally this would be in a common helper library shared between the tests
def start_server_process():
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd)
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver/dist/cli/cli.js run --appendCoverage".format(cwd)
if os.name == 'nt': #On windows, subprocess creation works without being in the shell
return subprocess.Popen(cmd)

Expand Down
8 changes: 4 additions & 4 deletions test/azure/version-tolerant/AcceptanceTests/test_zzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def test_ensure_coverage(self):
report = client.get_report(qualifier=platform.python_version())

# Add tests that wont be supported due to the nature of Python here
not_supported = {}

# Please add missing features or failing tests here
missing_features_or_bugs = {
not_supported = {
"LROPatchInlineCompleteIgnoreHeaders": 1,
"PagingDuplicateParameters": 1 # skipping for now, going to do another PR soon changing paging behavior for version tolerant
}

# Please add missing features or failing tests here
missing_features_or_bugs = {}

print("Coverage:")
self._print_report(report, not_supported, missing_features_or_bugs)

Expand Down
2 changes: 1 addition & 1 deletion test/dpg/low-level/AcceptanceTests/asynctests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#Ideally this would be in a common helper library shared between the tests
def start_server_process():
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd)
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver/dist/cli/cli.js run --appendCoverage".format(cwd)
if os.name == 'nt': #On windows, subprocess creation works without being in the shell
return subprocess.Popen(cmd)

Expand Down
2 changes: 1 addition & 1 deletion test/dpg/low-level/AcceptanceTests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#Ideally this would be in a common helper library shared between the tests
def start_server_process():
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd)
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver/dist/cli/cli.js run --appendCoverage".format(cwd)
if os.name == 'nt': #On windows, subprocess creation works without being in the shell
return subprocess.Popen(cmd)

Expand Down
1 change: 1 addition & 0 deletions test/dpg/low-level/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ envlist=py36, py310
skipsdist=True

[testenv:ci]
passenv=*
deps=
-rrequirements.txt
commands =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,21 @@ async def test_add_optional_parameter(initial_client, update_one_client):
parameter="foo",
new_parameter="bar",
)

@pytest.mark.asyncio
async def test_add_new_content_type(initial_client, update_one_client):
await initial_client.params.post_parameters({ "url": "http://example.org/myimage.jpeg" })
await update_one_client.params.post_parameters({ "url": "http://example.org/myimage.jpeg" })
await update_one_client.params.post_parameters(b"hello", content_type="image/jpeg")

@pytest.mark.asyncio
async def test_add_new_operation(initial_client, update_one_client):
with pytest.raises(AttributeError):
await initial_client.params.delete_parameters()
await update_one_client.params.delete_parameters()

@pytest.mark.asyncio
async def test_add_new_path(initial_client, update_one_client):
with pytest.raises(AttributeError):
await initial_client.params.get_new_operation()
assert await update_one_client.params.get_new_operation() == {'message': 'An object was successfully returned'}
2 changes: 1 addition & 1 deletion test/dpg/version-tolerant/AcceptanceTests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#Ideally this would be in a common helper library shared between the tests
def start_server_process():
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd)
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver/dist/cli/cli.js run --appendCoverage".format(cwd)
if os.name == 'nt': #On windows, subprocess creation works without being in the shell
return subprocess.Popen(cmd)

Expand Down
15 changes: 15 additions & 0 deletions test/dpg/version-tolerant/AcceptanceTests/test_service_driven.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,18 @@ def test_add_optional_parameter(initial_client, update_one_client):
parameter="foo",
new_parameter="bar",
)

def test_add_new_content_type(initial_client, update_one_client):
initial_client.params.post_parameters({ "url": "http://example.org/myimage.jpeg" })
update_one_client.params.post_parameters({ "url": "http://example.org/myimage.jpeg" })
update_one_client.params.post_parameters(b"hello", content_type="image/jpeg")

def test_add_new_operation(initial_client, update_one_client):
with pytest.raises(AttributeError):
initial_client.params.delete_parameters()
update_one_client.params.delete_parameters()

def test_add_new_path(initial_client, update_one_client):
with pytest.raises(AttributeError):
initial_client.params.get_new_operation()
assert update_one_client.params.get_new_operation() == {'message': 'An object was successfully returned'}
80 changes: 80 additions & 0 deletions test/dpg/version-tolerant/AcceptanceTests/test_zzz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# --------------------------------------------------------------------------
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------
import platform
import warnings
from azure.core.rest import HttpRequest

from dpgservicedriveninitialversiontolerant import DPGClient




class TestAcceptance(object):

def test_ensure_coverage(self):
client = DPGClient()
request = HttpRequest("GET", "http://localhost:3000/report/dpg", params={"qualifier": platform.python_version()})
response = client.send_request(request)
response.raise_for_status()
support_dict = response.json()
# Add tests that wont be supported due to the nature of Python here
not_supported = {
}

# Please add missing features or failing tests here
missing_features_or_bugs = {
'DPGAddOptionalInput_NoParams': 1,
'DPGAddOptionalInput_RequiredOptionalParam': 1,
'DPGAddOptionalInput_OptionalParam': 1,
'DPGGlassBreaker': 1,
}
for name in support_dict:
if "DPG" not in name:
# this folder only does dpg
missing_features_or_bugs[name] = 1

print("Coverage:")
self._print_report(support_dict, not_supported, missing_features_or_bugs)

def _print_report(self, report, not_supported=None, missing_features_or_bugs=None):
if not_supported:
report.update(not_supported)
for s in not_supported.keys():
print("IGNORING {0}".format(s))

if missing_features_or_bugs:
report.update(missing_features_or_bugs)
for s in missing_features_or_bugs.keys():
print("PENDING {0}".format(s))

failed = [k for k, v in report.items() if v == 0]
for s in failed:
print("FAILED TO EXECUTE {0}".format(s))

total_tests = len(report)
warnings.warn ("The test coverage is {0}/{1}.".format(total_tests - len(failed), total_tests))

assert 0 == len(failed)
16 changes: 16 additions & 0 deletions test/dpg/version-tolerant/coverage/report-dpg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"GetRawModel": 0,
"GetHandwrittenModel": 0,
"PostRawModel": 0,
"PostHandwrittenModel": 0,
"GetRawPages": 0,
"GetHandwrittenModelPages": 0,
"RawLRO": 0,
"HandwrittenModelLRO": 0,
"DPGAddOptionalInput": 4,
"DPGNewBodyType.JSON": 4,
"DPGNewBodyType.JPEG": 2,
"DPGNewBodyType": 6,
"DPGAddNewOperation": 2,
"DPGAddNewPath": 2
}
1 change: 1 addition & 0 deletions test/dpg/version-tolerant/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ commands =
python ../../../eng/scripts/run_pylint.py -t dpg -g version-tolerant

[testenv:ci]
passenv=*
deps=
-rrequirements.txt
commands =
Expand Down
2 changes: 1 addition & 1 deletion test/multiapi/AcceptanceTests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#Ideally this would be in a common helper library shared between the tests
def start_server_process():
cmd = "node {}/../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd)
cmd = "node {}/../../../node_modules/@microsoft.azure/autorest.testserver/dist/cli/cli.js run --appendCoverage".format(cwd)
if os.name == 'nt': #On windows, subprocess creation works without being in the shell
return subprocess.Popen(cmd)

Expand Down
11 changes: 11 additions & 0 deletions test/vanilla/legacy/AcceptanceTests/asynctests/test_media_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,14 @@ async def test_binary_body_two_content_types(self, client):

content = b"hello, world"
await client.binary_body_with_two_content_types(content, content_type="application/octet-stream")

@pytest.mark.asyncio
async def test_binary_body_three_content_types(self, client):
json_input = json.dumps({"hello":"world"})
await client.binary_body_with_three_content_types(json_input)

content = b"hello, world"
await client.binary_body_with_three_content_types(content, content_type="application/octet-stream")

content = "hello, world"
await client.binary_body_with_three_content_types(content, content_type="text/plain")
2 changes: 1 addition & 1 deletion test/vanilla/legacy/AcceptanceTests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#Ideally this would be in a common helper library shared between the tests
def start_server_process():
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver".format(cwd)
cmd = "node {}/../../../../node_modules/@microsoft.azure/autorest.testserver/dist/cli/cli.js run --appendCoverage".format(cwd)
if os.name == 'nt': #On windows, subprocess creation works without being in the shell
return subprocess.Popen(cmd)

Expand Down
Loading