summaryrefslogtreecommitdiffstats
path: root/tests/test_helper.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-02 23:59:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-02 23:59:11 +0000
commitcaea5267cb8e1fea3702adbdf6f68fd37d13b3b7 (patch)
treef06f1da1ab3b6906beca1c3c7222d28ff00766ac /tests/test_helper.py
parentAdding upstream version 12.2.0. (diff)
downloadsqlglot-caea5267cb8e1fea3702adbdf6f68fd37d13b3b7.tar.xz
sqlglot-caea5267cb8e1fea3702adbdf6f68fd37d13b3b7.zip
Adding upstream version 15.0.0.upstream/15.0.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_helper.py')
-rw-r--r--tests/test_helper.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/test_helper.py b/tests/test_helper.py
index d37c03a..82d917e 100644
--- a/tests/test_helper.py
+++ b/tests/test_helper.py
@@ -1,6 +1,7 @@
import unittest
-from sqlglot.helper import tsort
+from sqlglot.dialects import BigQuery, Dialect, Snowflake
+from sqlglot.helper import name_sequence, tsort
class TestHelper(unittest.TestCase):
@@ -29,3 +30,40 @@ class TestHelper(unittest.TestCase):
"c": [],
}
)
+
+ def test_compare_dialects(self):
+ bigquery_class = Dialect["bigquery"]
+ bigquery_object = BigQuery()
+ bigquery_string = "bigquery"
+
+ snowflake_class = Dialect["snowflake"]
+ snowflake_object = Snowflake()
+ snowflake_string = "snowflake"
+
+ self.assertEqual(snowflake_class, snowflake_class)
+ self.assertEqual(snowflake_class, snowflake_object)
+ self.assertEqual(snowflake_class, snowflake_string)
+ self.assertEqual(snowflake_object, snowflake_object)
+ self.assertEqual(snowflake_object, snowflake_string)
+
+ self.assertNotEqual(snowflake_class, bigquery_class)
+ self.assertNotEqual(snowflake_class, bigquery_object)
+ self.assertNotEqual(snowflake_class, bigquery_string)
+ self.assertNotEqual(snowflake_object, bigquery_object)
+ self.assertNotEqual(snowflake_object, bigquery_string)
+
+ self.assertTrue(snowflake_class in {"snowflake", "bigquery"})
+ self.assertTrue(snowflake_object in {"snowflake", "bigquery"})
+ self.assertFalse(snowflake_class in {"bigquery", "redshift"})
+ self.assertFalse(snowflake_object in {"bigquery", "redshift"})
+
+ def test_name_sequence(self):
+ s1 = name_sequence("a")
+ s2 = name_sequence("b")
+
+ self.assertEqual(s1(), "a0")
+ self.assertEqual(s1(), "a1")
+ self.assertEqual(s2(), "b0")
+ self.assertEqual(s1(), "a2")
+ self.assertEqual(s2(), "b1")
+ self.assertEqual(s2(), "b2")