Azure / Azure/azure-cli

azure-cli-core: Test failure in TestClientFactory.test_get_mgmt_service_client

Open
#23,014 3 comments 0 reactions 1 assignee Claimed by @jiasli View on GitHub
Account act-identity-squad Auto-Assign customer-reported feature-request Packaging/RPM
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Related command**
This is a failure while running `azure-cli` tests during RPM packaging in Fedora Linux.

**Describe the bug**
When I run tests for the `azure-cli-core` package, I get the following test failure:

```
________________ TestClientFactory.test_get_mgmt_service_client ________________
[gw3] linux -- Python 3.11.0 /usr/bin/python3

self =

def test_get_mgmt_service_client(self):
cli = DummyCli()
> client = get_mgmt_service_client(cli, ResourceType.MGMT_RESOURCE_RESOURCES)

src/azure-cli-core/azure/cli/core/commands/tests/test_client_factory.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/azure-cli-core/azure/cli/core/commands/client_factory.py:70: in get_mgmt_service_client
client, _ = _get_mgmt_service_client(cli_ctx, client_type, subscription_id=subscription_id,
src/azure-cli-core/azure/cli/core/commands/client_factory.py:212: in _get_mgmt_service_client
cred, subscription_id, _ = profile.get_login_credentials(subscription_id=subscription_id, resource=resource,
src/azure-cli-core/azure/cli/core/_profile.py:314: in get_login_credentials
account = self.get_subscription(subscription_id)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
subscription = None

def get_subscription(self, subscription=None): # take id or name
subscriptions = self.load_cached_subscriptions()
if not subscriptions:
> raise CLIError(_AZ_LOGIN_MESSAGE)
E knack.util.CLIError: Please run 'az login' to setup account.

src/azure-cli-core/azure/cli/core/_profile.py:546: CLIError
```

**To Reproduce**
I run `pytest src/azure-cli-core` during an RPM build of azure-cli 2.37.0.

**Expected behavior**
I expected the test to pass. I even tried to add configuration files in `~/.azure`, but this did not help.

**Environment summary**
Python 3.10.5 and 3.11.0b3 on Fedora Linux 36 and 37. The Debian package scripts skip this test, so I assume there is trouble with it there as well.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.