File: test_from.py

package info (click to toggle)
python-sql 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 440 kB
  • sloc: python: 5,028; sh: 9; makefile: 7
file content (25 lines) | stat: -rw-r--r-- 713 bytes parent folder | download | duplicates (2)
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
# 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 CombiningQuery, From, Table


class TestFrom(unittest.TestCase):

    def test_add(self):
        t1 = Table('t1')
        t2 = Table('t2')
        from_ = From([t1]) + t2

        self.assertEqual(from_, [t1, t2])

    def test_invalid_add(self):
        with self.assertRaises(TypeError):
            From([Table('t')]) + 'foo'

    def test_invalid_add_combining_query(self):
        with self.assertRaises(TypeError):
            From([Table('t')]) + CombiningQuery(
                Table('t1').select(), Table('t2').select())