Port test suite from nose to pytest.
This just eliminates all errors on the tests collection. Elimination of failures is left to the next commit.
This commit is contained in:
parent
47dbad291e
commit
77dc60ea97
146 changed files with 1172 additions and 1277 deletions
|
|
@ -6,12 +6,7 @@ import boto3
|
|||
from moto import mock_secretsmanager
|
||||
from botocore.exceptions import ClientError
|
||||
import sure # noqa
|
||||
from nose.tools import assert_raises
|
||||
|
||||
try:
|
||||
from nose.tools import assert_items_equal
|
||||
except ImportError:
|
||||
from nose.tools import assert_count_equal as assert_items_equal
|
||||
import pytest
|
||||
|
||||
|
||||
def boto_client():
|
||||
|
|
@ -24,7 +19,7 @@ def test_empty():
|
|||
|
||||
secrets = conn.list_secrets()
|
||||
|
||||
assert_items_equal(secrets["SecretList"], [])
|
||||
assert secrets["SecretList"] == []
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -60,7 +55,7 @@ def test_with_name_filter():
|
|||
secrets = conn.list_secrets(Filters=[{"Key": "name", "Values": ["foo"]}])
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo"])
|
||||
assert secret_names == ["foo"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -75,7 +70,7 @@ def test_with_tag_key_filter():
|
|||
secrets = conn.list_secrets(Filters=[{"Key": "tag-key", "Values": ["baz"]}])
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo"])
|
||||
assert secret_names == ["foo"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -90,7 +85,7 @@ def test_with_tag_value_filter():
|
|||
secrets = conn.list_secrets(Filters=[{"Key": "tag-value", "Values": ["baz"]}])
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo"])
|
||||
assert secret_names == ["foo"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -103,7 +98,7 @@ def test_with_description_filter():
|
|||
secrets = conn.list_secrets(Filters=[{"Key": "description", "Values": ["baz"]}])
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo"])
|
||||
assert secret_names == ["foo"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -128,14 +123,14 @@ def test_with_all_filter():
|
|||
secrets = conn.list_secrets(Filters=[{"Key": "all", "Values": ["foo"]}])
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo", "bar", "baz", "qux", "multi"])
|
||||
assert secret_names == ["foo", "bar", "baz", "qux", "multi"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
def test_with_no_filter_key():
|
||||
conn = boto_client()
|
||||
|
||||
with assert_raises(ClientError) as ire:
|
||||
with pytest.raises(ClientError) as ire:
|
||||
conn.list_secrets(Filters=[{"Values": ["foo"]}])
|
||||
|
||||
ire.exception.response["Error"]["Code"].should.equal("InvalidParameterException")
|
||||
|
|
@ -148,7 +143,7 @@ def test_with_no_filter_values():
|
|||
|
||||
conn.create_secret(Name="foo", SecretString="secret", Description="hello")
|
||||
|
||||
with assert_raises(ClientError) as ire:
|
||||
with pytest.raises(ClientError) as ire:
|
||||
conn.list_secrets(Filters=[{"Key": "description"}])
|
||||
|
||||
ire.exception.response["Error"]["Code"].should.equal("InvalidParameterException")
|
||||
|
|
@ -161,7 +156,7 @@ def test_with_no_filter_values():
|
|||
def test_with_invalid_filter_key():
|
||||
conn = boto_client()
|
||||
|
||||
with assert_raises(ClientError) as ire:
|
||||
with pytest.raises(ClientError) as ire:
|
||||
conn.list_secrets(Filters=[{"Key": "invalid", "Values": ["foo"]}])
|
||||
|
||||
ire.exception.response["Error"]["Code"].should.equal("ValidationException")
|
||||
|
|
@ -190,7 +185,7 @@ def test_with_duplicate_filter_keys():
|
|||
)
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo"])
|
||||
assert secret_names == ["foo"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -220,7 +215,7 @@ def test_with_multiple_filters():
|
|||
)
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo"])
|
||||
assert secret_names == ["foo"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -234,7 +229,7 @@ def test_with_filter_with_multiple_values():
|
|||
secrets = conn.list_secrets(Filters=[{"Key": "name", "Values": ["foo", "bar"]}])
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo", "bar"])
|
||||
assert secret_names == ["foo", "bar"]
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
|
@ -250,4 +245,4 @@ def test_with_filter_with_value_with_multiple_words():
|
|||
secrets = conn.list_secrets(Filters=[{"Key": "description", "Values": ["one two"]}])
|
||||
|
||||
secret_names = list(map(lambda s: s["Name"], secrets["SecretList"]))
|
||||
assert_items_equal(secret_names, ["foo", "bar"])
|
||||
assert secret_names == ["foo", "bar"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue