https://github.com/localstack/localstack-python-utils
Localstack utility for tests
https://github.com/localstack/localstack-python-utils
Last synced: about 2 months ago
JSON representation
Localstack utility for tests
- Host: GitHub
- URL: https://github.com/localstack/localstack-python-utils
- Owner: localstack
- Created: 2021-05-11T20:53:40.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-24T07:37:43.000Z (over 1 year ago)
- Last Synced: 2024-06-25T11:53:20.735Z (over 1 year ago)
- Language: Python
- Size: 25.4 KB
- Stars: 2
- Watchers: 14
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LocalStack Utils
This Python utility streamlines the integration of Localstack, a local AWS cloud services mock, with unit tests. Seamlessly incorporate Localstack into your Python projects to facilitate efficient and reliable testing of AWS interactions within a controlled local environment. Enhance the development process by utilizing this utility to simulate AWS services during unit testing, ensuring robust and dependable code before deployment.
### Prerequisites
- Docker
- Localstack
### Instalation
``` bash
pip install localstack-utils
```
### Usage example
``` python
import time
import boto3
import unittest
from localstack_utils.localstack import startup_localstack, stop_localstack
class TestKinesis(unittest.TestCase):
def setUp(self):
startup_localstack()
def tearDown(self):
stop_localstack()
return super().tearDown()
def test_create_stream(self):
kinesis = boto3.client(
service_name="kinesis",
aws_access_key_id="test",
aws_secret_access_key="test",
endpoint_url="http://localhost:4566",
)
kinesis.create_stream(StreamName="test", ShardCount=1)
time.sleep(1)
response = kinesis.list_streams()
self.assertGreater(len(response.get("StreamNames", [])), 0)
```
## Change Log
* 1.0.0: Repository URL fixed
* 1.0.0: Initial version