aboutsummaryrefslogtreecommitdiff
path: root/tests/test_collection.py
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-03-25 09:51:23 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-03-25 09:51:23 +0100
commitf556ea9ad72af80c17a456bcc8248e57f2afe0e5 (patch)
tree2dde9b74d7a1059d51646b5b50420bc73f3548a9 /tests/test_collection.py
parent3abed981be50f84dad531b370d43e13fa093d4da (diff)
Start getting the list and frequency of values for a field.
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r--tests/test_collection.py19
1 files changed, 19 insertions, 0 deletions
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):