Skip to main content

Unit testing microframework for Storm ORM models

Project description

Introduction

Storm is a fast, small and powerful object-relational mapper. Try it to use in db-aware applications.

Effective unit-testing DB-models needed:

  • easy access to testing-DB inside testcases

  • setting up testing-DB before each test (and tear down after)

To help this unitstorm provides class ModelTestCase, that can be used both in unittest and nosetest testing frameworks.

Simple example

from unitstorm import ModelTestCase
from os import path

import models as model # models define somewhere else

class TestMyModel(ModelTestCase):
    dburi = 'postgres://test:test@localhost/test'

    fixtures = path.join(path.dirname(__file__), 'fixtures')

    fixture_setup = 'create.sql', 'filldata.sql'
    fixture_teardown = 'drop.sql'

    sql_setup = 'INSERT INTO my_model (id, name) VALUES (1, "foo");',\
        'INSERT INTO my_model (id, name) VALUES (2, "bar");'
    sql_teardown = 'DELETE FROM my_model WHERE id = 1;'

    def test_stub(self):
        assert self.store.get(model.MyModel, 1).name == "foo"

TODO more description (look sources)

dburi

db

store

fixtures

fixture_setup

fixture_teardown

sql_setup

sql_teardown

Execution order: fixture_setup, sql_setup, test, sql_teardown, fixture_teardown

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

unitstorm-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: unitstorm-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for unitstorm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aeeebf1ea2046c3fa62cd450319ce2b40e94c9b15ba3f722852ddb8f7e2d4536
MD5 b35ee98b654ee57b50bad277b91b1360
BLAKE2b-256 049cc9eec961d4bffaf4f4fb8a5dacc1812c9dc87da450d673b0a6eb3f649c10

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