Skip to content
Snippets Groups Projects
Verified Commit c0c2ae64 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

TEST: Actually testing the content.

parent c3c6dfa9
No related branches found
No related tags found
2 merge requests!100WIP: Filling XLSX: Seems to be working.,!99FIX: `to_table` failed on lists
Pipeline #50262 passed with warnings
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment