kyuubi/python/pyhive/tests/test_common.py
Cheng Pan f8c7b93f55
[KYUUBI #5686][FOLLOWUP] Rename pyhive to python
# 🔍 Description

This is the follow-up of #5686, renaming `./pyhive` to `./python`, and also adding `**/python/*` to RAT exclusion list temporarily.

"PyHive" may not be a suitable name after being part of Apache Kyuubi, let's use a generic dir name `python`, and discuss the official name later(we probably keep the code at `./python` eventually).

## Types of changes 🔖

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

Recover RAT checked.

---

# Checklist 📝

- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

**Be nice. Be informative.**

Closes #6279 from pan3793/pyhive-1.

Closes #5686

42d338e71 [Cheng Pan] [KYUUBI #5686][FOLLOWUP] Rename pyhive to python

Authored-by: Cheng Pan <chengpan@apache.org>
Signed-off-by: Cheng Pan <chengpan@apache.org>
2024-04-09 20:30:02 +08:00

41 lines
1.8 KiB
Python

# encoding: utf-8
from __future__ import absolute_import
from __future__ import unicode_literals
from pyhive import common
import datetime
import unittest
class TestCommon(unittest.TestCase):
def test_escape_args(self):
escaper = common.ParamEscaper()
self.assertEqual(escaper.escape_args({'foo': 'bar'}),
{'foo': "'bar'"})
self.assertEqual(escaper.escape_args({'foo': 123}),
{'foo': 123})
self.assertEqual(escaper.escape_args({'foo': 123.456}),
{'foo': 123.456})
self.assertEqual(escaper.escape_args({'foo': ['a', 'b', 'c']}),
{'foo': "('a','b','c')"})
self.assertEqual(escaper.escape_args({'foo': ('a', 'b', 'c')}),
{'foo': "('a','b','c')"})
self.assertIn(escaper.escape_args({'foo': {'a', 'b'}}),
({'foo': "('a','b')"}, {'foo': "('b','a')"}))
self.assertIn(escaper.escape_args({'foo': frozenset(['a', 'b'])}),
({'foo': "('a','b')"}, {'foo': "('b','a')"}))
self.assertEqual(escaper.escape_args(('bar',)),
("'bar'",))
self.assertEqual(escaper.escape_args([123]),
(123,))
self.assertEqual(escaper.escape_args((123.456,)),
(123.456,))
self.assertEqual(escaper.escape_args((['a', 'b', 'c'],)),
("('a','b','c')",))
self.assertEqual(escaper.escape_args((['你好', 'b', 'c'],)),
("('你好','b','c')",))
self.assertEqual(escaper.escape_args((datetime.date(2020, 4, 17),)),
("'2020-04-17'",))
self.assertEqual(escaper.escape_args((datetime.datetime(2020, 4, 17, 12, 0, 0, 123456),)),
("'2020-04-17 12:00:00.123456'",))