summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/suite/test_results.py
blob: f81e30e0b75240fc6da6e12dc8ac486d3ed9e411 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from .. import fixtures, config
from ..config import requirements
from .. import exclusions
from ..assertions import eq_
from .. import engines

from sqlalchemy import Integer, String, select, util

from ..schema import Table, Column


class RowFetchTest(fixtures.TablesTest):

    @classmethod
    def define_tables(cls, metadata):
        Table('plain_pk', metadata,
                Column('id', Integer, primary_key=True),
                Column('data', String(50))
            )

    @classmethod
    def insert_data(cls):
        config.db.execute(
            cls.tables.plain_pk.insert(),
            [
                {"id":1, "data":"d1"},
                {"id":2, "data":"d2"},
                {"id":3, "data":"d3"},
            ]
        )

    def test_via_string(self):
        row = config.db.execute(
                self.tables.plain_pk.select().\
                    order_by(self.tables.plain_pk.c.id)
            ).first()

        eq_(
            row['id'], 1
        )
        eq_(
            row['data'], "d1"
        )

    def test_via_int(self):
        row = config.db.execute(
                self.tables.plain_pk.select().\
                    order_by(self.tables.plain_pk.c.id)
            ).first()

        eq_(
            row[0], 1
        )
        eq_(
            row[1], "d1"
        )

    def test_via_col_object(self):
        row = config.db.execute(
                self.tables.plain_pk.select().\
                    order_by(self.tables.plain_pk.c.id)
            ).first()

        eq_(
            row[self.tables.plain_pk.c.id], 1
        )
        eq_(
            row[self.tables.plain_pk.c.data], "d1"
        )