-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update management API -
BucketsApi
, OrganizationsApi
, `User…
…sApi` (#358)
- Loading branch information
Showing
9 changed files
with
163 additions
and
8 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
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
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,24 @@ | ||
from tests.base_test import BaseTest, generate_name | ||
|
||
|
||
class OrganizationsApiTests(BaseTest): | ||
|
||
def setUp(self) -> None: | ||
super(OrganizationsApiTests, self).setUp() | ||
organizations_api = self.client.organizations_api() | ||
organizations = organizations_api.find_organizations() | ||
|
||
for organization in organizations: | ||
if organization.name.endswith("_IT"): | ||
print("Delete organization: ", organization.name) | ||
organizations_api.delete_organization(org_id=organization.id) | ||
|
||
def test_update_organization(self): | ||
organizations_api = self.client.organizations_api() | ||
|
||
organization = organizations_api.create_organization(name=generate_name(key='org')) | ||
self.assertEqual("", organization.description) | ||
|
||
organization.description = "updated description" | ||
organization = organizations_api.update_organization(organization=organization) | ||
self.assertEqual("updated description", organization.description) |
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,45 @@ | ||
import pytest | ||
|
||
from influxdb_client import UserResponse | ||
from influxdb_client.rest import ApiException | ||
from tests.base_test import BaseTest, generate_name | ||
|
||
|
||
class UsersApiTests(BaseTest): | ||
|
||
def setUp(self) -> None: | ||
super(UsersApiTests, self).setUp() | ||
users_api = self.client.users_api() | ||
users = users_api.find_users() | ||
|
||
for user in users.users: | ||
if user.name.endswith("_IT"): | ||
print("Delete user: ", user.name) | ||
users_api.delete_user(user=user) | ||
|
||
def test_delete_user(self): | ||
users_api = self.client.users_api() | ||
|
||
user = users_api.create_user(name=generate_name(key='user')) | ||
users = users_api.find_users(id=user.id) | ||
self.assertEqual(1, len(users.users)) | ||
self.assertEqual(user, users.users[0]) | ||
|
||
users_api.delete_user(user) | ||
|
||
with pytest.raises(ApiException) as e: | ||
assert users_api.find_users(id=user.id) | ||
assert "user not found" in e.value.body | ||
|
||
def test_update_user(self): | ||
users_api = self.client.users_api() | ||
|
||
name = generate_name(key='user') | ||
user = users_api.create_user(name=name) | ||
self.assertEqual(name, user.name) | ||
|
||
user.name = "updated_" + name | ||
user = users_api.update_user(user=user) | ||
self.assertIsInstance(user, UserResponse) | ||
user = users_api.find_users(id=user.id).users[0] | ||
self.assertEqual("updated_" + name, user.name) |