{ "info": { "author": "James Nunn", "author_email": "jamesnunn123@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# pgtest [![Build Status](https://travis-ci.org/jamesnunn/pgtest.svg?branch=master)](https://travis-ci.org/jamesnunn/pgtest)\n\nCreates a temporary, local PostgreSQL database cluster and server specifically for unittesting, and cleans up after itself.\n\n```\nPGTest(username='postgres', port=None, log_file=None, no_cleanup=False,\n copy_cluster=None, base_dir=None, pg_ctl=None, max_connections=5)\n\nArgs:\n username - str, username for default database superuser\n port - int, port to connect on; you must ensure that the port is unused\n log_file - str, path to place the log file\n no_cleanup - bool, don't clean up dirs after PGTest.close() is called\n copy_cluster - str, copies cluster from this path\n base_dir - str, path to the base directory to init the cluster\n pg_ctl - str, path to the pg_ctl executable to use\n max_connections - int, maximum number of connections to the cluster\n\nAttributes:\n PGTest.port - int, port number bound by PGTest\n PGTest.cluster - str, cluster directory generated by PGTest\n PGTest.username - str, username used by PGTest. Default is 'postgres'\n PGTest.log_file - str, path to postgres log file\n PGTest.pg_ctl - str, path to pg_ctl executable\n PGTest.url - str, url for default postgres database on the cluster\n PGTest.dsn - dict, dictionary containing dsn key-value pairs for the\n default postgres database on the cluster\nMethods:\n close() - Closes this instance of PGTest, cleans up directories \n```\n\nUsage as an instance\n```\n>>> from pgtest.pgtest import PGTest\n>>> import psycopg2\n>>> pg = PGTest()\nServer started: postgresql://postgres@localhost:47251/postgres\n>>> pg.port\n47251\n>>> pg.cluster\n'/tmp/tmpiDtBjs/data'\n>>> pg.username\n'postgres'\n>>> pg.log_file\n'/tmp/tmpiDtBjs/pgtest_log.txt'\n>>> pg.pg_ctl\nu'/usr/lib/postgresql/9.4/bin/pg_ctl'\n>>> pg.url\n'postgresql://postgres@localhost:47251/postgres'\n>>> pg.dsn\n{'user': 'postgres', 'host': 'localhost',\n'port': 47251, 'database': 'postgres'}\n>>> # Connect with other db driver here, e.g. psql, psycopg2,\n>>> # sqlalchemy etc\n>>> psycopg2.connect(**pg.dsn)\n>>> pg.close()\nServer stopped\n```\n\nOr use as a context:\n```\n>>> from pgtest.pgtest import PGTest\n>>> import psycopg2\n>>> with PGTest() as pg:\n... # connect to db with psycopg/sqlalchemy etc\n... psycopg2.connect(**pg.dsn)\n... # Do other database actions here\n>>> # When the context exits, the db cluster and service is deleted unless specified\n```\n\nUse with `unittest` in the `setUp()` and `tearDown()` methods:\n```\nimport unittest\nfrom pgtest.pgtest import PGTest\n\nclass TestThirdPartyDrivers(unittest.TestCase):\n @classmethod\n def setUpClass(cls):\n cls.pg = pgtest.PGTest()\n cls.base_dir = cls.pg._base_dir\n\n @classmethod\n def tearDownClass(cls):\n cls.pg.close()\n\n def test_something(self):\n self.assertTrue(isinstance(self.pg, PGTest)\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jamesnunn/pgtest", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pgtest", "package_url": "https://pypi.org/project/pgtest/", "platform": "", "project_url": "https://pypi.org/project/pgtest/", "project_urls": { "Homepage": "https://github.com/jamesnunn/pgtest" }, "release_url": "https://pypi.org/project/pgtest/1.3.1/", "requires_dist": [ "pg8000 (>=1.10)" ], "requires_python": "", "summary": "Creates a temporary, local PostgreSQL database cluster and server for unittesting, and cleans up after itself", "version": "1.3.1" }, "last_serial": 5836787, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "cefdd0626eb08b7636b972e9144234e3", "sha256": "a2baab3805f8e2de1da13cfe4c13f4707c298ba800c2c02a53551f7d77b797a6" }, "downloads": -1, "filename": "pgtest-1.0.0.zip", "has_sig": false, "md5_digest": "cefdd0626eb08b7636b972e9144234e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9371, "upload_time": "2015-08-25T15:30:47", "url": "https://files.pythonhosted.org/packages/1f/94/f76ac977229176b025c0a1cab4920f5303a8af265830f53325a41729ca8e/pgtest-1.0.0.zip" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "db35afc8ed782b982a0b8eb10fe5793d", "sha256": "7e7a9b473229f95dbf3773e3d28a583d69ba5060035f1e71fa3bfb4493ee4050" }, "downloads": -1, "filename": "pgtest-1.1.0.tar.gz", "has_sig": false, "md5_digest": "db35afc8ed782b982a0b8eb10fe5793d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8510, "upload_time": "2017-10-12T08:31:21", "url": "https://files.pythonhosted.org/packages/82/5b/109885695c5d99896a5e3042379dbd5529e896c410440d16047276e4a058/pgtest-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "6d8850f0b7c2d6727daf565074a8c463", "sha256": "1695720e57c82b0fbfdace1fb43bcb9d26c5f652887ceaaa850452608ac14fc8" }, "downloads": -1, "filename": "pgtest-1.2.0-py2-none-any.whl", "has_sig": false, "md5_digest": "6d8850f0b7c2d6727daf565074a8c463", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 7707, "upload_time": "2019-03-25T12:28:36", "url": "https://files.pythonhosted.org/packages/59/6b/55f5c19465531e6fdd87d2f1e9c470ab4bd988218f4496178942ebf0dee9/pgtest-1.2.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9dedc23c6389a62723b9e78a895e1164", "sha256": "31c848ddaa628d3c23887631985ae30ec4b7d1f4bec71a222811813643215615" }, "downloads": -1, "filename": "pgtest-1.2.0.tar.gz", "has_sig": false, "md5_digest": "9dedc23c6389a62723b9e78a895e1164", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8813, "upload_time": "2019-03-25T12:28:37", "url": "https://files.pythonhosted.org/packages/1e/e0/bd48b52807b31dc48a0b4b338837e6f203b8a293affaa6a17c250dfcd319/pgtest-1.2.0.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "023aefb6be14206d46cfa318ab69f1b9", "sha256": "ec8e2db353dcfc8a757de452f064378ddae25256657246c26adb442eb036dd7e" }, "downloads": -1, "filename": "pgtest-1.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "023aefb6be14206d46cfa318ab69f1b9", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 7800, "upload_time": "2019-04-29T09:57:45", "url": "https://files.pythonhosted.org/packages/bf/ab/bae77a9f458b787790e1f1255d90c40ee5baea9afdce7daeedd5f52c026a/pgtest-1.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21b1af5fc8eb74fa1f3efff42a3345c6", "sha256": "3f055058723b26bdd6612726a7bf792f7630ff3f2a4b647e3a3c9bdc0192b641" }, "downloads": -1, "filename": "pgtest-1.3.0.tar.gz", "has_sig": false, "md5_digest": "21b1af5fc8eb74fa1f3efff42a3345c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9004, "upload_time": "2019-04-29T09:57:50", "url": "https://files.pythonhosted.org/packages/01/4f/2a7b8c51a0ac5572b01b8b187df8866a0c6d670f4452e993ada99dc64935/pgtest-1.3.0.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "a64516459311c44430cccabd47a1f3e8", "sha256": "efc128ce49cf0a5e2ed6380d33b317570161577e9234a5a9e9679f2090159933" }, "downloads": -1, "filename": "pgtest-1.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a64516459311c44430cccabd47a1f3e8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8993, "upload_time": "2019-09-16T15:16:21", "url": "https://files.pythonhosted.org/packages/c7/8f/43c0ee58e17c77fd5005e3a8b238980ba6daec3f0f651eb9e78140815aac/pgtest-1.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f5178f83f94ce59370d9bb7f8f6fc995", "sha256": "b1aa5516b3f1215643c265e11c83099a7d6978a4bd1e59e63963b33fe7da08e6" }, "downloads": -1, "filename": "pgtest-1.3.1.tar.gz", "has_sig": false, "md5_digest": "f5178f83f94ce59370d9bb7f8f6fc995", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9266, "upload_time": "2019-09-16T15:16:23", "url": "https://files.pythonhosted.org/packages/07/cb/9c29de31f75a32591956ac01ad1feb3122962873ab570a7f41ce7a0d69e1/pgtest-1.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a64516459311c44430cccabd47a1f3e8", "sha256": "efc128ce49cf0a5e2ed6380d33b317570161577e9234a5a9e9679f2090159933" }, "downloads": -1, "filename": "pgtest-1.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a64516459311c44430cccabd47a1f3e8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8993, "upload_time": "2019-09-16T15:16:21", "url": "https://files.pythonhosted.org/packages/c7/8f/43c0ee58e17c77fd5005e3a8b238980ba6daec3f0f651eb9e78140815aac/pgtest-1.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f5178f83f94ce59370d9bb7f8f6fc995", "sha256": "b1aa5516b3f1215643c265e11c83099a7d6978a4bd1e59e63963b33fe7da08e6" }, "downloads": -1, "filename": "pgtest-1.3.1.tar.gz", "has_sig": false, "md5_digest": "f5178f83f94ce59370d9bb7f8f6fc995", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9266, "upload_time": "2019-09-16T15:16:23", "url": "https://files.pythonhosted.org/packages/07/cb/9c29de31f75a32591956ac01ad1feb3122962873ab570a7f41ce7a0d69e1/pgtest-1.3.1.tar.gz" } ] }