sqlalchemy.testing.eq_

Here are the examples of the python api sqlalchemy.testing.eq_ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

170 Examples 7

Example 1

Project: sqlalchemy Source File: test_query.py
Function: test_and_match
    def test_and_match(self):
        results1 = (matchtable.select().
                    where(and_(matchtable.c.title.match('python'),
                               matchtable.c.title.match('nutshell'))).
                    execute().
                    fetchall())
        eq_([5], [r.id for r in results1])
        results2 = (matchtable.select().
                    where(matchtable.c.title.match('+python +nutshell')).
                    execute().
                    fetchall())
        eq_([5], [r.id for r in results2])

Example 2

Project: sqlalchemy Source File: test_types.py
    def test_set_colspec(self):
        self.metadata = MetaData()
        set_table = self._set_fixture_one()
        eq_(
            colspec(set_table.c.e1),
            "e1 SET('a','b')")
        eq_(colspec(
            set_table.c.e2),
            "e2 SET('a','b') NOT NULL")
        eq_(
            colspec(set_table.c.e3),
            "e3 SET('a','b')")
        eq_(
            colspec(set_table.c.e4),
            "e4 SET('''a''','b')")
        eq_(
            colspec(set_table.c.e5),
            "e5 SET('a','b')")

Example 3

Project: sqlalchemy Source File: test_query.py
    @testing.provide_metadata
    def test_insertid_reserved(self):
        meta = self.metadata
        table = Table(
            'select', meta,
            Column('col', Integer, primary_key=True)
        )
        table.create()

        table.insert().execute(col=7)
        eq_(table.select().scalar(), 7)

Example 4

Project: sqlalchemy Source File: test_dialect.py
    def _test_ssl_arguments(self, dialect):
        kwarg = dialect.create_connect_args(
            make_url("mysql://scott:tiger@localhost:3306/test"
                "?ssl_ca=/ca.pem&ssl_cert=/cert.pem&ssl_key=/key.pem")
        )[1]
        # args that differ among mysqldb and oursql
        for k in ('use_unicode', 'found_rows', 'client_flag'):
            kwarg.pop(k, None)
        eq_(
            kwarg,
            {
                'passwd': 'tiger', 'db': 'test',
                'ssl': {'ca': '/ca.pem', 'cert': '/cert.pem',
                        'key': '/key.pem'},
                'host': 'localhost', 'user': 'scott',
                'port': 3306
            }
        )

Example 5

Project: sqlalchemy Source File: test_query.py
Function: test_and_match
    def test_and_match(self):
        results1 = \
            matchtable.select().where(and_(
                matchtable.c.title.match('python'),
                matchtable.c.title.match('nutshell'))).execute().fetchall()
        eq_([5], [r.id for r in results1])
        results2 = \
            matchtable.select().where(
                matchtable.c.title.match('python AND nutshell'
                                         )).execute().fetchall()
        eq_([5], [r.id for r in results2])

Example 6

Project: sqlalchemy Source File: test_query.py
Function: test_execute
    def test_execute(self):
        cattable.insert().values(id=9, description='Python').execute()

        cats = cattable.select().order_by(cattable.c.id).execute()
        eq_([(9, 'Python')], list(cats))

        result = cattable.insert().values(description='PHP').execute()
        eq_([10], result.inserted_primary_key)
        lastcat = cattable.select().order_by(desc(cattable.c.id)).execute()
        eq_((10, 'PHP'), lastcat.first())

Example 7

Project: sqlalchemy Source File: test_reflection.py
    def test_fk_reflection(self):
        regex = self.parser._re_constraint

        m = regex.match('  CONSTRAINT `addresses_user_id_fkey` '
                        'FOREIGN KEY (`user_id`) '
                        'REFERENCES `users` (`id`) '
                        'ON DELETE CASCADE ON UPDATE CASCADE')
        eq_(m.groups(), ('addresses_user_id_fkey', '`user_id`',
                            '`users`', '`id`', None, 'CASCADE', 'CASCADE'))


        m = regex.match('  CONSTRAINT `addresses_user_id_fkey` '
                        'FOREIGN KEY (`user_id`) '
                        'REFERENCES `users` (`id`) '
                        'ON DELETE CASCADE ON UPDATE SET NULL')
        eq_(m.groups(), ('addresses_user_id_fkey', '`user_id`',
                            '`users`', '`id`', None, 'CASCADE', 'SET NULL'))

Example 8

Project: sqlalchemy Source File: test_reflection.py
    @testing.requires.temp_table_reflection
    def test_get_temp_table_indexes(self):
        insp = inspect(self.bind)
        indexes = insp.get_indexes('user_tmp')
        for ind in indexes:
            ind.pop('dialect_options', None)
        eq_(
            # TODO: we need to add better filtering for indexes/uq constraints
            # that are doubled up
            [idx for idx in indexes if idx['name'] == 'user_tmp_ix'],
            [{'unique': False, 'column_names': ['foo'], 'name': 'user_tmp_ix'}]
        )

Example 9

Project: sqlalchemy Source File: test_firebird.py
    def test_intermixed_comment(self):
        metadata = MetaData(testing.db)

        table_a = Table('a', metadata, autoload=True)

        eq_(table_a.c.id.server_default.arg.text, "0")

Example 10

Project: sqlalchemy Source File: test_events.py
    def test_remove_wrapped_named(self):
        Target = self._wrapped_fixture()

        listen_one = Mock()
        t1 = Target()
        event.listen(t1, "event_one", listen_one, named=True)
        t1.dispatch.event_one("t1")

        eq_(listen_one.mock_calls, [call(x="adapted t1")])
        event.remove(t1, "event_one", listen_one)
        t1.dispatch.event_one("t2")

        eq_(listen_one.mock_calls, [call(x="adapted t1")])

Example 11

Project: sqlalchemy Source File: test_types.py
    def test_timestamp(self):
        """Exercise TIMESTAMP column."""

        dialect = mssql.dialect()

        metadata = MetaData()
        spec, expected = (TIMESTAMP, 'TIMESTAMP')
        t = Table(
            'mssql_ts', metadata,
            Column('id', Integer, primary_key=True),
            Column('t', spec, nullable=None))
        gen = dialect.ddl_compiler(dialect, schema.CreateTable(t))
        testing.eq_(gen.get_column_specification(t.c.t), "t %s" % expected)
        self.assert_(repr(t.c.t))

Example 12

Project: sqlalchemy Source File: test_reflection.py
    @testing.provide_metadata
    def test_indexes_cols(self):
        metadata = self.metadata

        t1 = Table('t', metadata, Column('x', Integer), Column('y', Integer))
        Index('foo', t1.c.x, t1.c.y)
        metadata.create_all()

        m2 = MetaData()
        t2 = Table('t', m2, autoload=True, autoload_with=testing.db)

        eq_(
            set(list(t2.indexes)[0].columns),
            set([t2.c['x'], t2.c.y])
        )

Example 13

Project: sqlalchemy Source File: test_compiler.py
    def test_limit_zero_using_top(self):
        t = table('t', column('x', Integer), column('y', Integer))

        s = select([t]).where(t.c.x == 5).order_by(t.c.y).limit(0)

        self.assert_compile(
            s,
            "SELECT TOP 0 t.x, t.y FROM t WHERE t.x = :x_1 ORDER BY t.y",
            checkparams={'x_1': 5}
        )
        c = s.compile(dialect=mssql.MSDialect())
        eq_(len(c._result_columns), 2)
        assert t.c.x in set(c._create_result_map()['x'][1])

Example 14

