File: test_get_bind.py

package info (click to toggle)
python-sqlalchemy-utils 0.30.12-2~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 1,056 kB
  • sloc: python: 10,350; makefile: 160
file content (21 lines) | stat: -rw-r--r-- 566 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
from pytest import raises

from sqlalchemy_utils import get_bind
from tests import TestCase


class TestGetBind(TestCase):
    def test_with_session(self):
        assert get_bind(self.session) == self.connection

    def test_with_connection(self):
        assert get_bind(self.connection) == self.connection

    def test_with_model_object(self):
        article = self.Article()
        self.session.add(article)
        assert get_bind(article) == self.connection

    def test_with_unknown_type(self):
        with raises(TypeError):
            get_bind(None)