コード例 #1
0
ファイル: test_expr.py プロジェクト: iffy/norm
    def test_tableAlias(self):
        """
        Should generate a new alias per class, but return the same alias for
        the same class
        """
        class Foo(object):
            __sql_table__ = 'foo'
        class Bar(object):
            __sql_table__ = 'bar'

        state = State()
        self.assertEqual(state.tableAlias(Foo), 'a')
        self.assertEqual(state.tableAlias(Bar), 'b')
        self.assertEqual(state.tableAlias(Foo), 'a')
        self.assertEqual(state.tableAlias(Bar), 'b')
コード例 #2
0
ファイル: test_expr.py プロジェクト: iffy/norm
    def test_compile(self):
        """
        Should call through to compiler with the compiler as a second arg
        """
        called = []
        class Fake(object):
            def compile(self, what, state):
                called.append((what, state))
                return 'foo'

        fake = Fake()
        state = State()
        state.compiler = fake
        r = state.compile('something')
        self.assertEqual(r, 'foo')
        self.assertEqual(called, [('something', state)])