def test_invalid_syntax_triple_colon(self): with self.assertRaises(Exception) as context: hook._split_tablename('alt1:alt2:alt3:dataset.table', 'project') self.assertIn('Use either : or . to specify project', str(context.exception), "") self.assertFalse('Format exception for' in str(context.exception))
def test_invalid_syntax_triple_dot(self): with self.assertRaises(Exception) as context: hook._split_tablename('alt1.alt.dataset.table', 'project') self.assertIn('Expect format of (<project.|<project:)<dataset>.<table>', str(context.exception), "") self.assertFalse('Format exception for' in str(context.exception))
def test_invalid_syntax_column_double_project_var(self): with self.assertRaises(Exception) as context: hook._split_tablename('alt1:alt2:alt.dataset.table', 'project', 'var_x') self.assertIn('Use either : or . to specify project', str(context.exception), "") self.assertIn('Format exception for var_x:', str(context.exception), "")
def test_valid_double_column(self): project, dataset, table = hook._split_tablename('alt1:alt:dataset.table', 'project') self.assertEqual('alt1:alt', project) self.assertEqual("dataset", dataset) self.assertEqual("table", table)
def test_colon_in_project(self): project, dataset, table = hook._split_tablename('alt1:alt.dataset.table', 'project') self.assertEqual('alt1:alt', project) self.assertEqual("dataset", dataset) self.assertEqual("table", table)
def test_sql_split_project_dataset_table(self): project, dataset, table = hook._split_tablename('alternative.dataset.table', 'project') self.assertEqual("alternative", project) self.assertEqual("dataset", dataset) self.assertEqual("table", table)
def test_split_dataset_table(self): project, dataset, table = hook._split_tablename('dataset.table', 'project') self.assertEqual("project", project) self.assertEqual("dataset", dataset) self.assertEqual("table", table)
def test_internal_need_default_project(self): with self.assertRaises(Exception) as context: hook._split_tablename('dataset.table', None) self.assertIn('INTERNAL: No default project is specified', str(context.exception), "")