def test_check_table_alias_map(self, mock_catalog): mock_get_column_object = mock_catalog().get_column_object = MagicMock() mock_get_column_object.return_value = 'catalog_value' # key exists ctx = StatementBinderContext() ctx._table_alias_map['alias'] = 'table_obj' result = ctx._check_table_alias_map('alias', 'col_name') mock_get_column_object.assert_called_once_with('table_obj', 'col_name') self.assertEqual(result, 'catalog_value') # key does not exixt mock_get_column_object.reset_mock() ctx = StatementBinderContext() result = ctx._check_table_alias_map('alias', 'col_name') mock_get_column_object.assert_not_called() self.assertEqual(result, None)
def test_search_all_alias_raise_duplicate_error(self): with self.assertRaises(RuntimeError): ctx = StatementBinderContext() ctx._check_table_alias_map = MagicMock() ctx._check_derived_table_alias_map = MagicMock() # duplicate ctx._table_alias_map['alias'] = 'col_name' ctx._derived_table_alias_map['alias'] = 'col_name' ctx._search_all_alias_maps('col_name')