Skip to main content

Utils for testing with LocalStack

Project description

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

pip install localstack-utils

Usage example

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.5: Add support for configurable container name and auth token forwarding
  • 1.0.4: Fixes to LocalStack and Container modules
  • 1.0.3: Add auto_remove config option
  • 1.0.2: LocalStack Pro image set as default
  • 1.0.1: Repository URL fixed
  • 1.0.0: Initial version

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

localstack_utils-1.0.5.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

localstack_utils-1.0.5-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file localstack_utils-1.0.5.tar.gz.

File metadata

  • Download URL: localstack_utils-1.0.5.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for localstack_utils-1.0.5.tar.gz
Algorithm Hash digest
SHA256 7e50edc3e29ed7ed253e72adf4b71094b70961b7ed066ccf576db926733e7ee2
MD5 2e7c2b913fed6055ac81f24a0dd50165
BLAKE2b-256 9374fbb1f3748b041268cf5dbde2324de7242fb84701474342c8dff25da65a5a

See more details on using hashes here.

File details

Details for the file localstack_utils-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for localstack_utils-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 af163f061bacb5479e23c82a37901e7d505638903aa86dda319f5a4e86f17f8b
MD5 fca5e4d211ff1afab87159532bdecb4a
BLAKE2b-256 bfec19da6c964a7517c09fa904f4ac2456b604054b57094a84955f14e208a184

See more details on using hashes here.

Supported by

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