Skip to main content

Declarative assertions for AWS

Project description

AWSsert

GitHub Workflow Status PyPI PyPI - Python Version Code style: black

AWSsert is a Python library providing declarative assertions about AWS resources to your tests.

Installation

Use the package manager pip to install AWSsert.

pip install awssert

Usage

Installing the package will make AWSserts extra assertions available to all of your tests. Assertions are attached directly to boto3 resource objects, allowing you to write clean and declarative tests:

import boto3

def test_bucket_contains_object():
   bucket = boto3.resource("s3").Bucket("foo")
   assert bucket.should_not.contain("bar")
   bucket.put_object(Key="bar", Body=b"123")
   assert bucket.should.contain("bar")

AWSsert also works in tandem with moto, enabling the same level of clarity to be applied on mock infrastructure:

import boto3
from moto import mock_s3

@mock_s3
def test_mock_bucket_contains_object():
   bucket = boto3.resource("s3").Bucket("foo")
   assert bucket.should_not.contain("bar")
   bucket.put_object(Key="bar", Body=b"123")
   assert bucket.should.contain("bar")

Progress

AWS Service Resource Object AWSsert Supported
CloudFormation Event :x:
Stack :x:
StackResource :x:
StackResourceSummary :x:
CloudWatch Alarm :x:
Metric :x:
DynamoDB Table :white_check_mark:
EC2 ClassicAddress :x:
DhcpOptions :x:
Image :x:
Instance :x:
InternetGateway :x:
KeyPair :x:
KeyPairInfo :x:
NetworkAcl :x:
NetworkInterface :x:
NetworkInterfaceAssociation :x:
PlacementGroup :x:
Route :x:
RouteTable :x:
RouteTableAssociation :x:
SecurityGroup :x:
Snapshot :x:
Subnet :x:
Tag :x:
Volume :x:
Vpc :x:
VpcPeeringConnection :x:
VpcAddress :x:
Glacier Account :x:
Archive :x:
Job :x:
MultipartUpload :x:
Notification :x:
Vault :x:
IAM AccessKey :x:
AccessKeyPair :x:
AccountPasswordPolicy :x:
AccountSummary :x:
AssumeRolePolicy :x:
CurrentUser :x:
Group :white_check_mark:
GroupPolicy :x:
InstanceProfile :x:
LoginProfile :x:
MfaDevice :x:
Policy :white_check_mark:
PolicyVersion :x:
Role :white_check_mark:
RolePolicy :x:
SamlProvider :x:
ServerCertificate :x:
SigningCertificate :x:
User :white_check_mark:
UserPolicy :x:
VirtualMfaDevice :x:
OpsWorks Layer :x:
Stack :x:
StackSummary :x:
S3 Bucket :white_check_mark:
BucketAcl :x:
BucketCors :x:
BucketLifecycle :x:
BucketLifecycleConfiguration :x:
BucketLogging :x:
BucketNotification :x:
BucketPolicy :x:
BucketRequestPayment :x:
BucketTagging :x:
BucketVersioning :x:
BucketWebsite :x:
MultipartUpload :x:
MultipartUploadPart :x:
Object :x:
ObjectAcl :x:
ObjectSummary :x:
ObjectVersion :x:
SNS PlatformApplication :x:
PlatformEndpoint :x:
Subscription :x:
Topic :white_check_mark:
SQS Message :x:
Queue :x:

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

A full contribution guide and code of conduct are supplied with the repository. In essence, update the unit tests and changelog, and treat fellow users with respect!

License

Apache Software License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awssert-1.0.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

awssert-1.0.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file awssert-1.0.0.tar.gz.

File metadata

  • Download URL: awssert-1.0.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for awssert-1.0.0.tar.gz
Algorithm Hash digest
SHA256 261bab609a36bef04096c8ca777159e5b28e53c2473f215b406dc2444e0c9102
MD5 e784aeb1b2643a299881729322bc5672
BLAKE2b-256 bff9b2fcde87a407816720f5124aec75bac6e53b3d0b36df6a0ff4a15499ca7c

See more details on using hashes here.

File details

Details for the file awssert-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: awssert-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for awssert-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0057038c324fb3f189265f10637a7a0a28915796f100db97f5ab54fff5ff8ef
MD5 be4a7ce2f16063ed3c2cd0b3feb43472
BLAKE2b-256 2506948ffabfc69e04bf58ecb395ed83e01c693ca92d3b7542c153a5703b860a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page