File: test_analyze.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 (29 lines) | stat: -rw-r--r-- 936 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
26
27
28
29
from sqlalchemy_utils import analyze
from tests import TestCase


class TestAnalyzeWithPostgres(TestCase):
    dns = 'postgres://postgres@localhost/sqlalchemy_utils_test'

    def test_runtime(self):
        query = self.session.query(self.Article)
        assert analyze(self.connection, query).runtime

    def test_node_types_with_join(self):
        query = (
            self.session.query(self.Article)
            .join(self.Article.category)
        )
        analysis = analyze(self.connection, query)
        assert analysis.node_types == [
            u'Hash Join', u'Seq Scan', u'Hash', u'Seq Scan'
        ]

    def test_node_types_with_index_only_scan(self):
        query = (
            self.session.query(self.Article.name)
            .order_by(self.Article.name)
            .limit(10)
        )
        analysis = analyze(self.connection, query)
        assert analysis.node_types == [u'Limit', u'Index Only Scan']