2017-04-24 13:14:13 +03:00
|
|
|
# -*- coding: utf-8 -*-
|
2017-08-16 23:48:18 +03:00
|
|
|
from __future__ import unicode_literals
|
2017-04-24 13:14:13 +03:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from infi.clickhouse_orm.models import BufferModel
|
|
|
|
from infi.clickhouse_orm.engines import *
|
|
|
|
from .base_test_with_data import *
|
|
|
|
|
|
|
|
|
|
|
|
class BufferTestCase(TestCaseWithData):
|
|
|
|
|
|
|
|
def _insert_and_check_buffer(self, data, count):
|
|
|
|
self.database.insert(data)
|
2018-08-19 18:22:22 +03:00
|
|
|
self.assertEqual(count, self.database.count(PersonBuffer))
|
2017-04-24 13:14:13 +03:00
|
|
|
|
|
|
|
def _sample_buffer_data(self):
|
|
|
|
for entry in data:
|
|
|
|
yield PersonBuffer(**entry)
|
|
|
|
|
|
|
|
def test_insert_buffer(self):
|
|
|
|
self.database.create_table(PersonBuffer)
|
|
|
|
self._insert_and_check_buffer(self._sample_buffer_data(), len(data))
|
|
|
|
|
|
|
|
|
|
|
|
class PersonBuffer(BufferModel, Person):
|
|
|
|
|
2017-08-16 23:48:18 +03:00
|
|
|
engine = Buffer(Person)
|