~ubuntu-branches/debian/jessie/sqlalchemy/jessie

« back to all changes in this revision

Viewing changes to test/orm/test_descriptor.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski, Jakub Wilk, Piotr Ożarowski
  • Date: 2013-07-06 20:53:52 UTC
  • mfrom: (1.4.23) (16.1.17 experimental)
  • Revision ID: package-import@ubuntu.com-20130706205352-ryppl1eto3illd79
Tags: 0.8.2-1
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Piotr Ożarowski ]
* New upstream release
* Upload to unstable
* Build depend on python3-all instead of -dev, extensions are not built for
  Python 3.X 

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
from sqlalchemy import Column, Integer, func, String
6
6
from sqlalchemy.ext.declarative import declarative_base
7
7
from sqlalchemy.util import partial
8
 
from test.lib import fixtures
9
 
from test.lib.testing import eq_
 
8
from sqlalchemy.testing import fixtures
 
9
from sqlalchemy.testing import eq_
10
10
 
11
11
class TestDescriptor(descriptor_props.DescriptorProperty):
12
12
    def __init__(self, cls, key, descriptor=None, doc=None,
58
58
            def method1(self):
59
59
                return "method1"
60
60
 
61
 
            def __getitem__(self, key):
62
 
                return 'value'
63
 
 
64
61
        prop = myprop(lambda self:None)
65
62
        Foo.foo = prop
66
63
 
71
68
        assert Foo.foo is not prop
72
69
        assert Foo.foo.attr == 'bar'
73
70
        assert Foo.foo.method1() == 'method1'
74
 
        assert Foo.foo['bar'] == 'value'
75
71
 
76
72
    def test_comparator(self):
77
73
        class Comparator(PropComparator):
85
81
            def method2(self, other):
86
82
                return "method2"
87
83
 
88
 
            # TODO ?
89
 
            #def __getitem__(self, key):
90
 
            #    return 'value'
 
84
            def __getitem__(self, key):
 
85
                return 'value'
91
86
 
92
87
            def __eq__(self, other):
93
88
                return column('foo') == func.upper(other)
98
93
        eq_(Foo.foo.method1(), "method1")
99
94
        eq_(Foo.foo.method2('x'), "method2")
100
95
        assert Foo.foo.attr == 'bar'
101
 
        # TODO ?
102
 
        #assert Foo.foo['bar'] == 'value'
 
96
        assert Foo.foo['bar'] == 'value'
103
97
        eq_(
104
98
            (Foo.foo == 'bar').__str__(),
105
99
            "foo = upper(:upper_1)"