File: test_flavor.py

package info (click to toggle)
python-sql 1.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 440 kB
  • sloc: python: 5,016; sh: 9; makefile: 7
file content (46 lines) | stat: -rw-r--r-- 1,240 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 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 Flavor


class TestFlavor(unittest.TestCase):

    def test(self):
        Flavor()

    def test_limitstyle(self):
        flavor = Flavor(limitstyle='rownum')

        self.assertEqual(flavor.limitstyle, 'rownum')

    def test_invalid_limitstyle(self):
        with self.assertRaises(ValueError):
            Flavor(limitstyle='foo')

    def test_max_limit(self):
        flavor = Flavor(max_limit=42)

        self.assertEqual(flavor.max_limit, 42)

    def test_invalid_max_limit(self):
        with self.assertRaises(ValueError):
            Flavor(max_limit='foo')

    def test_paramstyle_format(self):
        flavor = Flavor(paramstyle='format')

        self.assertEqual(flavor.paramstyle, 'format')
        self.assertEqual(flavor.param, '%s')

    def test_paramstyle_qmark(self):
        flavor = Flavor(paramstyle='qmark')

        self.assertEqual(flavor.paramstyle, 'qmark')
        self.assertEqual(flavor.param, '?')

    def test_invalid_paramstyle(self):
        with self.assertRaises(ValueError):
            Flavor(paramstyle='foo')