
Security News
CISA Extends MITRE Contract as Crisis Accelerates Alternative CVE Coordination Efforts
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.
Automatically mocks resources defined in serverless.yml file using moto and uses them in pytest.
This way you can focus on writing tests rather than defining enormous list of fixtures.
master | PyPI | Python | pytest | Licence |
---|---|---|---|---|
6.2 |
serverless
installedpytest
installedpip install pytest-serverless
Assuming your serverless.yml
file looks like:
service: my-microservice
resources:
Resources:
TableA:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Delete
Properties:
TableName: ${self:service}.my-table
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: company_id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: company_id
KeySchema:
- AttributeName: company_id
KeyType: HASH
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 30
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 30
Just mark your test with @pytest.mark.usefixtures("serverless")
and pytest-serverless
will automatically create my-microservice.my-table
dynamodb table.
import boto3
import pytest
@pytest.mark.usefixtures("serverless")
def test():
table = boto3.resource("dynamodb").Table("my-microservice.my-table")
count_of_items = len(table.scan()["Items"])
assert count_of_items == 0
You can use a custom serverless file path setting the envionmnet variable SERVERLESS_FILE_PATH
.
$ export SERVERLESS_FILE_PATH=/path/to/serverless.yml
You can use choose both sls
or serverless
command to run, settings the environment variable SERVERLESS_COMMAND
. It will only accpets sls
or serverless
values.
$ export SERVERLESS_COMMAND=sls
FAQs
Automatically mocks resources from serverless.yml in pytest using moto.
We found that pytest-serverless demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.
Product
Socket's Rubygems ecosystem support is moving from beta to GA, featuring enhanced security scanning to detect supply chain threats beyond traditional CVEs in your Ruby dependencies.
Research
The Socket Research Team investigates a malicious npm package that appears to be an Advcash integration but triggers a reverse shell during payment success, targeting servers handling transactions.