提交 dd626d65 编写于 作者: S superjom

add more python test

上级 231c2b3d
...@@ -35,6 +35,7 @@ PYBIND11_MODULE(core, m) { ...@@ -35,6 +35,7 @@ PYBIND11_MODULE(core, m) {
py::class_<vs::StorageHelper>(m, "Storage") py::class_<vs::StorageHelper>(m, "Storage")
.def("timestamp", &vs::StorageHelper::timestamp) .def("timestamp", &vs::StorageHelper::timestamp)
.def("dir", &vs::StorageHelper::dir) .def("dir", &vs::StorageHelper::dir)
.def("set_dir", &vs::StorageHelper::SetDir)
.def("tablets_size", &vs::StorageHelper::tablets_size) .def("tablets_size", &vs::StorageHelper::tablets_size)
.def("buffer", &vs::StorageHelper::buffer) .def("buffer", &vs::StorageHelper::buffer)
.def("human_readable_buffer", &vs::StorageHelper::human_readable_buffer) .def("human_readable_buffer", &vs::StorageHelper::human_readable_buffer)
......
import core
im = core.im()
im.add_tablet("tag0", 50)
tablet = im.tablet("tag0")
tablet.add_scalar_int32(1, 13)
print "buffer", tablet.buffer()
print "buffer", tablet.human_readable_buffer()
import sys
import unittest
sys.path.append('../../build')
import core
im = core.im()
class StorageTester(unittest.TestCase):
def setUp(self):
self.storage = im.storage()
def test_size(self):
self.assertEqual(self.storage.tablets_size(), 0)
im.add_tablet("tag0", 100)
self.assertEqual(self.storage.tablets_size(), 1)
for i in range(1, 11):
im.add_tablet("tag%d" % i, 100)
self.assertEqual(self.storage.tablets_size(), 11)
def test_timestamp(self):
print self.storage.timestamp()
def test_dir(self):
dir = "./1.txt"
self.storage.set_dir(dir)
self.assertEqual(dir, self.storage.dir())
def test_human_readable_buffer(self):
print self.storage.human_readable_buffer()
class TabletTester(unittest.TestCase):
def setUp(self):
self.tablet = im.add_tablet("tag101", 20)
def test_add_scalar(self):
self.tablet.add_scalar_float(1, 0.3)
self.assertEqual(self.tablet.records_size(), 1)
def test_human_readable_buffer(self):
print self.tablet.human_readable_buffer()
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册