Project: sqlalchemy Source File: test_query.py
Function: test_return_value
    def test_return_value(self):
        # test [ticket:3263]
        result = testing.db.execute(
            select([
                matchtable.c.title.match('Agile Ruby Programming').label('ruby'),
                matchtable.c.title.match('Dive Python').label('python'),
                matchtable.c.title
            ]).order_by(matchtable.c.id)
        ).fetchall()
        eq_(
            result,
            [
                (2.0, 0.0, 'Agile Web Development with Ruby On Rails'),
                (0.0, 2.0, 'Dive Into Python'),
                (2.0, 0.0, "Programming Matz's Ruby"),
                (0.0, 0.0, 'The Definitive Guide to Django'),
                (0.0, 1.0, 'Python in a Nutshell')
            ]
        )

Example 15

Project: sqlalchemy Source File: test_reflection.py
    @testing.provide_metadata
    def _test_get_pk_constraint(self, schema=None):
        meta = self.metadata
        users, addresses = self.tables.users, self.tables.email_addresses
        insp = inspect(meta.bind)

        users_cons = insp.get_pk_constraint(users.name, schema=schema)
        users_pkeys = users_cons['constrained_columns']
        eq_(users_pkeys, ['user_id'])

        addr_cons = insp.get_pk_constraint(addresses.name, schema=schema)
        addr_pkeys = addr_cons['constrained_columns']
        eq_(addr_pkeys, ['address_id'])

        with testing.requires.reflects_pk_names.fail_if():
            eq_(addr_cons['name'], 'email_ad_pk')

Example 16

Project: sqlalchemy Source File: test_query.py
    def test_any_w_comparator(self):
        stuff = self.tables.stuff
        stmt = select([stuff.c.id]).where(
            stuff.c.value > any_(select([stuff.c.value])))

        eq_(
            testing.db.execute(stmt).fetchall(),
            [(2,), (3,), (4,), (5,)]
        )

Example 17

Project: sqlalchemy Source File: test_query.py
    @testing.provide_metadata
    def test_insertid_schema_legacy(self):
        meta = self.metadata
        eng = engines.testing_engine(
            options=dict(legacy_schema_aliasing=True))
        meta.bind = eng
        con = eng.connect()
        con.execute('create schema paj')

        @event.listens_for(meta, "after_drop")
        def cleanup(target, connection, **kw):
            connection.execute('drop schema paj')

        tbl = Table('test', meta,
                    Column('id', Integer, primary_key=True), schema='paj')
        tbl.create()
        tbl.insert().execute({'id': 1})
        eq_(tbl.select().scalar(), 1)

Example 18

Project: sqlalchemy Source File: test_types.py
    def test_time_result_processor(self):
        eq_(
            mysql.TIME().result_processor(None, None)(
                    datetime.timedelta(seconds=35, minutes=517,
                            microseconds=450
                    )),
            datetime.time(8, 37, 35, 450)
        )

Example 19

Project: sqlalchemy Source File: test_reflection.py
    @testing.requires.table_reflection
    def test_numeric_reflection(self):
        for typ in self._type_round_trip(
            sql_types.Numeric(18, 5),
        ):
            assert isinstance(typ, sql_types.Numeric)
            eq_(typ.precision, 18)
            eq_(typ.scale, 5)

Example 20

Project: sqlalchemy Source File: test_firebird.py
    def test_tables_are_reflected_same_way(self):
        metadata = MetaData(testing.db)

        table_dom = Table('def_error', metadata, autoload=True)
        table_nodom = Table('def_error_nodom', metadata, autoload=True)

        eq_(table_dom.c.interessi.server_default.arg.text,
            table_nodom.c.interessi.server_default.arg.text)
        eq_(table_dom.c.ritenuta.server_default.arg.text,
            table_nodom.c.ritenuta.server_default.arg.text)
        eq_(table_dom.c.stampato_modulo.server_default.arg.text,
            table_nodom.c.stampato_modulo.server_default.arg.text)

Example 21

Project: sqlalchemy Source File: test_query.py
    def test_simple_inflectional_match(self):
        results = \
            matchtable.select().where(
                matchtable.c.title.match('FORMSOF(INFLECTIONAL, "dives")'
                                         )).execute().fetchall()
        eq_([2], [r.id for r in results])

Example 22

Project: sqlalchemy Source File: test_query.py
Function: test_or_match
    def test_or_match(self):
        results1 = \
            matchtable.select().where(or_(
                matchtable.c.title.match('nutshell'),
                matchtable.c.title.match('ruby'))).\
            order_by(matchtable.c.id).execute().fetchall()
        eq_([3, 5], [r.id for r in results1])
        results2 = \
            matchtable.select().where(
                matchtable.c.title.match(
                    'nutshell OR ruby')).\
            order_by(matchtable.c.id).execute().fetchall()
        eq_([3, 5], [r.id for r in results2])

Example 23

Project: sqlalchemy Source File: test_reflection.py
    @testing.requires.table_reflection
    @testing.provide_metadata
    def test_nullable_reflection(self):
        t = Table('t', self.metadata,
                  Column('a', Integer, nullable=True),
                  Column('b', Integer, nullable=False))
        t.create()
        eq_(
            dict(
                (col['name'], col['nullable'])
                for col in inspect(self.metadata.bind).get_columns('t')
            ),
            {"a": True, "b": False}
        )

Example 24

Project: sqlalchemy Source File: test_query.py
Function: test_match_across_joins
    def test_match_across_joins(self):
        results = matchtable.select().where(
            and_(cattable.c.id == matchtable.c.category_id,
                 or_(cattable.c.description.match('Ruby'),
                     matchtable.c.title.match('nutshell')))).\
            order_by(matchtable.c.id).execute().fetchall()
        eq_([1, 3, 5], [r.id for r in results])

Example 25

Project: sqlalchemy Source File: test_events.py
    def test_double_event_nonwrapped(self):
        Target = self._fixture()

        listen_one = Mock()
        t1 = Target()
        event.listen(t1, "event_one", listen_one)
        event.listen(t1, "event_one", listen_one)

        t1.dispatch.event_one("t1")

        # doubles are eliminated
        eq_(listen_one.mock_calls, [call("t1")])

        # only one remove needed
        event.remove(t1, "event_one", listen_one)
        t1.dispatch.event_one("t2")

        eq_(listen_one.mock_calls, [call("t1")])

Example 26

Project: sqlalchemy Source File: test_types.py
    def test_extract(self):
        from sqlalchemy import extract
        fivedaysago = datetime.datetime.now() \
            - datetime.timedelta(days=5)
        for field, exp in ('year', fivedaysago.year), \
                ('month', fivedaysago.month), ('day', fivedaysago.day):
            r = testing.db.execute(
                select([
                    extract(field, fivedaysago)])
            ).scalar()
            eq_(r, exp)

Example 27

Project: sqlalchemy Source File: test_reflection.py
    @testing.provide_metadata
    def test_indexes_cols_with_commas(self):
        metadata = self.metadata

        t1 = Table('t', metadata,
                        Column('x, col', Integer, key='x'),
                        Column('y', Integer)
                    )
        Index('foo', t1.c.x, t1.c.y)
        metadata.create_all()

        m2 = MetaData()
        t2 = Table('t', m2, autoload=True, autoload_with=testing.db)

        eq_(
            set(list(t2.indexes)[0].columns),
            set([t2.c['x, col'], t2.c.y])
        )

Example 28

Project: sqlalchemy Source File: test_inspect.py
    def test_hierarchy_insp(self):
        class SomeFoo(TestFixture):
            pass

        class SomeSubFoo(SomeFoo):
            pass

        @inspection._inspects(SomeFoo)
        def insp_somefoo(subject):
            return 1

        @inspection._inspects(SomeSubFoo)
        def insp_somesubfoo(subject):
            return 2

        somefoo = SomeFoo()
        eq_(inspect(SomeFoo()), 1)
        eq_(inspect(SomeSubFoo()), 2)

Example 29

Project: sqlalchemy Source File: test_types.py
Function: test_bytes
    def test_bytes(self):
        module = __import__('pymssql')
        input = b('\x80\x03]q\x00X\x03\x00\x00\x00oneq\x01a.')
        expected_result = input
        result = module.Binary(input)
        eq_(result, expected_result)

Example 30

Project: sqlalchemy Source File: test_reflection.py
    @testing.requires.temp_table_reflection
    @testing.requires.view_column_reflection
    @testing.requires.temporary_views
    def test_get_temp_view_columns(self):
        insp = inspect(self.bind)
        cols = insp.get_columns('user_tmp_v')
        eq_(
            [col['name'] for col in cols],
            ['id', 'name', 'foo']
        )

Example 31

Project: sqlalchemy Source File: test_dialect.py
    def test_mysqlconnector_raise_on_warnings_arg(self):
        from sqlalchemy.dialects.mysql import mysqlconnector
        dialect = mysqlconnector.dialect()
        kw = dialect.create_connect_args(
                make_url("mysql+mysqlconnector://u:p@host/db?raise_on_warnings=true")
            )[1]
        eq_(kw['raise_on_warnings'], True)

        kw = dialect.create_connect_args(
                make_url("mysql+mysqlconnector://u:p@host/db?raise_on_warnings=false")
            )[1]
        eq_(kw['raise_on_warnings'], False)


        kw = dialect.create_connect_args(
                make_url("mysql+mysqlconnector://u:p@host/db")
            )[1]
        assert "raise_on_warnings" not in kw

Example 32

Project: sqlalchemy Source File: test_compiler.py
    def test_limit_offset_using_window(self):
        t = table('t', column('x', Integer), column('y', Integer))

        s = select([t]).where(t.c.x == 5).order_by(t.c.y).limit(10).offset(20)

        self.assert_compile(
            s,
            "SELECT anon_1.x, anon_1.y "
            "FROM (SELECT t.x AS x, t.y AS y, "
            "ROW_NUMBER() OVER (ORDER BY t.y) AS mssql_rn "
            "FROM t "
            "WHERE t.x = :x_1) AS anon_1 "
            "WHERE mssql_rn > :param_1 AND mssql_rn <= :param_2 + :param_1",
            checkparams={'param_1': 20, 'param_2': 10, 'x_1': 5}
        )
        c = s.compile(dialect=mssql.MSDialect())
        eq_(len(c._result_columns), 2)
        assert t.c.x in set(c._create_result_map()['x'][1])
        assert t.c.y in set(c._create_result_map()['y'][1])

Example 33

Project: sqlalchemy Source File: test_query.py
Function: test_or_match
    def test_or_match(self):
        results1 = (matchtable.select().
                    where(or_(matchtable.c.title.match('nutshell'),
                              matchtable.c.title.match('ruby'))).
                    order_by(matchtable.c.id).
                    execute().
                    fetchall())
        eq_([1, 3, 5], [r.id for r in results1])
        results2 = (matchtable.select().
                    where(matchtable.c.title.match('nutshell ruby')).
                    order_by(matchtable.c.id).
                    execute().
                    fetchall())
        eq_([1, 3, 5], [r.id for r in results2])

Example 34

Project: sqlalchemy Source File: test_reflection.py
    @testing.requires.view_reflection
    @testing.requires.temp_table_names
    @testing.requires.temporary_views
    def test_get_temp_view_names(self):
        insp = inspect(self.bind)
        temp_table_names = insp.get_temp_view_names()
        eq_(sorted(temp_table_names), ['user_tmp_v'])

Example 35

Project: sqlalchemy Source File: test_query.py
Function: test_match_across_joins
    def test_match_across_joins(self):
        results = (matchtable.select().
                   where(and_(cattable.c.id==matchtable.c.category_id,
                              or_(cattable.c.description.match('Ruby'),
                                  matchtable.c.title.match('nutshell')))).
                   order_by(matchtable.c.id).
                   execute().
                   fetchall())
        eq_([1, 3, 5], [r.id for r in results])

Example 36

Project: sqlalchemy Source File: test_query.py
    @testing.provide_metadata
    def test_insertid_schema(self):
        meta = self.metadata
        eng = engines.testing_engine(
            options=dict(legacy_schema_aliasing=False))
        meta.bind = eng
        con = eng.connect()
        con.execute('create schema paj')

        @event.listens_for(meta, "after_drop")
        def cleanup(target, connection, **kw):
            connection.execute('drop schema paj')

        tbl = Table('test', meta,
                    Column('id', Integer, primary_key=True), schema='paj')
        tbl.create()
        tbl.insert().execute({'id': 1})
        eq_(tbl.select().scalar(), 1)

Example 37

Project: sqlalchemy Source File: test_query.py
    def test_all_w_comparator(self):
        stuff = self.tables.stuff
        stmt = select([stuff.c.id]).where(
            stuff.c.value >= all_(select([stuff.c.value])))

        eq_(
            testing.db.execute(stmt).fetchall(),
            [(5,)]
        )

Example 38

Project: sqlalchemy Source File: test_reflection.py
    @testing.requires.temp_table_reflection
    @testing.requires.unique_constraint_reflection
    def test_get_temp_table_unique_constraints(self):
        insp = inspect(self.bind)
        reflected = insp.get_unique_constraints('user_tmp')
        for refl in reflected:
            # Different dialects handle duplicate index and constraints
            # differently, so ignore this flag
            refl.pop('duplicates_index', None)
        eq_(reflected, [{'column_names': ['name'], 'name': 'user_tmp_uq'}])

Example 39

Project: sqlalchemy Source File: test_types.py
    @testing.provide_metadata
    def test_precision_float_roundtrip(self):
        t = Table('t', self.metadata,
                    Column('scale_value', mysql.DOUBLE(
                            precision=15, scale=12, asdecimal=True)),
                    Column('unscale_value', mysql.DOUBLE(
                            decimal_return_scale=12, asdecimal=True))
            )
        t.create(testing.db)
        testing.db.execute(
            t.insert(), scale_value=45.768392065789,
            unscale_value=45.768392065789
        )
        result = testing.db.scalar(select([t.c.scale_value]))
        eq_(result, decimal.Decimal("45.768392065789"))

        result = testing.db.scalar(select([t.c.unscale_value]))
        eq_(result, decimal.Decimal("45.768392065789"))

Example 40

Project: sqlalchemy Source File: test_query.py
    @testing.provide_metadata
    def test_returning_no_autoinc(self):
        meta = self.metadata
        table = Table(
            't1', meta,
            Column('id', Integer, primary_key=True),
            Column('data', String(50)))
        table.create()
        result = table.insert().values(
            id=1,
            data=func.lower('SomeString')).\
            returning(table.c.id, table.c.data).execute()
        eq_(result.fetchall(), [(1, 'somestring')])

Example 41

Project: sqlalchemy Source File: test_types.py
    @testing.fails_on("mysql+oursql", "TODO: probable OurSQL bug")
    @testing.provide_metadata
    def test_time_roundtrip(self):
        t = Table('mysql_time', self.metadata,
                Column('t1', mysql.TIME())
            )
        t.create()
        t.insert().values(t1=datetime.time(8, 37, 35)).execute()
        eq_(select([t.c.t1]).scalar(), datetime.time(8, 37, 35))

Example 42

Project: SickGear Source File: test_reflection.py
    @testing.requires.table_reflection
    @testing.provide_metadata
    def test_nullable_reflection(self):
        t = Table('t', self.metadata,
                        Column('a', Integer, nullable=True),
                        Column('b', Integer, nullable=False))
        t.create()
        eq_(
            dict(
                (col['name'], col['nullable'])
                for col in inspect(self.metadata.bind).get_columns('t')
            ),
            {"a": True, "b": False}
        )

Example 43

Project: sqlalchemy Source File: test_types.py
    @testing.provide_metadata
    def test_int_roundtrip(self):
        set_table = self._set_fixture_one()
        set_table.create()
        with testing.db.begin() as conn:
            conn.execute(
                set_table.insert(),
                dict(e1=1, e2=2, e3=3, e4=3, e5=0)
            )
            res = conn.execute(set_table.select()).first()
            eq_(
                res,
                (
                    set(['a']), set(['b']), set(['a', 'b']),
                    set(["'a'", 'b']), set([]))
            )

Example 44

Project: sqlalchemy Source File: test_query.py
Function: test_simple_match
    def test_simple_match(self):
        results = \
            matchtable.select().where(
                matchtable.c.title.match('python')).\
            order_by(matchtable.c.id).execute().fetchall()
        eq_([2, 5], [r.id for r in results])

Example 45

Project: sqlalchemy Source File: test_events.py
    def test_remove_plain_named(self):
        Target = self._fixture()

        listen_one = Mock()
        t1 = Target()
        event.listen(t1, "event_one", listen_one, named=True)
        t1.dispatch.event_one("t1")

        eq_(listen_one.mock_calls, [call(x="t1")])
        event.remove(t1, "event_one", listen_one)
        t1.dispatch.event_one("t2")

        eq_(listen_one.mock_calls, [call(x="t1")])

Example 46

Project: SickGear Source File: test_reflection.py
    @testing.requires.table_reflection
    def test_numeric_reflection(self):
        for typ in self._type_round_trip(
                            sql_types.Numeric(18, 5),
                        ):
            assert isinstance(typ, sql_types.Numeric)
            eq_(typ.precision, 18)
            eq_(typ.scale, 5)

Example 47

Project: SickGear Source File: test_reflection.py
    @testing.provide_metadata
    def _test_get_pk_constraint(self, schema=None):
        meta = self.metadata
        users, addresses = self.tables.users, self.tables.email_addresses
        insp = inspect(meta.bind)

        users_cons = insp.get_pk_constraint(users.name, schema=schema)
        users_pkeys = users_cons['constrained_columns']
        eq_(users_pkeys,  ['user_id'])

        addr_cons = insp.get_pk_constraint(addresses.name, schema=schema)
        addr_pkeys = addr_cons['constrained_columns']
        eq_(addr_pkeys,  ['address_id'])

        with testing.requires.reflects_pk_names.fail_if():
            eq_(addr_cons['name'], 'email_ad_pk')

Example 48

Project: sqlalchemy Source File: test_reflection.py
    @testing.requires.temp_table_reflection
    def test_get_temp_table_columns(self):
        meta = MetaData(self.bind)
        user_tmp = self.tables.user_tmp
        insp = inspect(meta.bind)
        cols = insp.get_columns('user_tmp')
        self.assert_(len(cols) > 0, len(cols))

        for i, col in enumerate(user_tmp.columns):
            eq_(col.name, cols[i]['name'])

Example 49

Project: sqlalchemy Source File: test_except.py
    def test_tostring(self):
        try:
            raise sa_exceptions.DBAPIError.instance(
                'this is a message',
                None, OperationalError(), DatabaseError)
        except sa_exceptions.DBAPIError as exc:
            eq_(
                str(exc),
                "(test.base.test_except.OperationalError)  "
                "[SQL: 'this is a message']")

Example 50

Project: sqlalchemy Source File: test_reflection.py
    @testing.provide_metadata
    def test_indexes_cols_with_spaces(self):
        metadata = self.metadata

        t1 = Table('t', metadata, Column('x col', Integer, key='x'),
                                    Column('y', Integer))
        Index('foo', t1.c.x, t1.c.y)
        metadata.create_all()

        m2 = MetaData()
        t2 = Table('t', m2, autoload=True, autoload_with=testing.db)

        eq_(
            set(list(t2.indexes)[0].columns),
            set([t2.c['x col'], t2.c.y])
        )
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4