From f556ea9ad72af80c17a456bcc8248e57f2afe0e5 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 25 Mar 2021 09:51:23 +0100 Subject: Start getting the list and frequency of values for a field. --- tests/test_collection.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/test_collection.py') diff --git a/tests/test_collection.py b/tests/test_collection.py index 2af4cfe..d05415f 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -285,6 +285,15 @@ class testSimpleCollection(unittest.TestCase): with open(fname, 'r') as fp: self.assertEqual(entry.yaml_data, fp.read()) + def test_list_values(self): + values = self.collection.get_field_values('position') + values = list(values) + self.assertEqual(len(values), 2) + self.assertEqual(values, [ + {'value': 'somewhere', 'frequency': 2}, + {'value': None, 'frequency': 1}, + ]) + class testComplexCollection(unittest.TestCase): def setUp(self): @@ -455,6 +464,16 @@ class testComplexCollection(unittest.TestCase): self.assertEqual(entry.data['updated'].year, now.year) self.assertEqual(entry.data['version'], 2) + def test_list_values(self): + values = self.collection.get_field_values('position') + values = list(values) + self.assertEqual(values, [ + {'value': b'Somewhere', 'frequency': 1}, + {'value': b'over there', 'frequency': 1}, + {'value': b'somewhere', 'frequency': 1}, + {'value': b'there', 'frequency': 1}, + ]) + class testCollectionWithErrors(unittest.TestCase): def setUp(self): -- cgit v1.2.3