Code Monkey home page Code Monkey logo

gocept.testdb's Introduction

gocept.testdb

Creates and drops temporary databases for testing purposes.

This package has been tested with Python 3.8, 3.9, 3.10 and 3.11.

gocept.testdb's People

Contributors

wosc avatar pre-commit-ci[bot] avatar sallner avatar sweh avatar vernans avatar zagy avatar mpeeters avatar nattre avatar ni-rnias avatar

Stargazers

Uwe Hartwig avatar Michael Howitz avatar

Watchers

 avatar James Cloos avatar nilo avatar  avatar  avatar

Forkers

leona-ya

gocept.testdb's Issues

Allow database creation for non-local databases

@sallner wrote at 2018-04-10:

For test setups on bitbucket pipelines with postgres as a service, we have a test system, where there is no createdb command available. Instead a connection to the postgres on localhost is possible.
I would like to have gocept.testdb to use this connection instead of CLI programs to create a database.
Inspiration may be found here: https://stackoverflow.com/a/8977109/8531885 http://sqlalchemy-utils.readthedocs.io/en/latest/database_helpers.html connection.execute('CREATE DATABASE test')

Use a better "new schema" marker for template db

@tlotze wrote at 2016-02-03:

Currently, if using a template db with PostgreSQL, the template db is recreated if the schema file is newer that the existing template db in terms of integer seconds. This may be too coarse-grained; either use a float time stamp or something else altogether, such as a hash of the schema file's content.

Improve test coverage for teardown with open connection

In #13 drop_db has been improved for cases in which the username is not identical to the db_name that has to be dropped. The execute command broke, if there is no database named like the user.

The test should roughly do the following:

  • create a user
  • create a db for the user with a random name
  • create a connection to that database and keep it open
  • call drop_db as the newly created user (without the change done in #13 this would fail because there is no database given for the psql call, so it is trying to connect to the database of the user)

Writing this test has been non-trivial as the creation and deletion of the user might temper with the ~/.pgpass which could have long-lasting effects if not properly cleared after an error in teardown. One solution might be to move default way of testing to docker as as the settings could than be made a prerequisite.

Create tmp table even when using a template db

@tlotze wrote at 2016-02-03:

gocept.testdb creates a special table within a test database to signal to the application the testing status of the db. (This is a safety belt so the app can make sure that it doesn't write to a production db when under test and vice versa.) When using a template db, however, this special table doesn't seem to get created, causing tests not to run.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.