Exemple #1
0
    def test_bind_select_statement_union_starts_new_context(self, mock_ctx):
        with patch.object(StatementBinder, 'bind'):
            binder = StatementBinder(StatementBinderContext())
            select_statement = MagicMock()
            select_statement.union_link = None
            binder._bind_select_statement(select_statement)
            self.assertEqual(mock_ctx.call_count, 0)

            binder = StatementBinder(StatementBinderContext())
            select_statement = MagicMock()
            binder._bind_select_statement(select_statement)
            self.assertEqual(mock_ctx.call_count, 1)
Exemple #2
0
 def test_bind_select_statement(self):
     with patch.object(StatementBinder, 'bind') as mock_binder:
         binder = StatementBinder(StatementBinderContext())
         select_statement = MagicMock()
         mocks = [MagicMock(), MagicMock(), MagicMock(), MagicMock()]
         select_statement.target_list = mocks[:2]
         select_statement.orderby_list = [(mocks[2], 0), (mocks[3], 0)]
         binder._bind_select_statement(select_statement)
         mock_binder.assert_any_call(select_statement.from_table)
         mock_binder.assert_any_call(select_statement.where_clause)
         mock_binder.assert_any_call(select_statement.union_link)
         for mock in mocks:
             mock_binder.assert_any_call(mock)