{ "info": { "author": "Mitch Garnaat", "author_email": "mitch@garnaat.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "placebo\n=======\n\n[![Build Status](https://travis-ci.org/garnaat/placebo.svg)](https://travis-ci.org/garnaat/placebo)\n\n[![Code Health](https://landscape.io/github/garnaat/placebo/master/landscape.svg?style=flat)](https://landscape.io/github/garnaat/placebo/master)\n\nPlacebo allows you to mock boto3 calls that look just like normal calls but\nactually have no effect at all. It does this by allowing you to record a set\nof calls and save them to a data file and then replay those calls later\n(e.g. in a unit test) without ever hitting the AWS endpoints.\n\nInstallation\n------------\n\n~~~\n$ pip install placebo\n~~~\n\nQuickstart\n----------\n\nPlacebo uses the event mechanism in botocore to do most of its work. To start\nwith, you need a boto3 Session object.\n\n~~~ python\nimport boto3\nimport placebo\n\nsession = boto3.Session()\n~~~\n\nOnce you have a Session object, you can tell placebo about the Session like\nthis:\n\n~~~ python\npill = placebo.attach(session, data_path='/path/to/response/directory')\n~~~\n\nThe ``data_path`` is a path to a directory where you want responses to be stored\nor that contains previously recorded responses you want to playback.\n\nThe ``attach`` function returns an instance of a ``Pill`` object. This object\nwill be used to control all recording and playback of requests for all clients\ncreated by this session object.\n\nThe first thing you will probably want to do is record some requests. To do\nthis, simply:\n\n~~~ python\npill.record()\n~~~\n\nBy default, the ``record`` method will cause all responses from all services to\nbe recorded to the ``data_path``. If you are only interested in responses from\none certain services, you can limit the recording by passing in a list of\nservice names.\n\n~~~ python\npill.record(services='ec2,iam')\n~~~\n\nThis would limit to recording to responses from the ``ec2`` service and the\n``iam`` service. If you want to restrict recording to only certain operations\nin a single service, you can do this:\n\n~~~ python\npill.record(services='ec2', operations='DescribeInstances,DescribeKeyPairs')\n~~~\n\nFrom this point on, any clients that match the recording specification and are\ncreated from the session will be placebo-aware. To record responses, just\ncreate the client and use it as you normally would.\n\n~~~ python\nlambda = session.client('lambda')\nlambda.list_functions()\n... more lambda calls ...\n~~~\n\nEach response will be saved as an individual JSON data file in the ``data_path``\npath you specified when you attached the session. Multiple responses from the\nsame service and operation are stored as separate files and will be replayed in\nthe same order on playback.\n\nLater, to replay saved requests:\n\n~~~ python\nimport boto3\nimport placebo\n\nsession = boto3.Session()\npill = placebo.attach(session, data_path='/path/to/response/directory')\npill.playback()\nlambda = session.client('lambda')\nlambda.list_functions()\n... mocked response will be returned\n~~~\n\n#### Attaching to the default session\n\nSometimes, Placebo needs to be attached to the Boto3 [default session](http://boto3.readthedocs.io/en/latest/guide/session.html#default-session)\nobject.\n\nTo attach Placebo to the default session, it is necessary to explicitly set up\nthe default session by making a call to `boto3.setup_default_session()`. The\ndefault session is then accessible at `boto3.DEFAULT_SESSION`.\n\nFor example:\n\n~~~ python\nimport boto3\nimport placebo\n\n# Explicity set up the default session and attach Placebo to it.\nboto3.setup_default_session()\nsession = boto3.DEFAULT_SESSION\npill = placebo.attach(session, data_path='/path/to/response/directory')\npill.record()\n\n# Now make Boto3 calls using the default session.\nclient = boto3.client('ec2')\nclient.describe_images(DryRun=False)\n~~~\n\nThis is particularly useful if you are writing tests for legacy code that\nmakes use of the Boto3 default session.\n\n#### Using pickle\n\nThe responses can also be saved using pickle instead of JSON documents.\nThis can be useful to avoid serialization problems with complex types in\nthe responses.\n\nTo enable the pickle format:\n```\npill = pill = placebo.attach(session, record_format=\"pickle\")\n```\n\n#### Manual Mocking\n\nYou can also add mocked responses manually:\n\n~~~ python\nlist_functions_response = [\n {\n \"Version\": \"$LATEST\",\n \"CodeSha256\": \"I8Scq2g6ZKcPIvhKzvZqCiV4pDysxq4gZ+jLcMmDy5Y=\",\n \"FunctionName\": \"foobar\",\n \"MemorySize\": 128,\n \"CodeSize\": 876521,\n \"FunctionArn\": \"arn:aws:lambda:us-west-2:123456789012:function:foobar\",\n \"Handler\": \"foobar.handler\",\n \"Role\": \"arn:aws:iam::123456789012:role/foobar-role\",\n \"Timeout\": 30,\n \"LastModified\": \"2015-11-06T22:30:32.164+0000\",\n \"Runtime\": \"python2.7\",\n \"Description\": \"Foos all of the bars\"\n }]\n\npill.save_response(service='lambda', operation='ListFunctions',\n response_data=list_functions_response, http_response=200)\n~~~\n\nYou can add additional responses to a particular operation and the responses\nwill be returned in order. The final parameter is the HTTP response code which\nis optional. The default value is 200.\n\n#### Usage as a decorator\n\nPlacebo also provides a decorator for easier usage.\n\nFirst, you'll want to decorate your test method with `placebo_session` and include the `session` kwarg in your method, ex:\n~~~ python\n@placebo_session\ndef test_your_function(self, session):\n foo = Foo()\n arn = foo.create_iam_roles(session)\n self.assertEqual(arn, \"arn:aws:iam::123:role/{}\".format(foo.role_name))\n~~~\n\nNow, you'll be able to record the AWS interactions with an environment variable:\n~~~ bash\n$ PLACEBO_MODE=record nosetests tests.tests:TestFoo.test_create_iam_roles\n~~~\n\nYou can optionally pass an AWS profile to use:\n~~~ bash\n$ PLACEBO_PROFILE=foo PLACEBO_MODE=record nosetests tests.tests:TestFoo.test_create_iam_roles\n~~~\n\nYou can optionally set the record format to use:\n```bash\n$ PLACEBO_FORMAT=pickle PLACEBO_MODE=record nosetests tests.tests:TestFoo.test_create_iam_roles\n```\n\nIn this example, it has created the following JSON blobs:\n~~~\ntests/placebo/TestFoo.test_create_iam_roles\ntests/placebo/TestFoo.test_create_iam_roles/iam.CreateRole_1.json\ntests/placebo/TestFoo.test_create_iam_roles/iam.GetRole_1.json\ntests/placebo/TestFoo.test_create_iam_roles/iam.GetRolePolicy_1.json\ntests/placebo/TestFoo.test_create_iam_roles/iam.PutRolePolicy_1.json\n~~~\n\nAfter the JSON has been created, simply drop the environment variables and re-run your test:\n~~~ bash\n$ nosetests tests.tests:TestFoo.test_create_iam_roles\n~~~\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/garnaat/placebo", "keywords": "", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "placebo", "package_url": "https://pypi.org/project/placebo/", "platform": "", "project_url": "https://pypi.org/project/placebo/", "project_urls": { "Homepage": "https://github.com/garnaat/placebo" }, "release_url": "https://pypi.org/project/placebo/0.9.0/", "requires_dist": null, "requires_python": "", "summary": "Make boto3 calls that look real but have no effect", "version": "0.9.0" }, "last_serial": 4829262, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "6e6dcc3c305ef13e77c569cc76c67ad5", "sha256": "d3de4475b82ed2b9620f6576871b0d7f872bae9be9f231130d3bd4b9bbbc9730" }, "downloads": -1, "filename": "placebo-0.1.0.tar.gz", "has_sig": false, "md5_digest": "6e6dcc3c305ef13e77c569cc76c67ad5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5795, "upload_time": "2015-11-24T03:13:12", "url": "https://files.pythonhosted.org/packages/71/ec/8b02124da13859ffdd5f272c75133515fec1f74cc67c7c04277b8fed3949/placebo-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7e50456e07c0ca7ba4ad778ac85636da", "sha256": "46cbe7c30ee892649cfd60237c9fe5adfa805724632ce262118e32312a8c1247" }, "downloads": -1, "filename": "placebo-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7e50456e07c0ca7ba4ad778ac85636da", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5991, "upload_time": "2015-11-24T04:53:59", "url": "https://files.pythonhosted.org/packages/ca/72/800d59a7a7e5c7d0ec6fc47dd0dcd7d1430d0c759b97d69ec8f943129047/placebo-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "5e403aceaa3a54fe39af59bbf3a641b6", "sha256": "dd8ef7d1df5615fb25635c1916af9312a3379e4832b32bcce851898722c06f30" }, "downloads": -1, "filename": "placebo-0.1.2.tar.gz", "has_sig": false, "md5_digest": "5e403aceaa3a54fe39af59bbf3a641b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5989, "upload_time": "2015-11-24T05:35:16", "url": "https://files.pythonhosted.org/packages/13/e7/f9415a9c62229a553b94b773b80fb706870aa15ee5581de0ad8e49a005cf/placebo-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "46ac9530415f9aa2dfdf1c9a4a0931a9", "sha256": "745eb9fb8629b08ead3b9b159e60e43129bd222a515c4e0157b3cfc26ec48223" }, "downloads": -1, "filename": "placebo-0.2.0.tar.gz", "has_sig": false, "md5_digest": "46ac9530415f9aa2dfdf1c9a4a0931a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6493, "upload_time": "2015-11-24T17:01:33", "url": "https://files.pythonhosted.org/packages/85/a6/5240183a3ab5661215e2b949cc7b6600a4b73f88dbd65f767cd39a371e76/placebo-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "2d3e0cfd4fd6c8537e1e86d8cfdeb356", "sha256": "8cf1bb4dc4d1440fb79a2ffe0ac120c892ac2c0b15a48e3bfac0ba5ce510f140" }, "downloads": -1, "filename": "placebo-0.3.0.tar.gz", "has_sig": false, "md5_digest": "2d3e0cfd4fd6c8537e1e86d8cfdeb356", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7077, "upload_time": "2015-12-08T16:29:15", "url": "https://files.pythonhosted.org/packages/6d/0e/a7f3cfed7c94aaa5132ad28cc77d566636f6a42c9344859ab8ca8a79d78f/placebo-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "8bb170727896ceb585c7d44ac4478519", "sha256": "ca44463674ec5bdd8546c0fdcde0f3ec2956103705a8c28e322c665bfa90238c" }, "downloads": -1, "filename": "placebo-0.4.0.tar.gz", "has_sig": false, "md5_digest": "8bb170727896ceb585c7d44ac4478519", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8761, "upload_time": "2015-12-13T19:15:16", "url": "https://files.pythonhosted.org/packages/89/d5/1f4fc916863a92519515ccff65496712e59dd0832bd85ed6c08dc8628efd/placebo-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "ef7cffb1249fcb50bea4f438b5abef79", "sha256": "891c05958674f38a7ab7f96c307ceb0fd500678e1c0d7d501ab65680eda03633" }, "downloads": -1, "filename": "placebo-0.4.1.tar.gz", "has_sig": false, "md5_digest": "ef7cffb1249fcb50bea4f438b5abef79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8767, "upload_time": "2015-12-13T21:42:37", "url": "https://files.pythonhosted.org/packages/a5/34/df1bef3db8d4311c506318ce03df8294fa2b407b08bb0d34962ceefdfeb1/placebo-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "e9889017cd87355684fe9c6f2071d0d7", "sha256": "5784d4deadb67929132ff23fdea0f8e903f30b3b439e0903c8491af80cfaf534" }, "downloads": -1, "filename": "placebo-0.4.2.tar.gz", "has_sig": false, "md5_digest": "e9889017cd87355684fe9c6f2071d0d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9966, "upload_time": "2015-12-14T13:30:15", "url": "https://files.pythonhosted.org/packages/ae/0a/ffdab679a0196e7f8c4f9b3bb8bd67abf138cb9fdeadb74b8861a9c2f738/placebo-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "c937f957eefe9ad9291ae77c17a341cf", "sha256": "e8dc7ec904829af8f929c657c0309fc588cc637e33cf30d8ad7ad8611e87c87a" }, "downloads": -1, "filename": "placebo-0.4.3.tar.gz", "has_sig": false, "md5_digest": "c937f957eefe9ad9291ae77c17a341cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10385, "upload_time": "2015-12-15T18:26:11", "url": "https://files.pythonhosted.org/packages/e5/5a/54d8c6ff87cf3146ff9e917396f18eed7bbb69f18f10a070b296f98d3d1f/placebo-0.4.3.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "8e70b9b4452711793f6c721e5b91f11f", "sha256": "8d5a62c40d41ba4235a68757ad3082054acb6d8bcaeae4a27a7b0474beeb3b37" }, "downloads": -1, "filename": "placebo-0.5.0.tar.gz", "has_sig": false, "md5_digest": "8e70b9b4452711793f6c721e5b91f11f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10430, "upload_time": "2016-01-15T13:50:27", "url": "https://files.pythonhosted.org/packages/24/d8/790e349b4befffb30f805d5ecd82a9d6d7c01e621450303123c47796991a/placebo-0.5.0.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "e2dfff6b3b50f46d671b03e9452df30d", "sha256": "007435d5abfbdb02659be467cf0596ea4e914ba863ece737cb3dd62390000c17" }, "downloads": -1, "filename": "placebo-0.6.0.tar.gz", "has_sig": false, "md5_digest": "e2dfff6b3b50f46d671b03e9452df30d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10279, "upload_time": "2016-02-15T22:04:11", "url": "https://files.pythonhosted.org/packages/fd/3a/f4ac0d442fd69f4e56f3a7a03b099984518b5a8d3298c0d894f909ba17fd/placebo-0.6.0.tar.gz" } ], "0.7.0": [ { "comment_text": "", "digests": { "md5": "254097f7272ec876f395034f9cc5eb79", "sha256": "1d8853005a9f16a7a1963a85ee33e759fa7c74f708d76d29fd05965a1ee16d73" }, "downloads": -1, "filename": "placebo-0.7.0.tar.gz", "has_sig": false, "md5_digest": "254097f7272ec876f395034f9cc5eb79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10338, "upload_time": "2016-02-16T01:50:35", "url": "https://files.pythonhosted.org/packages/31/72/1b28bea7a058e540f11585fd69174806b0f1e27cc3335033625f79ca7abb/placebo-0.7.0.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "92c215e4c63692ed7af8bb2063ce4c6a", "sha256": "4081e7ac17d32baa2c2895883a9beabcfd784cb4ab80c5e332a846c1d43535d7" }, "downloads": -1, "filename": "placebo-0.7.1.tar.gz", "has_sig": false, "md5_digest": "92c215e4c63692ed7af8bb2063ce4c6a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10359, "upload_time": "2016-02-17T13:24:53", "url": "https://files.pythonhosted.org/packages/9b/ad/3a21851dce77808bbce4619322dc32ca317c5aae229d852df6b22d3dc21a/placebo-0.7.1.tar.gz" } ], "0.7.2": [ { "comment_text": "", "digests": { "md5": "1216abfbd944968bf398741c05291440", "sha256": "25a4d19b574875f6f05c20d6cbb0fee488149f99c1afc38410a92eb669e8b573" }, "downloads": -1, "filename": "placebo-0.7.2.tar.gz", "has_sig": false, "md5_digest": "1216abfbd944968bf398741c05291440", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10407, "upload_time": "2016-02-18T03:23:45", "url": "https://files.pythonhosted.org/packages/72/b9/2d5d9cecd1bbdf5814b0a1e8c984297b78f87f67143e848aabbacdbea807/placebo-0.7.2.tar.gz" } ], "0.8.0": [ { "comment_text": "", "digests": { "md5": "b78714c3c699ac7a1cae046d68fe0542", "sha256": "2cc58c4b51214f5774d5ea0d0c086b450d460d116ce1a9ec5c7b64987248880f" }, "downloads": -1, "filename": "placebo-0.8.0.tar.gz", "has_sig": false, "md5_digest": "b78714c3c699ac7a1cae046d68fe0542", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11461, "upload_time": "2016-02-28T23:48:14", "url": "https://files.pythonhosted.org/packages/ec/ce/ac39b59bb61175c85a1f7270d1fe805c529e427bb5c587524b195e604b8e/placebo-0.8.0.tar.gz" } ], "0.8.1": [ { "comment_text": "", "digests": { "md5": "349657cef05afc1b2eebed6dc6acf625", "sha256": "8aa848b892924786fa5e37e75524e8ec039b7d54860d35c51ffb4ed3e30590c5" }, "downloads": -1, "filename": "placebo-0.8.1.tar.gz", "has_sig": false, "md5_digest": "349657cef05afc1b2eebed6dc6acf625", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11501, "upload_time": "2016-03-04T13:45:31", "url": "https://files.pythonhosted.org/packages/89/c7/809e349d224ea5d7d5d5ad470e75634e88a43ba4ab84a08f7734ab23d4e6/placebo-0.8.1.tar.gz" } ], "0.8.2": [ { "comment_text": "", "digests": { "md5": "09d6caded00f062be1c2926d773a37f4", "sha256": "40269b5eeaf1ee9a28491ef982c722d1aebff577a0815528906bf392a10265a5" }, "downloads": -1, "filename": "placebo-0.8.2.tar.gz", "has_sig": false, "md5_digest": "09d6caded00f062be1c2926d773a37f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12723, "upload_time": "2018-09-03T16:38:23", "url": "https://files.pythonhosted.org/packages/4e/67/cdd143e5cb486b33a0b43c5cdfe96c72f0f5dc0c2a2b5efebd4a47d703c1/placebo-0.8.2.tar.gz" } ], "0.9.0": [ { "comment_text": "", "digests": { "md5": "fb52dbc3956590aa95f2bf595ecde49f", "sha256": "03157f8527bbc2965b71b88f4a139ef8038618b346787f20d63e3c5da541b047" }, "downloads": -1, "filename": "placebo-0.9.0.tar.gz", "has_sig": false, "md5_digest": "fb52dbc3956590aa95f2bf595ecde49f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13555, "upload_time": "2019-02-16T17:15:26", "url": "https://files.pythonhosted.org/packages/18/35/a60e29abebe274da55a62261a070c173bbb5faf1e6f3b35ac292d944d632/placebo-0.9.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fb52dbc3956590aa95f2bf595ecde49f", "sha256": "03157f8527bbc2965b71b88f4a139ef8038618b346787f20d63e3c5da541b047" }, "downloads": -1, "filename": "placebo-0.9.0.tar.gz", "has_sig": false, "md5_digest": "fb52dbc3956590aa95f2bf595ecde49f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13555, "upload_time": "2019-02-16T17:15:26", "url": "https://files.pythonhosted.org/packages/18/35/a60e29abebe274da55a62261a070c173bbb5faf1e6f3b35ac292d944d632/placebo-0.9.0.tar.gz" } ] }