Techdebt: Replace sure with regular assertions in Neptune (#6663)
This commit is contained in:
parent
dc32eb86a3
commit
8035269645
@ -1,5 +1,4 @@
|
|||||||
import boto3
|
import boto3
|
||||||
import sure # noqa # pylint: disable=unused-import
|
|
||||||
from moto import mock_neptune
|
from moto import mock_neptune
|
||||||
|
|
||||||
|
|
||||||
@ -9,14 +8,14 @@ def test_db_cluster_options():
|
|||||||
# We're not checking the exact data here, that is already done in TF
|
# We're not checking the exact data here, that is already done in TF
|
||||||
client = boto3.client("neptune", region_name="us-east-1")
|
client = boto3.client("neptune", region_name="us-east-1")
|
||||||
response = client.describe_orderable_db_instance_options(Engine="neptune")
|
response = client.describe_orderable_db_instance_options(Engine="neptune")
|
||||||
response["OrderableDBInstanceOptions"].should.have.length_of(286)
|
assert len(response["OrderableDBInstanceOptions"]) == 286
|
||||||
|
|
||||||
response = client.describe_orderable_db_instance_options(
|
response = client.describe_orderable_db_instance_options(
|
||||||
Engine="neptune", EngineVersion="1.0.2.1"
|
Engine="neptune", EngineVersion="1.0.2.1"
|
||||||
)
|
)
|
||||||
response["OrderableDBInstanceOptions"].should.have.length_of(0)
|
assert len(response["OrderableDBInstanceOptions"]) == 0
|
||||||
|
|
||||||
response = client.describe_orderable_db_instance_options(
|
response = client.describe_orderable_db_instance_options(
|
||||||
Engine="neptune", EngineVersion="1.0.3.0"
|
Engine="neptune", EngineVersion="1.0.3.0"
|
||||||
)
|
)
|
||||||
response["OrderableDBInstanceOptions"].should.have.length_of(12)
|
assert len(response["OrderableDBInstanceOptions"]) == 12
|
||||||
|
@ -17,9 +17,9 @@ def test_add_tags_to_cluster():
|
|||||||
)
|
)
|
||||||
|
|
||||||
tags = conn.list_tags_for_resource(ResourceName=cluster_arn)["TagList"]
|
tags = conn.list_tags_for_resource(ResourceName=cluster_arn)["TagList"]
|
||||||
tags.should.equal([{"Key": "k1", "Value": "v1"}, {"Key": "k2", "Value": "v2"}])
|
assert tags == [{"Key": "k1", "Value": "v1"}, {"Key": "k2", "Value": "v2"}]
|
||||||
|
|
||||||
conn.remove_tags_from_resource(ResourceName=cluster_arn, TagKeys=["k1"])
|
conn.remove_tags_from_resource(ResourceName=cluster_arn, TagKeys=["k1"])
|
||||||
|
|
||||||
tags = conn.list_tags_for_resource(ResourceName=cluster_arn)["TagList"]
|
tags = conn.list_tags_for_resource(ResourceName=cluster_arn)["TagList"]
|
||||||
tags.should.equal([{"Key": "k2", "Value": "v2"}])
|
assert tags == [{"Key": "k2", "Value": "v2"}]
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""Unit tests for neptune-supported APIs."""
|
"""Unit tests for neptune-supported APIs."""
|
||||||
import boto3
|
import boto3
|
||||||
import pytest
|
import pytest
|
||||||
import sure # noqa # pylint: disable=unused-import
|
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from moto import mock_neptune
|
from moto import mock_neptune
|
||||||
|
|
||||||
@ -15,23 +14,21 @@ def test_create_db_cluster():
|
|||||||
resp = client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")[
|
resp = client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")[
|
||||||
"DBCluster"
|
"DBCluster"
|
||||||
]
|
]
|
||||||
resp.should.have.key("DBClusterIdentifier").equals("cluster-id")
|
assert resp["DBClusterIdentifier"] == "cluster-id"
|
||||||
resp.should.have.key("DbClusterResourceId")
|
assert "DbClusterResourceId" in resp
|
||||||
resp.should.have.key("DBClusterArn")
|
assert "DBClusterArn" in resp
|
||||||
resp.should.have.key("Engine").equals("neptune")
|
assert resp["Engine"] == "neptune"
|
||||||
resp.should.have.key("EngineVersion").equals("1.2.0.2")
|
assert resp["EngineVersion"] == "1.2.0.2"
|
||||||
resp.should.have.key("StorageEncrypted").equals(True)
|
assert resp["StorageEncrypted"] is True
|
||||||
resp.should.have.key("DBClusterParameterGroup").equals("")
|
assert resp["DBClusterParameterGroup"] == ""
|
||||||
resp.should.have.key("Endpoint")
|
assert "Endpoint" in resp
|
||||||
resp.should.have.key("DbClusterResourceId").match("cluster-")
|
assert "cluster-" in resp["DbClusterResourceId"]
|
||||||
resp.should.have.key("AvailabilityZones").equals(
|
assert resp["AvailabilityZones"] == ["us-east-2a", "us-east-2b", "us-east-2c"]
|
||||||
["us-east-2a", "us-east-2b", "us-east-2c"]
|
assert "ServerlessV2ScalingConfiguration" not in resp
|
||||||
)
|
|
||||||
resp.shouldnt.have.key("ServerlessV2ScalingConfiguration")
|
|
||||||
|
|
||||||
# Double check this cluster is not available in another region
|
# Double check this cluster is not available in another region
|
||||||
europe_client = boto3.client("neptune", region_name="eu-west-2")
|
europe_client = boto3.client("neptune", region_name="eu-west-2")
|
||||||
europe_client.describe_db_clusters()["DBClusters"].should.have.length_of(0)
|
assert len(europe_client.describe_db_clusters()["DBClusters"]) == 0
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
@ -47,29 +44,30 @@ def test_create_db_cluster__with_additional_params():
|
|||||||
ServerlessV2ScalingConfiguration={"MinCapacity": 1.0, "MaxCapacity": 2.0},
|
ServerlessV2ScalingConfiguration={"MinCapacity": 1.0, "MaxCapacity": 2.0},
|
||||||
DatabaseName="sth",
|
DatabaseName="sth",
|
||||||
)["DBCluster"]
|
)["DBCluster"]
|
||||||
resp.should.have.key("StorageEncrypted").equals(False)
|
assert resp["StorageEncrypted"] is False
|
||||||
resp.should.have.key("DBClusterParameterGroup").equals("myprm")
|
assert resp["DBClusterParameterGroup"] == "myprm"
|
||||||
resp.should.have.key("EngineVersion").equals("1.1.0.1")
|
assert resp["EngineVersion"] == "1.1.0.1"
|
||||||
resp.should.have.key("KmsKeyId").equals("key")
|
assert resp["KmsKeyId"] == "key"
|
||||||
resp.should.have.key("ServerlessV2ScalingConfiguration").equals(
|
assert resp["ServerlessV2ScalingConfiguration"] == {
|
||||||
{"MinCapacity": 1.0, "MaxCapacity": 2.0}
|
"MinCapacity": 1.0,
|
||||||
)
|
"MaxCapacity": 2.0,
|
||||||
resp.should.have.key("DatabaseName").equals("sth")
|
}
|
||||||
|
assert resp["DatabaseName"] == "sth"
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
def test_describe_db_clusters():
|
def test_describe_db_clusters():
|
||||||
client = boto3.client("neptune", region_name="ap-southeast-1")
|
client = boto3.client("neptune", region_name="ap-southeast-1")
|
||||||
client.describe_db_clusters()["DBClusters"].should.equal([])
|
assert client.describe_db_clusters()["DBClusters"] == []
|
||||||
|
|
||||||
client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")
|
client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")
|
||||||
|
|
||||||
clusters = client.describe_db_clusters(DBClusterIdentifier="cluster-id")[
|
clusters = client.describe_db_clusters(DBClusterIdentifier="cluster-id")[
|
||||||
"DBClusters"
|
"DBClusters"
|
||||||
]
|
]
|
||||||
clusters.should.have.length_of(1)
|
assert len(clusters) == 1
|
||||||
clusters[0]["DBClusterIdentifier"].should.equal("cluster-id")
|
assert clusters[0]["DBClusterIdentifier"] == "cluster-id"
|
||||||
clusters[0].should.have.key("Engine").equals("neptune")
|
assert clusters[0]["Engine"] == "neptune"
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
@ -79,7 +77,7 @@ def test_delete_db_cluster():
|
|||||||
client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")
|
client.create_db_cluster(DBClusterIdentifier="cluster-id", Engine="neptune")
|
||||||
client.delete_db_cluster(DBClusterIdentifier="cluster-id")
|
client.delete_db_cluster(DBClusterIdentifier="cluster-id")
|
||||||
|
|
||||||
client.describe_db_clusters()["DBClusters"].should.equal([])
|
assert client.describe_db_clusters()["DBClusters"] == []
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
@ -89,7 +87,7 @@ def test_delete_unknown_db_cluster():
|
|||||||
with pytest.raises(ClientError) as exc:
|
with pytest.raises(ClientError) as exc:
|
||||||
client.delete_db_cluster(DBClusterIdentifier="unknown-id")
|
client.delete_db_cluster(DBClusterIdentifier="unknown-id")
|
||||||
err = exc.value.response["Error"]
|
err = exc.value.response["Error"]
|
||||||
err["Code"].should.equal("DBClusterNotFoundFault")
|
assert err["Code"] == "DBClusterNotFoundFault"
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
@ -102,9 +100,9 @@ def test_modify_db_cluster():
|
|||||||
DBClusterParameterGroupName="myprm",
|
DBClusterParameterGroupName="myprm",
|
||||||
PreferredBackupWindow="window",
|
PreferredBackupWindow="window",
|
||||||
)["DBCluster"]
|
)["DBCluster"]
|
||||||
resp.should.have.key("DBClusterParameterGroup").equals("myprm")
|
assert resp["DBClusterParameterGroup"] == "myprm"
|
||||||
resp.should.have.key("EngineVersion").equals("1.1.0.1")
|
assert resp["EngineVersion"] == "1.1.0.1"
|
||||||
resp.should.have.key("PreferredBackupWindow").equals("window")
|
assert resp["PreferredBackupWindow"] == "window"
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
@ -115,4 +113,4 @@ def test_start_db_cluster():
|
|||||||
]
|
]
|
||||||
|
|
||||||
cluster = client.start_db_cluster(DBClusterIdentifier="cluster-id")["DBCluster"]
|
cluster = client.start_db_cluster(DBClusterIdentifier="cluster-id")["DBCluster"]
|
||||||
cluster.should.have.key("Status").equals("started")
|
assert cluster["Status"] == "started"
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import boto3
|
import boto3
|
||||||
import sure # noqa # pylint: disable=unused-import
|
|
||||||
from moto import mock_neptune
|
from moto import mock_neptune
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
def test_describe():
|
def test_describe():
|
||||||
client = boto3.client("neptune", "us-east-2")
|
client = boto3.client("neptune", "us-east-2")
|
||||||
client.describe_global_clusters()["GlobalClusters"].should.equal([])
|
assert client.describe_global_clusters()["GlobalClusters"] == []
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
@ -15,19 +14,19 @@ def test_create_global_cluster():
|
|||||||
resp = client.create_global_cluster(
|
resp = client.create_global_cluster(
|
||||||
GlobalClusterIdentifier="g-id", Engine="neptune"
|
GlobalClusterIdentifier="g-id", Engine="neptune"
|
||||||
)["GlobalCluster"]
|
)["GlobalCluster"]
|
||||||
resp.should.have.key("GlobalClusterIdentifier").equals("g-id")
|
assert resp["GlobalClusterIdentifier"] == "g-id"
|
||||||
resp.should.have.key("GlobalClusterResourceId")
|
assert "GlobalClusterResourceId" in resp
|
||||||
resp.should.have.key("GlobalClusterArn")
|
assert "GlobalClusterArn" in resp
|
||||||
resp.should.have.key("Engine").equals("neptune")
|
assert resp["Engine"] == "neptune"
|
||||||
resp.should.have.key("EngineVersion").equals("1.2.0.0")
|
assert resp["EngineVersion"] == "1.2.0.0"
|
||||||
resp.should.have.key("StorageEncrypted").equals(False)
|
assert resp["StorageEncrypted"] is False
|
||||||
resp.should.have.key("DeletionProtection").equals(False)
|
assert resp["DeletionProtection"] is False
|
||||||
|
|
||||||
client.describe_global_clusters()["GlobalClusters"].should.have.length_of(1)
|
assert len(client.describe_global_clusters()["GlobalClusters"]) == 1
|
||||||
|
|
||||||
# As a global cluster, verify it can be retrieved everywhere
|
# As a global cluster, verify it can be retrieved everywhere
|
||||||
europe_client = boto3.client("neptune", "eu-north-1")
|
europe_client = boto3.client("neptune", "eu-north-1")
|
||||||
europe_client.describe_global_clusters()["GlobalClusters"].should.have.length_of(1)
|
assert len(europe_client.describe_global_clusters()["GlobalClusters"]) == 1
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
@ -40,10 +39,10 @@ def test_create_global_cluster_with_additional_params():
|
|||||||
DeletionProtection=True,
|
DeletionProtection=True,
|
||||||
StorageEncrypted=True,
|
StorageEncrypted=True,
|
||||||
)["GlobalCluster"]
|
)["GlobalCluster"]
|
||||||
resp.should.have.key("Engine").equals("neptune")
|
assert resp["Engine"] == "neptune"
|
||||||
resp.should.have.key("EngineVersion").equals("1.0")
|
assert resp["EngineVersion"] == "1.0"
|
||||||
resp.should.have.key("StorageEncrypted").equals(True)
|
assert resp["StorageEncrypted"] is True
|
||||||
resp.should.have.key("DeletionProtection").equals(True)
|
assert resp["DeletionProtection"] is True
|
||||||
|
|
||||||
|
|
||||||
@mock_neptune
|
@mock_neptune
|
||||||
@ -53,4 +52,4 @@ def test_delete_global_cluster():
|
|||||||
|
|
||||||
client.delete_global_cluster(GlobalClusterIdentifier="g-id2")
|
client.delete_global_cluster(GlobalClusterIdentifier="g-id2")
|
||||||
|
|
||||||
client.describe_global_clusters()["GlobalClusters"].should.equal([])
|
assert client.describe_global_clusters()["GlobalClusters"] == []
|
||||||
|
Loading…
Reference in New Issue
Block a user