diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-09-15 16:46:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-09-15 16:46:17 +0000 |
commit | 28cc22419e32a65fea2d1678400265b8cabc3aff (patch) | |
tree | ff9ac1991fd48490b21ef6aa9015a347a165e2d9 /tests/test_helper.py | |
parent | Initial commit. (diff) | |
download | sqlglot-28cc22419e32a65fea2d1678400265b8cabc3aff.tar.xz sqlglot-28cc22419e32a65fea2d1678400265b8cabc3aff.zip |
Adding upstream version 6.0.4.upstream/6.0.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_helper.py')
-rw-r--r-- | tests/test_helper.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_helper.py b/tests/test_helper.py new file mode 100644 index 0000000..d37c03a --- /dev/null +++ b/tests/test_helper.py @@ -0,0 +1,31 @@ +import unittest + +from sqlglot.helper import tsort + + +class TestHelper(unittest.TestCase): + def test_tsort(self): + self.assertEqual(tsort({"a": []}), ["a"]) + self.assertEqual(tsort({"a": ["b", "b"]}), ["b", "a"]) + self.assertEqual(tsort({"a": ["b"]}), ["b", "a"]) + self.assertEqual(tsort({"a": ["c"], "b": [], "c": []}), ["c", "a", "b"]) + self.assertEqual( + tsort( + { + "a": ["b", "c"], + "b": ["c"], + "c": [], + "d": ["a"], + } + ), + ["c", "b", "a", "d"], + ) + + with self.assertRaises(ValueError): + tsort( + { + "a": ["b", "c"], + "b": ["a"], + "c": [], + } + ) |