File: test_get_bind.py

package info (click to toggle)
python-sqlalchemy-utils 0.41.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,252 kB
  • sloc: python: 13,566; makefile: 141
file content (20 lines) | stat: -rw-r--r-- 561 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
import pytest

from sqlalchemy_utils import get_bind


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

    def test_with_connection(self, session, connection):
        assert get_bind(connection) == connection

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

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