From c0c2ae64f7c8aa1bebbe7186585d71630f0750fb Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Wed, 24 Apr 2024 12:03:57 +0200
Subject: [PATCH] TEST: Actually testing the content.

---
 unittests/test_table_converter.py | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/unittests/test_table_converter.py b/unittests/test_table_converter.py
index 6c9438c6..436d6359 100644
--- a/unittests/test_table_converter.py
+++ b/unittests/test_table_converter.py
@@ -27,6 +27,7 @@ from tempfile import NamedTemporaryFile
 import caosdb as db
 import pandas as pd
 from caosdb.apiutils import compare_entities
+from numpy import nan
 
 from caosadvancedtools.table_converter import (from_table, from_tsv, to_table,
                                                to_tsv)
@@ -68,7 +69,7 @@ class TableTest(unittest.TestCase):
     def test_list(self):
         r1 = db.Record()
         r1.add_parent("no1")
-        r1.add_property("p1")
+        r1.add_property("p1", value=1)
         r1.add_property("p3", value=23)
         r1.add_property("p4", value=[1])
         r2 = db.Record()
@@ -82,7 +83,18 @@ class TableTest(unittest.TestCase):
         r3.add_property("p5", value=[50, 51])
         c = db.Container()
         c.extend([r1, r2, r3])
-        to_table(c)
+        result = to_table(c)
+        # NaN is hard to compare, so we replace it by -999
+        # autopep8: off
+        assert result.replace(to_replace=nan, value=-999).to_dict() == {
+            'p1': {0: 1,    1: -999,         2: -999    },  # noqa: E202
+            'p3': {0: 23,   1: [30, 31],     2: -999    },  # noqa: E202
+            'p4': {0: [1],  1: [40.0, 41.0], 2: -999    },  # noqa: E202
+            'p2': {0: -999, 1: [20, 21],     2: -999    },  # noqa: E202
+            'p5': {0: -999, 1: -999,         2: [50, 51]}
+        }
+        # autopep8: on
+        assert list(result.dtypes) == [float, object, object, object, object]
 
 
 class FromTsvTest(unittest.TestCase):
-- 
GitLab