Updates to dotnet example automation for recent changes on dotnet side (#9359)
* fix in new cases and update tests in new cases * remove useless pieces * update code * fix test cases * fix typo
This commit is contained in:
Родитель
9c36aa6e32
Коммит
607a9d8241
|
@ -98,7 +98,10 @@ def get_dotnet_using_statements(lines: List[str]) -> List[str]:
|
||||||
"using Azure.ResourceManager;\n",
|
"using Azure.ResourceManager;\n",
|
||||||
]
|
]
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.startswith("using "):
|
if line.startswith("using NUnit."):
|
||||||
|
# ignore the NUnit namespaces if any
|
||||||
|
pass
|
||||||
|
elif line.startswith("using "):
|
||||||
lines_using_statements.append(line)
|
lines_using_statements.append(line)
|
||||||
elif line.startswith("namespace "):
|
elif line.startswith("namespace "):
|
||||||
# remove the prefix first
|
# remove the prefix first
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
import unittest
|
import unittest
|
||||||
import parameterized
|
import parameterized
|
||||||
from main import break_down_aggregated_dotnet_example, format_dotnet, get_dotnet_using_statements
|
from main import break_down_aggregated_dotnet_example, format_dotnet, get_dotnet_using_statements
|
||||||
|
from typing import List
|
||||||
|
|
||||||
file_content = """// Copyright (c) Microsoft Corporation. All rights reserved.
|
class TestMain(unittest.TestCase):
|
||||||
|
@parameterized.parameterized.expand(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
"""// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
// <auto-generated/>
|
// <auto-generated/>
|
||||||
|
@ -20,14 +25,15 @@ using Azure.ResourceManager.ContainerInstance;
|
||||||
using Azure.ResourceManager.ContainerInstance.Models;
|
using Azure.ResourceManager.ContainerInstance.Models;
|
||||||
using Azure.ResourceManager.Models;
|
using Azure.ResourceManager.Models;
|
||||||
using Azure.ResourceManager.Resources;
|
using Azure.ResourceManager.Resources;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace Azure.ResourceManager.ContainerInstance.Samples
|
namespace Azure.ResourceManager.ContainerInstance.Samples
|
||||||
{
|
{
|
||||||
public partial class Sample_ContainerGroupCollection
|
public partial class Sample_ContainerGroupCollection
|
||||||
{
|
{
|
||||||
// ContainerGroupsListByResourceGroup
|
// ContainerGroupsListByResourceGroup
|
||||||
[NUnit.Framework.Test]
|
[Test]
|
||||||
[NUnit.Framework.Ignore("Only verifying that the sample builds")]
|
[Ignore("Only verifying that the sample builds")]
|
||||||
public async Task GetAll_ContainerGroupsListByResourceGroup()
|
public async Task GetAll_ContainerGroupsListByResourceGroup()
|
||||||
{
|
{
|
||||||
// Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2021-10-01/examples/ContainerGroupsListByResourceGroup.json
|
// Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2021-10-01/examples/ContainerGroupsListByResourceGroup.json
|
||||||
|
@ -324,10 +330,10 @@ new ContainerGroupSubnetId(new ResourceIdentifier("[resourceId('Microsoft.Networ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
)
|
||||||
|
]
|
||||||
class TestMain(unittest.TestCase):
|
)
|
||||||
def test_break_down_aggregated_dotnet_example(self):
|
def test_break_down_aggregated_dotnet_example(self, file_content: str):
|
||||||
lines = file_content.splitlines(keepends=True)
|
lines = file_content.splitlines(keepends=True)
|
||||||
examples = break_down_aggregated_dotnet_example(lines)
|
examples = break_down_aggregated_dotnet_example(lines)
|
||||||
self.assertIsNotNone(examples.class_opening)
|
self.assertIsNotNone(examples.class_opening)
|
||||||
|
@ -356,18 +362,28 @@ using Azure.Identity;
|
||||||
using Azure.ResourceManager.Compute.Models;
|
using Azure.ResourceManager.Compute.Models;
|
||||||
using Azure.ResourceManager.Resources;
|
using Azure.ResourceManager.Resources;
|
||||||
using Azure.ResourceManager.Resources.Models;
|
using Azure.ResourceManager.Resources.Models;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace Azure.ResourceManager.Compute.Samples
|
namespace Azure.ResourceManager.Compute.Samples
|
||||||
{
|
{
|
||||||
}"""
|
}""",
|
||||||
|
[
|
||||||
|
"using System;\n",
|
||||||
|
"using System.Threading.Tasks;\n",
|
||||||
|
"using Azure;\n",
|
||||||
|
"using Azure.Core;\n",
|
||||||
|
"using Azure.Identity;\n",
|
||||||
|
"using Azure.ResourceManager;\n",
|
||||||
|
"using Azure.ResourceManager.Compute;\n",
|
||||||
|
"using Azure.ResourceManager.Compute.Models;\n",
|
||||||
|
"using Azure.ResourceManager.Resources;\n",
|
||||||
|
"using Azure.ResourceManager.Resources.Models;\n",
|
||||||
|
]
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_example_usings(self, content: str):
|
def test_example_usings(self, content: str, expected_usings: List[str]):
|
||||||
lines = content.splitlines(keepends=True)
|
lines = content.splitlines(keepends=True)
|
||||||
usings = get_dotnet_using_statements(lines)
|
usings = get_dotnet_using_statements(lines)
|
||||||
|
|
||||||
self.assertIn("using Azure;\n", usings)
|
self.assertSetEqual(set(expected_usings), set(usings))
|
||||||
self.assertIn("using Azure.Core;\n", usings)
|
|
||||||
self.assertIn("using Azure.ResourceManager;\n", usings)
|
|
||||||
self.assertIn("using Azure.ResourceManager.Compute;\n", usings)
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче