Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added mocked tests for databases - part 2 #216

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions tests/mocked/test_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,97 @@ def test_databases_promote_replica(mock_client: Client, mock_client_url):
resp = mock_client.databases.promote_replica(cluster_uuid, replica_name)

assert resp is None


@responses.activate
def test_databases_delete(mock_client: Client, mock_client_url):
"""Mocks the databases delete operation."""

cluster_uuid = "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30"
database_name = "alpha"

responses.add(
responses.DELETE,
f"{mock_client_url}/v2/databases/{cluster_uuid}/dbs/{database_name}",
status=204,
)

resp = mock_client.databases.delete(cluster_uuid, database_name)

assert resp is None


@responses.activate
def test_databases_delete_connection_pool(mock_client: Client, mock_client_url):
"""Mocks the databases delete connection pool operation."""

cluster_uuid = "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30"

pool_name = "backend-pool"

responses.add(
responses.DELETE,
f"{mock_client_url}/v2/databases/{cluster_uuid}/pools/{pool_name}",
status=204,
)

resp = mock_client.databases.delete_connection_pool(cluster_uuid, pool_name)

assert resp is None


@responses.activate
def test_databases_delete_online_migration(mock_client: Client, mock_client_url):
"""Mocks the databases delete online migration operation."""

cluster_uuid = "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30"

migration_id = "77b28fc8-19ff-11eb-8c9c-c68e24557488"

responses.add(
responses.DELETE,
f"{mock_client_url}/v2/databases/{cluster_uuid}/online-migration/{migration_id}",
status=204,
)

resp = mock_client.databases.delete_online_migration(cluster_uuid, migration_id)

assert resp is None


@responses.activate
def test_databases_delete_user(mock_client: Client, mock_client_url):
"""Mocks the databases delete user operation."""

cluster_uuid = "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30"

user_name = "app-01"

responses.add(
responses.DELETE,
f"{mock_client_url}/v2/databases/{cluster_uuid}/users/{user_name}",
status=204,
)

resp = mock_client.databases.delete_user(cluster_uuid, user_name)

assert resp is None


@responses.activate
def test_databases_destroy_replica(mock_client: Client, mock_client_url):
"""Mocks the databases destroy replica operation that destroy a read only replica."""

cluster_uuid = "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30"

replica_name = "read_nyc_3"

responses.add(
responses.DELETE,
f"{mock_client_url}/v2/databases/{cluster_uuid}/replicas/{replica_name}",
status=204,
)

resp = mock_client.databases.destroy_replica(cluster_uuid, replica_name)

assert resp is None
Loading