rethinkORM.tests

To get started and make sure this all works, please make sure you have Python nose installed.

nosetests rethinkORM -v -s

This will run the all the tests, not capturing stdout and being verbose, in case anything goes wrong, or if you modify the tests. Please note, tests are subject to a lot of changes, and this may not always be the same command.

If you want to also check the PEP8 validity of the code, you can run:

pep8 rethinkORM

or, if you have tissue installed you can run a PEP8 check with the rest of the test suite like so:

nosetests rethinkORM -v -s --with-tissue

How the tests work (or should, if more are written):

There is a setup fixture that creates a database called model and within that creates a table stargate. Then each test works on entries which get stored in this database and table. When everything is done, the teardown fixture is ran to clean up and delete the whole database model. Each test should be broken down into basic actions, for example there are currently tests for:

  • inserting a new entry
  • modifying that entry
  • deleting that entry
  • inserting an entry where the primary key is None or a null value.

test_model Module

Test suite for the model

class rethinkORM.tests.test_model.base[source]

Bases: object

Base test object to help automate some of the repetitive work of reloading a document to ensure the model matches the test data. Also takes care of deleting the document if cleanupAfter is True

cleanupAfter = False

Should the document created by this test be deleted when over?

loadCheck = True

Should the document be reloaded and have all it’s data checked against?

whatToLoad = []

If loadCheck is true, fill this out with strings of the data keys to check the model against.

model = None

The model being used for this test

data = None

The data being used for this test. Please at least include an ID

action()[source]

Override this with your own function to do whatever you want for the test

load()[source]

Override this to do a custom load check. This should find the key you created or modified in action() and check it’s values to ensure everything was set correctly. By default this loads the model with the test objects data[“id”] and uses whatToLoad to run checks against the data and the model.

cleanup()[source]

Override this to set a custom cleanup process. By default this takes the key that was generated in action() and calls the models .delete() function.

class rethinkORM.tests.test_model.insert_test[source]

Bases: rethinkORM.tests.test_model.base

Tests the basic ability to make a new model instance, and save it to the Database

model

alias of gateModel

action()[source]

Creates a new object, and inserts it, using .save()

class rethinkORM.tests.test_model.modify_test[source]

Bases: rethinkORM.tests.test_model.base

Tests the ability to load, modify and save a model correctly

model

alias of gateModel

action()[source]

Next, we get the object again, and this time, we modify it, and save it.

rethinkORM.tests.test_model.insertBadId_test(*arg, **kw)[source]

Here we test to make sure that if we give a primary key of type None that we are raising an exception, if we don’t get an exception then something is wrong since the primary key shouldn’t be allowed to be None

rethinkORM.tests.test_model.insertIdAndData_test(*arg, **kw)[source]

Make sure that the model raises an Exception when a key and data are provided

class rethinkORM.tests.test_model.new_classmethod_test[source]

Bases: rethinkORM.tests.test_model.base

Tests the new() classmethod of the model

model

alias of gateModel

class rethinkORM.tests.test_model.create_classmethod_test[source]

Bases: rethinkORM.tests.test_model.base

Tests the create() classmethod of the model

Same as the new() classmethod test however we don’t have to explicitly tell the model to save

model

alias of gateModel

class rethinkORM.tests.test_model.find_classmethod_test[source]

Bases: rethinkORM.tests.test_model.base

Tests the find() classmethod of the model

model

alias of gateModel

Table Of Contents

Previous topic

rethinkORM

This Page