def test_check_derived_table_alias_map(self): # key exists ctx = StatementBinderContext() obj1 = MagicMock() obj1.name.lower.return_value = 'col_name1' obj2 = MagicMock() obj2.name.lower.return_value = 'col_name2' objs = [obj1, obj2] ctx._derived_table_alias_map['alias'] = objs result = ctx._check_derived_table_alias_map('alias', 'col_name1') self.assertEqual(result, obj1) # key does not exixt ctx = StatementBinderContext() result = ctx._check_derived_table_alias_map('alias', 'col_name') 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')