def setUpClass(cls): """ Make sure db is clean before starting up. """ db = get_db('localhost', 27017, 'caustic_test') # todo read from config db.connection.drop_database(db)
""" Test the database. Mongod must be running. """ import unittest import shutil from caustic.database import get_db, Users, Instructions from jsongit import JsonGitRepository from dictshield.base import ShieldException from pymongo.errors import DuplicateKeyError db = get_db('localhost', 27017, 'caustic_test') REPO_DIR = 'tmp_git' INSTRUCTION = {'load':'google'} # valid instruction for convenience TAGS = ['useful', 'fun', 'interesting'] class TestUsers(unittest.TestCase): def setUp(self): self.users = Users(db) def tearDown(self): for name in set(db.collection_names()) - set([u'system.indexes']): db[name].drop() def test_create_user(self): """Saving a user should assign an id. """ u = self.users.create('joe') self.assertEquals('joe', u.name)