|
1 | 1 | # LOCALSTACK-UTILS |
2 | | -Python utility to integrate Localstack with Unit tests. |
| 2 | +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. |
3 | 3 |
|
4 | 4 | ### Prerequisites |
5 | 5 | - Docker |
6 | 6 | - Localstack |
7 | 7 |
|
8 | 8 |
|
9 | | -### Instalation (soon...) |
| 9 | +### Instalation |
| 10 | +``` bash |
| 11 | +pip install localstack-utils |
| 12 | +``` |
10 | 13 |
|
11 | 14 | ### Usage example |
12 | 15 |
|
13 | 16 | ``` python |
14 | 17 | import time |
15 | 18 | import boto3 |
16 | 19 | import unittest |
17 | | -from localstack_utils import startup_localstack, stop_localstack |
| 20 | +from localstack_utils.localstack import startup_localstack, stop_localstack |
18 | 21 |
|
19 | | -class kinesis_test(unittest.TestCase): |
20 | | - def setUp(self): |
21 | | - startup_localstack() |
22 | | - session = boto3.session.Session() |
| 22 | +class TestKinesis(unittest.TestCase): |
| 23 | + def setUp(self): |
| 24 | + startup_localstack() |
23 | 25 |
|
24 | | - def tearDown(self): |
25 | | - stop_localstack() |
26 | | - return super().tearDown() |
| 26 | + def tearDown(self): |
| 27 | + stop_localstack() |
| 28 | + return super().tearDown() |
27 | 29 |
|
28 | | - def test_create_stream(self): |
29 | | - kinesis = boto3.client( |
30 | | - service_name='kinesis', |
31 | | - aws_access_key_id='test', |
32 | | - aws_secret_access_key='test', |
33 | | - endpoint_url='http://localhost:4566') |
| 30 | + def test_create_stream(self): |
| 31 | + kinesis = boto3.client( |
| 32 | + service_name="kinesis", |
| 33 | + aws_access_key_id="test", |
| 34 | + aws_secret_access_key="test", |
| 35 | + endpoint_url="http://localhost:4566", |
| 36 | + ) |
34 | 37 |
|
35 | | - kinesis.create_stream(StreamName='test', ShardCount=1) |
36 | | - time.sleep(5) |
| 38 | + kinesis.create_stream(StreamName="test", ShardCount=1) |
| 39 | + time.sleep(1) |
37 | 40 |
|
38 | | - response = kinesis.list_streams() |
39 | | - self.assertGreater(len(response.get('StreamNames', [])),0) |
| 41 | + response = kinesis.list_streams() |
| 42 | + self.assertGreater(len(response.get("StreamNames", [])), 0) |
40 | 43 | ``` |
| 44 | + |
| 45 | +## Change Log |
| 46 | +* 1.0.0: Initial version |
0 commit comments