%global _empty_manifest_terminate_build 0 Name: python-pgtest Version: 1.3.2 Release: 1 Summary: Creates a temporary, local PostgreSQL database cluster and server for unittesting, and cleans up after itself License: MIT URL: https://github.com/jamesnunn/pgtest Source0: https://mirrors.nju.edu.cn/pypi/web/packages/52/41/ff29129bc427bbdc6cbe4559a4830a4f4d71739ce33c728b4fa610f5b12e/pgtest-1.3.2.tar.gz BuildArch: noarch Requires: python3-pg8000 %description # pgtest [![Build Status](https://travis-ci.org/jamesnunn/pgtest.svg?branch=master)](https://travis-ci.org/jamesnunn/pgtest) Creates a temporary, local PostgreSQL database cluster and server specifically for unittesting, and cleans up after itself. ``` PGTest(username='postgres', port=None, log_file=None, no_cleanup=False, copy_cluster=None, base_dir=None, pg_ctl=None, max_connections=5) Args: username - str, username for default database superuser port - int, port to connect on; you must ensure that the port is unused log_file - str, path to place the log file no_cleanup - bool, don't clean up dirs after PGTest.close() is called copy_cluster - str, copies cluster from this path base_dir - str, path to the base directory to init the cluster pg_ctl - str, path to the pg_ctl executable to use max_connections - int, maximum number of connections to the cluster Attributes: PGTest.port - int, port number bound by PGTest PGTest.cluster - str, cluster directory generated by PGTest PGTest.username - str, username used by PGTest. Default is 'postgres' PGTest.log_file - str, path to postgres log file PGTest.pg_ctl - str, path to pg_ctl executable PGTest.url - str, url for default postgres database on the cluster PGTest.dsn - dict, dictionary containing dsn key-value pairs for the default postgres database on the cluster Methods: close() - Closes this instance of PGTest, cleans up directories ``` Usage as an instance ``` >>> from pgtest.pgtest import PGTest >>> import psycopg2 >>> pg = PGTest() Server started: postgresql://postgres@localhost:47251/postgres >>> pg.port 47251 >>> pg.cluster '/tmp/tmpiDtBjs/data' >>> pg.username 'postgres' >>> pg.log_file '/tmp/tmpiDtBjs/pgtest_log.txt' >>> pg.pg_ctl u'/usr/lib/postgresql/9.4/bin/pg_ctl' >>> pg.url 'postgresql://postgres@localhost:47251/postgres' >>> pg.dsn {'user': 'postgres', 'host': 'localhost', 'port': 47251, 'database': 'postgres'} >>> # Connect with other db driver here, e.g. psql, psycopg2, >>> # sqlalchemy etc >>> psycopg2.connect(**pg.dsn) >>> pg.close() Server stopped ``` Or use as a context: ``` >>> from pgtest.pgtest import PGTest >>> import psycopg2 >>> with PGTest() as pg: ... # connect to db with psycopg/sqlalchemy etc ... psycopg2.connect(**pg.dsn) ... # Do other database actions here >>> # When the context exits, the db cluster and service is deleted unless specified ``` Use with `unittest` in the `setUp()` and `tearDown()` methods: ``` import unittest from pgtest.pgtest import PGTest class TestThirdPartyDrivers(unittest.TestCase): @classmethod def setUpClass(cls): cls.pg = pgtest.PGTest() cls.base_dir = cls.pg._base_dir @classmethod def tearDownClass(cls): cls.pg.close() def test_something(self): self.assertTrue(isinstance(self.pg, PGTest) ``` %package -n python3-pgtest Summary: Creates a temporary, local PostgreSQL database cluster and server for unittesting, and cleans up after itself Provides: python-pgtest BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-pgtest # pgtest [![Build Status](https://travis-ci.org/jamesnunn/pgtest.svg?branch=master)](https://travis-ci.org/jamesnunn/pgtest) Creates a temporary, local PostgreSQL database cluster and server specifically for unittesting, and cleans up after itself. ``` PGTest(username='postgres', port=None, log_file=None, no_cleanup=False, copy_cluster=None, base_dir=None, pg_ctl=None, max_connections=5) Args: username - str, username for default database superuser port - int, port to connect on; you must ensure that the port is unused log_file - str, path to place the log file no_cleanup - bool, don't clean up dirs after PGTest.close() is called copy_cluster - str, copies cluster from this path base_dir - str, path to the base directory to init the cluster pg_ctl - str, path to the pg_ctl executable to use max_connections - int, maximum number of connections to the cluster Attributes: PGTest.port - int, port number bound by PGTest PGTest.cluster - str, cluster directory generated by PGTest PGTest.username - str, username used by PGTest. Default is 'postgres' PGTest.log_file - str, path to postgres log file PGTest.pg_ctl - str, path to pg_ctl executable PGTest.url - str, url for default postgres database on the cluster PGTest.dsn - dict, dictionary containing dsn key-value pairs for the default postgres database on the cluster Methods: close() - Closes this instance of PGTest, cleans up directories ``` Usage as an instance ``` >>> from pgtest.pgtest import PGTest >>> import psycopg2 >>> pg = PGTest() Server started: postgresql://postgres@localhost:47251/postgres >>> pg.port 47251 >>> pg.cluster '/tmp/tmpiDtBjs/data' >>> pg.username 'postgres' >>> pg.log_file '/tmp/tmpiDtBjs/pgtest_log.txt' >>> pg.pg_ctl u'/usr/lib/postgresql/9.4/bin/pg_ctl' >>> pg.url 'postgresql://postgres@localhost:47251/postgres' >>> pg.dsn {'user': 'postgres', 'host': 'localhost', 'port': 47251, 'database': 'postgres'} >>> # Connect with other db driver here, e.g. psql, psycopg2, >>> # sqlalchemy etc >>> psycopg2.connect(**pg.dsn) >>> pg.close() Server stopped ``` Or use as a context: ``` >>> from pgtest.pgtest import PGTest >>> import psycopg2 >>> with PGTest() as pg: ... # connect to db with psycopg/sqlalchemy etc ... psycopg2.connect(**pg.dsn) ... # Do other database actions here >>> # When the context exits, the db cluster and service is deleted unless specified ``` Use with `unittest` in the `setUp()` and `tearDown()` methods: ``` import unittest from pgtest.pgtest import PGTest class TestThirdPartyDrivers(unittest.TestCase): @classmethod def setUpClass(cls): cls.pg = pgtest.PGTest() cls.base_dir = cls.pg._base_dir @classmethod def tearDownClass(cls): cls.pg.close() def test_something(self): self.assertTrue(isinstance(self.pg, PGTest) ``` %package help Summary: Development documents and examples for pgtest Provides: python3-pgtest-doc %description help # pgtest [![Build Status](https://travis-ci.org/jamesnunn/pgtest.svg?branch=master)](https://travis-ci.org/jamesnunn/pgtest) Creates a temporary, local PostgreSQL database cluster and server specifically for unittesting, and cleans up after itself. ``` PGTest(username='postgres', port=None, log_file=None, no_cleanup=False, copy_cluster=None, base_dir=None, pg_ctl=None, max_connections=5) Args: username - str, username for default database superuser port - int, port to connect on; you must ensure that the port is unused log_file - str, path to place the log file no_cleanup - bool, don't clean up dirs after PGTest.close() is called copy_cluster - str, copies cluster from this path base_dir - str, path to the base directory to init the cluster pg_ctl - str, path to the pg_ctl executable to use max_connections - int, maximum number of connections to the cluster Attributes: PGTest.port - int, port number bound by PGTest PGTest.cluster - str, cluster directory generated by PGTest PGTest.username - str, username used by PGTest. Default is 'postgres' PGTest.log_file - str, path to postgres log file PGTest.pg_ctl - str, path to pg_ctl executable PGTest.url - str, url for default postgres database on the cluster PGTest.dsn - dict, dictionary containing dsn key-value pairs for the default postgres database on the cluster Methods: close() - Closes this instance of PGTest, cleans up directories ``` Usage as an instance ``` >>> from pgtest.pgtest import PGTest >>> import psycopg2 >>> pg = PGTest() Server started: postgresql://postgres@localhost:47251/postgres >>> pg.port 47251 >>> pg.cluster '/tmp/tmpiDtBjs/data' >>> pg.username 'postgres' >>> pg.log_file '/tmp/tmpiDtBjs/pgtest_log.txt' >>> pg.pg_ctl u'/usr/lib/postgresql/9.4/bin/pg_ctl' >>> pg.url 'postgresql://postgres@localhost:47251/postgres' >>> pg.dsn {'user': 'postgres', 'host': 'localhost', 'port': 47251, 'database': 'postgres'} >>> # Connect with other db driver here, e.g. psql, psycopg2, >>> # sqlalchemy etc >>> psycopg2.connect(**pg.dsn) >>> pg.close() Server stopped ``` Or use as a context: ``` >>> from pgtest.pgtest import PGTest >>> import psycopg2 >>> with PGTest() as pg: ... # connect to db with psycopg/sqlalchemy etc ... psycopg2.connect(**pg.dsn) ... # Do other database actions here >>> # When the context exits, the db cluster and service is deleted unless specified ``` Use with `unittest` in the `setUp()` and `tearDown()` methods: ``` import unittest from pgtest.pgtest import PGTest class TestThirdPartyDrivers(unittest.TestCase): @classmethod def setUpClass(cls): cls.pg = pgtest.PGTest() cls.base_dir = cls.pg._base_dir @classmethod def tearDownClass(cls): cls.pg.close() def test_something(self): self.assertTrue(isinstance(self.pg, PGTest) ``` %prep %autosetup -n pgtest-1.3.2 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-pgtest -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri May 05 2023 Python_Bot - 1.3.2-1 - Package Spec generated