def test_table_and_alias_quotes_alias(self): actual_input = '"table_name" "alias"' table_name = TableName(actual_input) response = table_name.check_validity() self.assertEquals(response, Response.okay()) self.assertEquals(table_name.table, '"table_name"') self.assertEquals(table_name.alias, '"alias"')
def test_schema_table_spaces_quotes(self): actual_input = '"schema"."table name"' table_name = TableName(actual_input) response = table_name.check_validity() self.assertEquals(response, Response.okay()) self.assertEquals(table_name.schema, '"schema"') self.assertEquals(table_name.table, '"table name"')
def test_schema_and_table_no_quotes(self): actual_input = 'schema.table_name' table_name = TableName(actual_input) response = table_name.check_validity() self.assertEquals(response, Response.okay()) self.assertEquals(table_name.schema, 'schema') self.assertEquals(table_name.table, 'table_name')
def test_and_table_no_quotes_alias(self): actual_input = 'table_name alias' table_name = TableName(actual_input) response = table_name.check_validity() self.assertEquals(response, Response.okay()) self.assertEquals(table_name.table, 'table_name') self.assertEquals(table_name.alias, 'alias')
def test_check_inner_query(self): actual_input = ''' SELECT lala,lalala FROM (SELECT * FROM lalaland) ''' select = Select(actual_input) select.check_validity() self.assertEquals(select.response, Response.okay())
def test_check_query_happy_path(self): actual_input = ''' SELECT * FROM schema.table ''' select = Select(actual_input) select.check_validity() self.assertEquals(select.response, Response.okay())
def check_bracket_order(conditional_section): bracket_stack = [] for index, character in enumerate(conditional_section): if character == '(': bracket_stack.append(index) elif character == ')': if len(bracket_stack) == 0: return Response('Brackets don\' match', 1) bracket_stack.pop() if len(bracket_stack) != 0: return Response('Brackets don\' match', 1) return Response.okay()
def test_happy_path(self): actual_input = ''' SELECT * FROM schema.table ''' self.assertEqual(sql_parser.run_parser(actual_input), Response.okay())
def test_check_conditional_happy_path(self): actual_input = ''' greater > lesser ''' actual_conditional = Conditional(actual_input) self.assertEqual(actual_conditional.check_validity(), Response.okay())