From f4fea43c7c1286c69f5fee4059f813afa2117740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Fri, 9 Jul 2021 16:24:26 +0200 Subject: [PATCH] extra unit tests and bugfixes --- README.md | 2 ++ setup.cfg | 2 +- tempsdb/database.pyx | 25 ++++++++++--------------- tests/test_database.py | 9 +++++++++ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 040a7cc..136a2ac 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Consult the docs for how to disable it. * added extra comparison operators for `VarlenEntry` * added `sync` to `VarlenSeries` * fixed a bug with not propagating metadata write exceptions +* fixed a bug with `Database` treating `varlen` and metadata as real time series + ## v0.6.3 diff --git a/setup.cfg b/setup.cfg index 57f81fd..a01c3e7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ # coding: utf-8 [metadata] name = tempsdb -version = 0.6.4a7 +version = 0.6.4a8 long-description = file: README.md long-description-content-type = text/markdown; charset=UTF-8 license_files = LICENSE diff --git a/tempsdb/database.pyx b/tempsdb/database.pyx index b714651..d5b5495 100644 --- a/tempsdb/database.pyx +++ b/tempsdb/database.pyx @@ -80,22 +80,11 @@ cdef class Database: """ cdef: list output = [] - TimeSeries series - VarlenSeries v_series str name + self.checkpoint() with self.lock: - with DictDeleter(self.open_series) as dd: - for series in dd.values(): - if series.closed: - dd.delete() - else: - output.append(series) - with DictDeleter(self.open_varlen_series) as dd: - for v_series in dd.values(): - if v_series.closed: - dd.delete() - else: - output.append(v_series) + output.extend(self.open_series.values()) + output.extend(self.open_varlen_series.values()) return output cpdef int checkpoint(self) except -1: @@ -258,7 +247,13 @@ cdef class Database: :return: a list of series names :rtype: tp.List[str] """ - return os.listdir(self.path) + cdef: + list output = [] + str path + for path in self.path: + if path != 'varlen' and path != 'metadata.txt' and path != 'metadata.minijson': + output.append(path) + return output cpdef list get_all_varlen_series(self): """ diff --git a/tests/test_database.py b/tests/test_database.py index 8538b2d..d1acbe7 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -20,6 +20,15 @@ class TestDatabase(unittest.TestCase): self.db.reload_metadata() self.assertEqual(self.db.metadata, meta) + def test_open_series(self): + self.db.create_series('test4', 2, 20) + self.db.create_series('test5', 2, 20).close() + self.db.create_varlen_series('test5', [10, 20, 10], 2, 20) + self.db.create_varlen_series('test6', [10, 20, 10], 2, 20).close() + self.assertGreaterEqual(len(self.db.get_open_series()), 2) + self.db.close_all_open_series() + self.assertEqual(len(self.db.get_open_series()), 0) + def test_add_series(self): ser = self.db.create_series('hello-world', 1, 10) ser.append(10, b'\x00') -- GitLab