Skip to content

Commit

Permalink
added mocked tests for databases - 2
Browse files Browse the repository at this point in the history
  • Loading branch information
work-mohit committed Sep 29, 2023
1 parent 010b228 commit 51e419a
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions tests/mocked/test_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,98 @@ 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

0 comments on commit 51e419a

Please sign in to comment.