From ed8b6ad28bacca1db642fa1855ebb7c5f882307e Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sat, 20 Feb 2021 11:18:13 +0100 Subject: New data type: geo (for Geo URIs) --- tests/test_types.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/test_types.py') diff --git a/tests/test_types.py b/tests/test_types.py index 32340d5..21a6d52 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -415,6 +415,26 @@ class testTypes(unittest.TestCase): v = checker.auto("http://example.org") self.assertEqual(v, "http://example.org") + def test_geo(self): + checker = types.LesanaGeo(self._get_field_def('geo'), {}) + + v = checker.empty() + self.assertEqual(v, "") + + v = checker.load("geo:45.81483,9.07524?z=17") + self.assertEqual(v, "geo:45.81483,9.07524?z=17") + + v = checker.load(None) + self.assertEqual(v, None) + + # TODO: improve check for invalid Geo URIs + for u in ("http://example.org",): + with self.assertRaises(types.LesanaValueError): + checker.load(u) + + v = checker.auto("geo:45.81483,9.07524?z=17") + self.assertEqual(v, "geo:45.81483,9.07524?z=17") + def test_yaml(self): checker = types.LesanaYAML(self._get_field_def('yaml'), {}) -- cgit v1.2.3