Skip to content
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

update conftest for spector #2985

Merged
merged 7 commits into from
Jan 3, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-python"
---

Update test for unbranded and azure
2 changes: 1 addition & 1 deletion eng/pipelines/internal-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ steps:
scriptType: "bash"
scriptLocation: "inlineScript"
inlineScript: npx tsp-spector upload-coverage --coverageFile ./spec-coverage.json --generatorName "@typespec/http-client-python" --storageAccountName typespec --generatorVersion $(node -p -e "require('$(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@typespec/http-client-python/package.json').version") --containerName coverages --generatorMode standard
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@azure-tools/azure-http-specs
workingDirectory: $(Build.SourcesDirectory)/autorest.python/packages/typespec-python/node_modules/@typespec/http-specs

- script: |
tox run -e ci
Expand Down
6 changes: 4 additions & 2 deletions packages/typespec-python/scripts/eng/regenerate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ async function getSubdirectories(baseDir: string, flags: RegenerateFlags): Promi
const clientTspPath = join(subDirPath, "client.tsp");

const mainTspRelativePath = toPosix(relative(baseDir, mainTspPath));
if (flags.flavor === "unbranded" && mainTspRelativePath.includes("azure")) return;

// after fix test generation for nested operation group, remove this check
if (mainTspRelativePath.includes("client-operation-group")) return;
Expand Down Expand Up @@ -264,7 +263,10 @@ async function regenerate(flags: RegenerateFlagsInput): Promise<void> {
const flagsResolved = { debug: false, flavor: flags.flavor, ...flags };
const subdirectoriesForAzure = await getSubdirectories(AZURE_HTTP_SPECS, flagsResolved);
const subdirectoriesForNonAzure = await getSubdirectories(HTTP_SPECS, flagsResolved);
const subdirectories = [...subdirectoriesForAzure, ...subdirectoriesForNonAzure];
const subdirectories =
flags.flavor === "azure"
? [...subdirectoriesForAzure, ...subdirectoriesForNonAzure]
: subdirectoriesForNonAzure;
const cmdList: TspCommand[] = subdirectories.flatMap((subdirectory) =>
_getCmdList(subdirectory, flagsResolved),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ async def test_add_optional_param_from_one_optional():


@pytest.mark.asyncio
async def test_break_the_glass(core_library):
request = core_library.rest.HttpRequest(method="DELETE", url="/add-operation")
async def test_break_the_glass():
from azure.core.rest import HttpRequest

request = HttpRequest(method="DELETE", url="/add-operation")
async with V1Client(
endpoint="http://localhost:3000",
service_deployment_version="v2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ def test_add_optional_param_from_one_optional():
client.from_one_optional(parameter="optional", new_parameter="new")


def test_break_the_glass(core_library):
request = core_library.rest.HttpRequest(method="DELETE", url="/add-operation")
def test_break_the_glass():
from azure.core.rest import HttpRequest

request = HttpRequest(method="DELETE", url="/add-operation")
with V1Client(
endpoint="http://localhost:3000",
service_deployment_version="v2",
Expand Down
14 changes: 7 additions & 7 deletions packages/typespec-python/test/azure/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@ azure-mgmt-core==1.3.2
-e ./generated/azure-resource-manager-common-properties
-e ./generated/azure-resource-manager-resources
-e ./generated/azure-payload-pageable
-e ./generated/client-naming
-e ./generated/client-structure-default
-e ./generated/client-structure-multiclient
-e ./generated/client-structure-renamedoperation
-e ./generated/client-structure-twooperationgroup
-e ./generated/resiliency-srv-driven1
-e ./generated/resiliency-srv-driven2

# common test case
-e ./generated/authentication-api-key
-e ./generated/authentication-http-custom
-e ./generated/authentication-oauth2
-e ./generated/authentication-union
-e ./generated/client-naming
-e ./generated/encode-duration
-e ./generated/encode-numeric
-e ./generated/parameters-basic
-e ./generated/parameters-collection-format
-e ./generated/parameters-spread
-e ./generated/resiliency-srv-driven1
-e ./generated/resiliency-srv-driven2
-e ./generated/serialization-encoded-name-json
-e ./generated/server-endpoint-not-defined
-e ./generated/server-path-multiple
Expand Down Expand Up @@ -66,10 +70,6 @@ azure-mgmt-core==1.3.2
-e ./generated/special-headers-conditional-request
-e ./generated/encode-datetime
-e ./generated/encode-bytes
-e ./generated/client-structure-default
-e ./generated/client-structure-multiclient
-e ./generated/client-structure-renamedoperation
-e ./generated/client-structure-twooperationgroup
-e ./generated/payload-content-negotiation
-e ./generated/payload-json-merge-patch
-e ./generated/payload-pageable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
def start_server_process():
azure_http_path = Path(os.path.dirname(__file__)) / Path("../../node_modules/@azure-tools/azure-http-specs")
http_path = Path(os.path.dirname(__file__)) / Path("../../node_modules/@typespec/http-specs")
os.chdir(azure_http_path.resolve())
cmd = f"npx tsp-spector serve ./specs {(http_path / 'specs').resolve()}"
if "unbranded" in Path(os.getcwd()).parts:
os.chdir(http_path.resolve())
cmd = "npx tsp-spector serve ./specs"
else:
os.chdir(azure_http_path.resolve())
cmd = f"npx tsp-spector serve ./specs {(http_path / 'specs').resolve()}"
if os.name == "nt":
return subprocess.Popen(cmd, shell=True)
return subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading