Skip to main content

Librería para procesar y gestionar metadatos de bases de datos

Project description

DeltaSnap

A tool to capture any subset of database records and compare changes between captures. It is mainly used for functional testing and debugging.

Installation

pip install deltasnap

Requirements

  • Python 3.6 or higher.

DeltaSnap works with any database or ORM that can interact with a database. You must have a database connection and an ORM such as SQLAlchemy or Django to use this tool effectively.

Supported ORMs:

  • SQLAlchemy (any version >= 1.3)
  • Django (any version >= 3.0)

Ensure that your project is properly connected to a database before using DeltaSnap.

Usage

from deltasnap import DBCapturer, DBConfig

# Set up the DBCapturer with the appropriate configuration
db_capturer = DBCapturer(
        DBConfig(
            db_source="sqlalchemy",  # Choose "sqlalchemy" or "django"
            test_session=test_session,  # Provide your test session (SQLAlchemy or Django session)
            base=base, # Provide the SQLAlchemy Base model. Django does not require this.
        )
    )


def test_start_game(test_session):
    initial_capture = db_capturer.capture_all_records(test_session)

    # Logic to test

    final_capture = db_capturer.capture_all_records(test_session)
    changes, created, deleted = db_capturer.compare_capture(initial_capture, final_capture)

    # Assertions to validate the changes
    assert not deleted.data # No records were deleted
    assert created.data == {
            ("cards", 1),
            ("cards", 2),
            ("cards", 3)
        } # 3 records were created in the 'cards' table
    assert changes.data == {
        ('games', 1): {
            'started': (False, True),
            'turn_start': (None, '2021-10-10T10:00:00Z')
            }
        } # There were changes in 2 columns of the record with id 1 from the 'games' table. For example, the 'started' field changed from False to True.

Advantages

  • Full coverage: Automatically validates all changes in the database.
  • Simplification: Reduces the use of fixed asserts that may be missed by the tester.
  • Automatic evolution: Adapts to changes in the database schema.
  • Complete comparisons: Validates both previous and current values.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deltasnap-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deltasnap-0.1.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file deltasnap-0.1.1.tar.gz.

File metadata

  • Download URL: deltasnap-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for deltasnap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 daa980b1244e2819e9e7eee4ff8ba1e0ece1b0931195d2f0fab88049a9ba9a64
MD5 ed89c27a0e72e542185cdd22ba3898d7
BLAKE2b-256 752b8354c15c1f4ddd2a5e5c7e12c2ce0d2ac508c2a53db937654be316564ec3

See more details on using hashes here.

File details

Details for the file deltasnap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: deltasnap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for deltasnap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef63c3ff8999b4362e4f46c3ce41025fada823c8011e036f638c78035b4df76f
MD5 05e1d8c269399c7dcb51798fa13de2c1
BLAKE2b-256 0e20e860f630207e9034a99cf3551437ea3eb240e7e20547ca41330f2bb80b3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page