-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADCM-6282: Prepare an example of interaction with a hostprovider (#83)
- Loading branch information
1 parent
5b772ae
commit b535a37
Showing
4 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest | ||
|
||
from adcm_aio_client import ADCMSession | ||
from tests.integration.examples.conftest import CREDENTIALS, REQUEST_KWARGS | ||
from tests.integration.setup_environment import ADCMContainer | ||
|
||
pytestmark = [pytest.mark.asyncio] | ||
|
||
|
||
async def test_hostprovider(adcm: ADCMContainer) -> None: | ||
""" | ||
Hostprovider (`client.hostproviders`) API Examples: | ||
- upload from path | ||
- retrieval with filtering / all hostproviders | ||
- hostprovider removal | ||
- creation of new hosts by hostprovider | ||
- retrieval a list of hosts by hostprovider with filtering / all hosts | ||
- upgrade of hostprovider | ||
""" | ||
async with ADCMSession(url=adcm.url, credentials=CREDENTIALS, **REQUEST_KWARGS) as client: | ||
# adding new hostprovider | ||
hostprovider = await client.hostproviders.create( | ||
bundle=await client.bundles.get(name__eq="simple_provider"), name="first provider" | ||
) | ||
second_hostprovider = await client.hostproviders.create( | ||
bundle=await client.bundles.get(name__eq="simple_provider"), name="second provider" | ||
) | ||
|
||
# getting full list of hostproviders | ||
providers = await client.hostproviders.all() | ||
assert len(providers) == 2 | ||
|
||
# getting filtered list of hostproviders | ||
providers = await client.hostproviders.filter(name__contains="first") | ||
assert len(providers) == 1 | ||
|
||
# deletion of hostprovider | ||
await second_hostprovider.delete() | ||
|
||
# adding new hosts by hostprovider | ||
for i in range(3): | ||
await client.hosts.create(hostprovider=hostprovider, name=f"host-{i}") | ||
|
||
# getting full list of hosts | ||
hosts = await hostprovider.hosts.all() | ||
assert len(hosts) == 3 | ||
|
||
# getting filtered list of hosts: | ||
hosts = await hostprovider.hosts.filter(name__contains="host-2") | ||
assert len(hosts) == 1 | ||
|
||
# running upgrade of hostprovider | ||
upgrade = await hostprovider.upgrades.get(name__eq="simple_provider") | ||
await upgrade.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters