~ubuntu-branches/debian/sid/sqlalchemy/sid

« back to all changes in this revision

Viewing changes to test/orm/test_rel_fn.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski
  • Date: 2014-06-27 20:17:13 UTC
  • mfrom: (1.4.28)
  • Revision ID: package-import@ubuntu.com-20140627201713-g6p1kq8q1qenztrv
Tags: 0.9.6-1
* New upstream release
* Remove Python 3.X build tag files, thanks to Matthias Urlichs for the
  patch (closes: #747852)
* python-fdb isn't in the Debian archive yet so default dialect for firebird://
  URLs is changed to obsolete kinterbasdb, thanks to Russell Stuart for the
  patch (closes: #752145)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
from sqlalchemy.testing import fixtures
4
4
from sqlalchemy.orm import relationships, foreign, remote
5
5
from sqlalchemy import MetaData, Table, Column, ForeignKey, Integer, \
6
 
    select, ForeignKeyConstraint, exc, func, and_
 
6
    select, ForeignKeyConstraint, exc, func, and_, String
7
7
from sqlalchemy.orm.interfaces import ONETOMANY, MANYTOONE, MANYTOMANY
8
8
 
9
9
 
119
119
                        ("composite_target.uid", "composite_target.oid")),
120
120
            )
121
121
 
 
122
        cls.purely_single_col = Table('purely_single_col', m,
 
123
            Column('path', String)
 
124
            )
 
125
 
122
126
    def _join_fixture_overlapping_three_tables(self, **kw):
123
127
        def _can_sync(*cols):
124
128
            for c in cols:
440
444
                    **kw
441
445
                    )
442
446
 
 
447
    def _join_fixture_purely_single_o2m(self, **kw):
 
448
        return relationships.JoinCondition(
 
449
                    self.purely_single_col,
 
450
                    self.purely_single_col,
 
451
                    self.purely_single_col,
 
452
                    self.purely_single_col,
 
453
                    support_sync=False,
 
454
                    primaryjoin=
 
455
                        self.purely_single_col.c.path.like(
 
456
                            remote(
 
457
                                foreign(
 
458
                                    self.purely_single_col.c.path.concat('%')
 
459
                                )
 
460
                            )
 
461
                        )
 
462
                )
 
463
 
 
464
    def _join_fixture_purely_single_m2o(self, **kw):
 
465
        return relationships.JoinCondition(
 
466
                    self.purely_single_col,
 
467
                    self.purely_single_col,
 
468
                    self.purely_single_col,
 
469
                    self.purely_single_col,
 
470
                    support_sync=False,
 
471
                    primaryjoin=
 
472
                        remote(self.purely_single_col.c.path).like(
 
473
                            foreign(self.purely_single_col.c.path.concat('%'))
 
474
                        )
 
475
                )
 
476
 
 
477
 
443
478
    def _assert_non_simple_warning(self, fn):
444
479
        assert_raises_message(
445
480
            exc.SAWarning,
829
864
            ]
830
865
        )
831
866
 
 
867
    def test_determine_local_remote_pairs_purely_single_col_o2m(self):
 
868
        joincond = self._join_fixture_purely_single_o2m()
 
869
        eq_(
 
870
            joincond.local_remote_pairs,
 
871
            [(self.purely_single_col.c.path, self.purely_single_col.c.path)]
 
872
        )
 
873
 
832
874
class DirectionTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL):
833
875
    def test_determine_direction_compound_2(self):
834
876
        joincond = self._join_fixture_compound_expression_2(
862
904
        joincond = self._join_fixture_m2o()
863
905
        is_(joincond.direction, MANYTOONE)
864
906
 
 
907
    def test_determine_direction_purely_single_o2m(self):
 
908
        joincond = self._join_fixture_purely_single_o2m()
 
909
        is_(joincond.direction, ONETOMANY)
 
910
 
 
911
    def test_determine_direction_purely_single_m2o(self):
 
912
        joincond = self._join_fixture_purely_single_m2o()
 
913
        is_(joincond.direction, MANYTOONE)
865
914
 
866
915
class DetermineJoinTest(_JoinFixtures, fixtures.TestBase, AssertsCompiledSQL):
867
916
    __dialect__ = 'default'