mirror of
https://github.com/bspeice/metrik
synced 2024-11-05 06:58:12 -05:00
2232283ec5
The actual code is still running fine.
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from random import randint
|
|
|
|
from metrik.merge import merge, open_connection
|
|
from metrik.conf import get_config
|
|
from test.mongo_test import MongoTest
|
|
|
|
|
|
class MergeTest(MongoTest):
|
|
db2_name = 'metrik_test_2'
|
|
collection_name = 'merge_test'
|
|
|
|
def setUp(self):
|
|
super(MergeTest, self).setUp()
|
|
self.client2 = self.client
|
|
self.db2 = self.client2[self.db2_name]
|
|
|
|
def tearDown(self):
|
|
super(MergeTest, self).tearDown()
|
|
self.client2.drop_database(self.db2_name)
|
|
|
|
def test_left_right_merge(self):
|
|
item_string = str(randint(-9999999, 9999999))
|
|
item = {'string': item_string}
|
|
item_id = self.db[self.collection_name].save(item)
|
|
|
|
merge(self.client, self.client2,
|
|
self.db.name, self.db2.name)
|
|
|
|
assert len(list(self.db[self.collection_name].find())) == 0
|
|
assert len(list(self.db2[self.collection_name].find())) == 1
|
|
|
|
item_retrieved = self.db2[self.collection_name].find_one({'_id': item_id})
|
|
assert item_retrieved is not None
|
|
assert item_retrieved['string'] == item_string
|
|
|