Techdebt: Replace sure with regular assertions in QuickSight (#6680)
This commit is contained in:
parent
0e1df2ba62
commit
a6f140ddab
@ -1,5 +1,4 @@
|
||||
import boto3
|
||||
import sure # noqa # pylint: disable=unused-import
|
||||
|
||||
from moto import mock_quicksight
|
||||
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
||||
@ -29,11 +28,9 @@ def test_create_data_set():
|
||||
},
|
||||
)
|
||||
|
||||
resp.should.have.key("Arn").equals(
|
||||
f"arn:aws:quicksight:eu-west-1:{ACCOUNT_ID}:data-set/myset"
|
||||
)
|
||||
resp.should.have.key("DataSetId").equals("myset")
|
||||
resp.should.have.key("IngestionArn").equals(
|
||||
assert resp["Arn"] == (f"arn:aws:quicksight:eu-west-1:{ACCOUNT_ID}:data-set/myset")
|
||||
assert resp["DataSetId"] == "myset"
|
||||
assert resp["IngestionArn"] == (
|
||||
f"arn:aws:quicksight:eu-west-1:{ACCOUNT_ID}:ingestion/tbd"
|
||||
)
|
||||
|
||||
@ -66,8 +63,8 @@ def test_create_ingestion():
|
||||
IngestionType="FULL_REFRESH",
|
||||
)
|
||||
|
||||
resp.should.have.key("Arn").equals(
|
||||
assert resp["Arn"] == (
|
||||
f"arn:aws:quicksight:eu-west-1:{ACCOUNT_ID}:data-set/n_a/ingestions/n_a2"
|
||||
)
|
||||
resp.should.have.key("IngestionId").equals("n_a2")
|
||||
resp.should.have.key("IngestionStatus").equals("INITIALIZED")
|
||||
assert resp["IngestionId"] == "n_a2"
|
||||
assert resp["IngestionStatus"] == "INITIALIZED"
|
||||
|
@ -1,9 +1,8 @@
|
||||
"""Unit tests for quicksight-supported APIs."""
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa # pylint: disable=unused-import
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
import pytest
|
||||
|
||||
from moto import mock_quicksight
|
||||
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
||||
|
||||
@ -21,14 +20,14 @@ def test_create_group():
|
||||
Description="my new fancy group",
|
||||
)
|
||||
|
||||
resp.should.have.key("Group")
|
||||
assert "Group" in resp
|
||||
|
||||
resp["Group"].should.have.key("Arn").equals(
|
||||
assert resp["Group"]["Arn"] == (
|
||||
f"arn:aws:quicksight:us-west-2:{ACCOUNT_ID}:group/default/mygroup"
|
||||
)
|
||||
resp["Group"].should.have.key("GroupName").equals("mygroup")
|
||||
resp["Group"].should.have.key("Description").equals("my new fancy group")
|
||||
resp["Group"].should.have.key("PrincipalId").equals(f"{ACCOUNT_ID}")
|
||||
assert resp["Group"]["GroupName"] == "mygroup"
|
||||
assert resp["Group"]["Description"] == "my new fancy group"
|
||||
assert resp["Group"]["PrincipalId"] == f"{ACCOUNT_ID}"
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -45,14 +44,14 @@ def test_describe_group():
|
||||
GroupName="mygroup", AwsAccountId=ACCOUNT_ID, Namespace="default"
|
||||
)
|
||||
|
||||
resp.should.have.key("Group")
|
||||
assert "Group" in resp
|
||||
|
||||
resp["Group"].should.have.key("Arn").equals(
|
||||
assert resp["Group"]["Arn"] == (
|
||||
f"arn:aws:quicksight:us-west-2:{ACCOUNT_ID}:group/default/mygroup"
|
||||
)
|
||||
resp["Group"].should.have.key("GroupName").equals("mygroup")
|
||||
resp["Group"].should.have.key("Description").equals("my new fancy group")
|
||||
resp["Group"].should.have.key("PrincipalId").equals(f"{ACCOUNT_ID}")
|
||||
assert resp["Group"]["GroupName"] == "mygroup"
|
||||
assert resp["Group"]["Description"] == "my new fancy group"
|
||||
assert resp["Group"]["PrincipalId"] == f"{ACCOUNT_ID}"
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -71,19 +70,19 @@ def test_update_group():
|
||||
Namespace="default",
|
||||
Description="desc2",
|
||||
)
|
||||
resp.should.have.key("Group").should.have.key("Description").equals("desc2")
|
||||
assert resp["Group"]["Description"] == "desc2"
|
||||
|
||||
resp = client.describe_group(
|
||||
GroupName="mygroup", AwsAccountId=ACCOUNT_ID, Namespace="default"
|
||||
)
|
||||
|
||||
resp.should.have.key("Group")
|
||||
resp["Group"].should.have.key("Arn").equals(
|
||||
assert "Group" in resp
|
||||
assert resp["Group"]["Arn"] == (
|
||||
f"arn:aws:quicksight:us-west-2:{ACCOUNT_ID}:group/default/mygroup"
|
||||
)
|
||||
resp["Group"].should.have.key("GroupName").equals("mygroup")
|
||||
resp["Group"].should.have.key("Description").equals("desc2")
|
||||
resp["Group"].should.have.key("PrincipalId").equals(f"{ACCOUNT_ID}")
|
||||
assert resp["Group"]["GroupName"] == "mygroup"
|
||||
assert resp["Group"]["Description"] == "desc2"
|
||||
assert resp["Group"]["PrincipalId"] == f"{ACCOUNT_ID}"
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -105,7 +104,7 @@ def test_delete_group():
|
||||
GroupName="mygroup", AwsAccountId=ACCOUNT_ID, Namespace="default"
|
||||
)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -113,8 +112,8 @@ def test_list_groups__initial():
|
||||
client = boto3.client("quicksight", region_name="us-east-2")
|
||||
resp = client.list_groups(AwsAccountId=ACCOUNT_ID, Namespace="default")
|
||||
|
||||
resp.should.have.key("GroupList").equals([])
|
||||
resp.should.have.key("Status").equals(200)
|
||||
assert resp["GroupList"] == []
|
||||
assert resp["Status"] == 200
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -127,21 +126,17 @@ def test_list_groups():
|
||||
|
||||
resp = client.list_groups(AwsAccountId=ACCOUNT_ID, Namespace="default")
|
||||
|
||||
resp.should.have.key("GroupList").length_of(4)
|
||||
resp.should.have.key("Status").equals(200)
|
||||
assert len(resp["GroupList"]) == 4
|
||||
assert resp["Status"] == 200
|
||||
|
||||
resp["GroupList"].should.contain(
|
||||
{
|
||||
"Arn": f"arn:aws:quicksight:us-east-1:{ACCOUNT_ID}:group/default/group0",
|
||||
"GroupName": "group0",
|
||||
"PrincipalId": ACCOUNT_ID,
|
||||
}
|
||||
)
|
||||
assert {
|
||||
"Arn": f"arn:aws:quicksight:us-east-1:{ACCOUNT_ID}:group/default/group0",
|
||||
"GroupName": "group0",
|
||||
"PrincipalId": ACCOUNT_ID,
|
||||
} in resp["GroupList"]
|
||||
|
||||
resp["GroupList"].should.contain(
|
||||
{
|
||||
"Arn": f"arn:aws:quicksight:us-east-1:{ACCOUNT_ID}:group/default/group3",
|
||||
"GroupName": "group3",
|
||||
"PrincipalId": ACCOUNT_ID,
|
||||
}
|
||||
)
|
||||
assert {
|
||||
"Arn": f"arn:aws:quicksight:us-east-1:{ACCOUNT_ID}:group/default/group3",
|
||||
"GroupName": "group3",
|
||||
"PrincipalId": ACCOUNT_ID,
|
||||
} in resp["GroupList"]
|
||||
|
@ -1,9 +1,8 @@
|
||||
"""Unit tests for quicksight-supported APIs."""
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa # pylint: disable=unused-import
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
import pytest
|
||||
|
||||
from moto import mock_quicksight
|
||||
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
|
||||
|
||||
@ -23,17 +22,17 @@ def test_register_user__quicksight():
|
||||
UserRole="READER",
|
||||
)
|
||||
|
||||
resp.should.have.key("UserInvitationUrl")
|
||||
resp.should.have.key("User")
|
||||
assert "UserInvitationUrl" in resp
|
||||
assert "User" in resp
|
||||
|
||||
resp["User"].should.have.key("Arn").equals(
|
||||
assert resp["User"]["Arn"] == (
|
||||
f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:user/default/tfacctestm9hpsr970z"
|
||||
)
|
||||
resp["User"].should.have.key("UserName").equals("tfacctestm9hpsr970z")
|
||||
resp["User"].should.have.key("Email").equals("fakeemail@example.com")
|
||||
resp["User"].should.have.key("Role").equals("READER")
|
||||
resp["User"].should.have.key("IdentityType").equals("QUICKSIGHT")
|
||||
resp["User"].should.have.key("Active").equals(False)
|
||||
assert resp["User"]["UserName"] == "tfacctestm9hpsr970z"
|
||||
assert resp["User"]["Email"] == "fakeemail@example.com"
|
||||
assert resp["User"]["Role"] == "READER"
|
||||
assert resp["User"]["IdentityType"] == "QUICKSIGHT"
|
||||
assert resp["User"]["Active"] is False
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -52,16 +51,16 @@ def test_describe_user__quicksight():
|
||||
UserName="tfacctestm9hpsr970z", AwsAccountId=ACCOUNT_ID, Namespace="default"
|
||||
)
|
||||
|
||||
resp.should.have.key("User")
|
||||
assert "User" in resp
|
||||
|
||||
resp["User"].should.have.key("Arn").equals(
|
||||
assert resp["User"]["Arn"] == (
|
||||
f"arn:aws:quicksight:us-east-1:{ACCOUNT_ID}:user/default/tfacctestm9hpsr970z"
|
||||
)
|
||||
resp["User"].should.have.key("UserName").equals("tfacctestm9hpsr970z")
|
||||
resp["User"].should.have.key("Email").equals("fakeemail@example.com")
|
||||
resp["User"].should.have.key("Role").equals("READER")
|
||||
resp["User"].should.have.key("IdentityType").equals("QUICKSIGHT")
|
||||
resp["User"].should.have.key("Active").equals(False)
|
||||
assert resp["User"]["UserName"] == "tfacctestm9hpsr970z"
|
||||
assert resp["User"]["Email"] == "fakeemail@example.com"
|
||||
assert resp["User"]["Role"] == "READER"
|
||||
assert resp["User"]["IdentityType"] == "QUICKSIGHT"
|
||||
assert resp["User"]["Active"] is False
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -85,7 +84,7 @@ def test_delete_user__quicksight():
|
||||
UserName="tfacctestm9hpsr970z", AwsAccountId=ACCOUNT_ID, Namespace="default"
|
||||
)
|
||||
err = exc.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
assert err["Code"] == "ResourceNotFoundException"
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -93,8 +92,8 @@ def test_list_users__initial():
|
||||
client = boto3.client("quicksight", region_name="us-east-2")
|
||||
resp = client.list_users(AwsAccountId=ACCOUNT_ID, Namespace="default")
|
||||
|
||||
resp.should.have.key("UserList").equals([])
|
||||
resp.should.have.key("Status").equals(200)
|
||||
assert resp["UserList"] == []
|
||||
assert resp["Status"] == 200
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -112,30 +111,26 @@ def test_list_users():
|
||||
|
||||
resp = client.list_users(AwsAccountId=ACCOUNT_ID, Namespace="default")
|
||||
|
||||
resp.should.have.key("UserList").length_of(4)
|
||||
resp.should.have.key("Status").equals(200)
|
||||
assert len(resp["UserList"]) == 4
|
||||
assert resp["Status"] == 200
|
||||
|
||||
resp["UserList"].should.contain(
|
||||
{
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:user/default/fake0",
|
||||
"UserName": "fake0",
|
||||
"Email": "fakeemail0@example.com",
|
||||
"Role": "READER",
|
||||
"IdentityType": "QUICKSIGHT",
|
||||
"Active": False,
|
||||
}
|
||||
)
|
||||
assert {
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:user/default/fake0",
|
||||
"UserName": "fake0",
|
||||
"Email": "fakeemail0@example.com",
|
||||
"Role": "READER",
|
||||
"IdentityType": "QUICKSIGHT",
|
||||
"Active": False,
|
||||
} in resp["UserList"]
|
||||
|
||||
resp["UserList"].should.contain(
|
||||
{
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:user/default/fake3",
|
||||
"UserName": "fake3",
|
||||
"Email": "fakeemail3@example.com",
|
||||
"Role": "READER",
|
||||
"IdentityType": "QUICKSIGHT",
|
||||
"Active": False,
|
||||
}
|
||||
)
|
||||
assert {
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:user/default/fake3",
|
||||
"UserName": "fake3",
|
||||
"Email": "fakeemail3@example.com",
|
||||
"Role": "READER",
|
||||
"IdentityType": "QUICKSIGHT",
|
||||
"Active": False,
|
||||
} in resp["UserList"]
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -160,13 +155,11 @@ def test_create_group_membership():
|
||||
Namespace="default",
|
||||
)
|
||||
|
||||
resp.should.have.key("GroupMember").equals(
|
||||
{
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:group/default/group1/user.1",
|
||||
"MemberName": "user.1",
|
||||
}
|
||||
)
|
||||
resp.should.have.key("Status").equals(200)
|
||||
assert resp["GroupMember"] == {
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:group/default/group1/user.1",
|
||||
"MemberName": "user.1",
|
||||
}
|
||||
assert resp["Status"] == 200
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -198,13 +191,11 @@ def test_describe_group_membership():
|
||||
Namespace="default",
|
||||
)
|
||||
|
||||
resp.should.have.key("GroupMember").equals(
|
||||
{
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:group/default/group1/user1",
|
||||
"MemberName": "user1",
|
||||
}
|
||||
)
|
||||
resp.should.have.key("Status").equals(200)
|
||||
assert resp["GroupMember"] == {
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:group/default/group1/user1",
|
||||
"MemberName": "user1",
|
||||
}
|
||||
assert resp["Status"] == 200
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -249,21 +240,17 @@ def test_list_group_memberships():
|
||||
GroupName="group1", AwsAccountId=ACCOUNT_ID, Namespace="default"
|
||||
)
|
||||
|
||||
resp.should.have.key("GroupMemberList").length_of(2)
|
||||
resp.should.have.key("Status").equals(200)
|
||||
assert len(resp["GroupMemberList"]) == 2
|
||||
assert resp["Status"] == 200
|
||||
|
||||
resp["GroupMemberList"].should.contain(
|
||||
{
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:group/default/group1/user0",
|
||||
"MemberName": "user0",
|
||||
}
|
||||
)
|
||||
resp["GroupMemberList"].should.contain(
|
||||
{
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:group/default/group1/user1",
|
||||
"MemberName": "user1",
|
||||
}
|
||||
)
|
||||
assert {
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:group/default/group1/user0",
|
||||
"MemberName": "user0",
|
||||
} in resp["GroupMemberList"]
|
||||
assert {
|
||||
"Arn": f"arn:aws:quicksight:us-east-2:{ACCOUNT_ID}:group/default/group1/user1",
|
||||
"MemberName": "user1",
|
||||
} in resp["GroupMemberList"]
|
||||
|
||||
|
||||
@mock_quicksight
|
||||
@ -291,11 +278,11 @@ def test_list_group_memberships__after_deleting_user():
|
||||
resp = client.list_group_memberships(
|
||||
GroupName="group1", AwsAccountId=ACCOUNT_ID, Namespace="default"
|
||||
)
|
||||
resp.should.have.key("GroupMemberList").length_of(3)
|
||||
assert len(resp["GroupMemberList"]) == 3
|
||||
|
||||
client.delete_user(UserName="user1", AwsAccountId=ACCOUNT_ID, Namespace="default")
|
||||
|
||||
resp = client.list_group_memberships(
|
||||
GroupName="group1", AwsAccountId=ACCOUNT_ID, Namespace="default"
|
||||
)
|
||||
resp.should.have.key("GroupMemberList").length_of(2)
|
||||
assert len(resp["GroupMemberList"]) == 2
|
||||
|
Loading…
Reference in New Issue
Block a user