mirror of
https://github.com/bspeice/metrik
synced 2024-11-05 06:58:12 -05:00
4d36403c59
Likely needs more tests, but that's all I'm getting done tonight.
28 lines
848 B
Python
28 lines
848 B
Python
from unittest import TestCase
|
|
from pymongo import MongoClient
|
|
|
|
from metrik.conf import MONGO_DATABASE, MONGO_PORT, MONGO_HOST
|
|
from metrik.targets.mongo import MongoTarget
|
|
|
|
|
|
class MongoTest(TestCase):
|
|
def setUp(self):
|
|
self.client = MongoClient(MONGO_HOST, MONGO_PORT)
|
|
self.db = self.client[MONGO_DATABASE]
|
|
|
|
def tearDown(self):
|
|
super(MongoTest, self).tearDown()
|
|
self.client.drop_database(MONGO_DATABASE)
|
|
|
|
|
|
class MongoTestTest(MongoTest):
|
|
# Test that the database is dropped correctly after each test
|
|
def test_round1(self):
|
|
t = MongoTarget('consistent_collection', 'consistent_id')
|
|
assert not t.exists()
|
|
t.persist({'a': 'b'})
|
|
|
|
def test_round2(self):
|
|
t = MongoTarget('consistent_collection', 'consistent_id')
|
|
assert not t.exists()
|
|
t.persist({'a': 'b'}) |