Skip to content

Commit 4677c99

Browse files
Merge pull request #23 from khushishah513/function-tests
modifications to tests
2 parents 379dedb + 025c3be commit 4677c99

6 files changed

+12058
-11665
lines changed

src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_function_invocations_summary_traces.yaml

Lines changed: 4753 additions & 4658 deletions
Large diffs are not rendered by default.

src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_function_keys.yaml

Lines changed: 2100 additions & 2084 deletions
Large diffs are not rendered by default.

src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_function_list_show_basic.yaml

Lines changed: 1114 additions & 1037 deletions
Large diffs are not rendered by default.

src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_function_list_show_error_scenarios.yaml

Lines changed: 1848 additions & 1759 deletions
Large diffs are not rendered by default.

src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_function_list_show_multirevision_scenarios.yaml

Lines changed: 2214 additions & 2120 deletions
Large diffs are not rendered by default.

src/containerapp/azext_containerapp/tests/latest/test_containerapp_function.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ def __init__(self, *arg, **kwargs):
3131

3232

3333
@AllowLargeResponse(8192)
34-
@ResourceGroupPreparer(location="northcentralus")
34+
@ResourceGroupPreparer(location="eastus2")
3535
def test_containerapp_function_list_show_basic(self, resource_group):
3636
"""Test basic function list functionality with various scenarios"""
3737
location = TEST_LOCATION
38+
if format_location(location) == format_location(STAGE_LOCATION):
39+
location = "eastus2"
3840
self.cmd('configure --defaults location={}'.format(location))
3941

4042
ca_name = self.create_random_name(prefix='containerapp', length=24)
@@ -54,6 +56,10 @@ def test_containerapp_function_list_show_basic(self, resource_group):
5456

5557
time.sleep(30)
5658
result = self.cmd(f'containerapp function list -g {resource_group} -n {ca_name}').get_output_in_json()
59+
self.assertIsInstance(result['value'], list, "Function list value should be a list")
60+
self.assertGreaterEqual(len(result['value']), 1, "Function list should contain at least one function")
61+
function_names = [func["properties"]["name"] for func in result['value']]
62+
self.assertIn(function_name, function_names, f"Function list should contain the function named {function_name}")
5763

5864
# Test successful function show
5965
function_details = self.cmd(f'containerapp function show -g {resource_group} -n {ca_name} --function-name {function_name}').get_output_in_json()
@@ -65,10 +71,12 @@ def test_containerapp_function_list_show_basic(self, resource_group):
6571

6672

6773
@AllowLargeResponse(8192)
68-
@ResourceGroupPreparer(location="northcentralus")
74+
@ResourceGroupPreparer(location="eastus2")
6975
def test_containerapp_function_list_show_error_scenarios(self, resource_group):
7076
"""Test error scenarios for function list command"""
7177
location = TEST_LOCATION
78+
if format_location(location) == format_location(STAGE_LOCATION):
79+
location = "eastus2"
7280
self.cmd('configure --defaults location={}'.format(location))
7381

7482
ca_name = self.create_random_name(prefix='containerapp', length=24)
@@ -130,10 +138,12 @@ def test_containerapp_function_list_show_error_scenarios(self, resource_group):
130138

131139

132140
@AllowLargeResponse(8192)
133-
@ResourceGroupPreparer(location="northcentralus")
141+
@ResourceGroupPreparer(location="eastus2")
134142
def test_containerapp_function_list_show_multirevision_scenarios(self, resource_group):
135143
"""Test multiple revisions scenarios for function list command"""
136144
location = TEST_LOCATION
145+
if format_location(location) == format_location(STAGE_LOCATION):
146+
location = "eastus2"
137147
self.cmd('configure --defaults location={}'.format(location))
138148
env = prepare_containerapp_env_for_app_e2e_tests(self, location=location)
139149

@@ -194,11 +204,17 @@ def test_containerapp_function_list_show_multirevision_scenarios(self, resource_
194204

195205

196206
@AllowLargeResponse(8192)
197-
@ResourceGroupPreparer(location="northcentralus")
207+
@ResourceGroupPreparer(location="eastus2")
198208
def test_containerapp_function_keys(self, resource_group):
199209
"""Test function keys show/list/set functionality"""
200210
location = TEST_LOCATION
211+
if format_location(location) == format_location(STAGE_LOCATION):
212+
location = "eastus2"
213+
self.cmd('configure --defaults location={}'.format(location))
201214
functionapp_location = TEST_LOCATION
215+
if format_location(functionapp_location) == format_location(STAGE_LOCATION):
216+
functionapp_location = "eastus2"
217+
202218
storage_account_name = self.create_random_name("storageacc", length=24)
203219
funcapp_name = self.create_random_name("functionapp", length=24)
204220
image = "mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0"
@@ -362,11 +378,17 @@ def test_containerapp_function_keys(self, resource_group):
362378

363379

364380
@AllowLargeResponse(8192)
365-
@ResourceGroupPreparer(location="northcentralus")
381+
@ResourceGroupPreparer(location="eastus2")
366382
def test_containerapp_function_invocations_summary_traces(self, resource_group):
367383
"""Test function keys show/list/set functionality using connection string and App Insights"""
368384
location = TEST_LOCATION
369-
functionapp_location = TEST_LOCATION
385+
if format_location(location) == format_location(STAGE_LOCATION):
386+
location = "eastus2"
387+
self.cmd('configure --defaults location={}'.format(location))
388+
functionapp_location = TEST_LOCATION
389+
if format_location(functionapp_location) == format_location(STAGE_LOCATION):
390+
functionapp_location = "eastus2"
391+
370392
funcapp_name = self.create_random_name("functionapp", length=24)
371393
image = "mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0"
372394
app_insights_name = self.create_random_name("appinsights", length=24)
@@ -387,7 +409,7 @@ def test_containerapp_function_invocations_summary_traces(self, resource_group):
387409
).output.strip()
388410

389411
# Step 2: Prepare Container App environment
390-
env = prepare_containerapp_env_v1_for_app_e2e_tests(self, location=functionapp_location) # this is temporary and will be removed in future
412+
env = prepare_containerapp_env_v1_for_app_e2e_tests(self, location=functionapp_location) # this is temporary and will be removed in future when this can be used with v2 envs
391413
time.sleep(100)
392414

393415
# Step 3: Create the function app (container app)

0 commit comments

Comments
 (0)