File: test_collate.py

package info (click to toggle)
python-sql 1.4.0-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 436 kB
  • sloc: python: 3,956; sh: 9; makefile: 7
file content (24 lines) | stat: -rw-r--r-- 842 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# This file is part of python-sql.  The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest

from sql import Collate, Column, Table


class TestCollate(unittest.TestCase):
    column = Column(Table('t'), 'c')

    def test_collate(self):
        for collate in [Collate(self.column, 'C'), self.column.collate('C')]:
            self.assertEqual(str(collate), '"c" COLLATE "C"')
            self.assertEqual(collate.params, ())

    def test_collate_no_expression(self):
        collate = Collate("foo", 'C')
        self.assertEqual(str(collate), '%s COLLATE "C"')
        self.assertEqual(collate.params, ("foo",))

    def test_collate_injection(self):
        collate = Collate(self.column, 'C";')
        with self.assertRaises(ValueError):
            str(collate)