Ejemplo n.º 1
0
    def test_statement_sql(self):
        valid_inputs = ["a", "   a", "  a  "]

        for valid in valid_inputs:
            statement = _SqlStatement(valid, [])
            self.assertEqual(valid, statement.sql)

        invalid_inputs = ["", "   ", None, 1]

        for invalid in invalid_inputs:
            with self.assertRaises((ValueError, AssertionError)):
                _SqlStatement(invalid, [])
Ejemplo n.º 2
0
    def test_statement_cursor_buffer_size(self):
        valid_inputs = [1, 10, 999999]

        for valid in valid_inputs:
            statement = _SqlStatement("something", [])
            statement.cursor_buffer_size = valid
            self.assertEqual(valid, statement.cursor_buffer_size)

        invalid_inputs = [0, -10, -99999, "hey", None, 1.0]

        for invalid in invalid_inputs:
            statement = _SqlStatement("something", [])
            with self.assertRaises((ValueError, AssertionError)):
                statement.cursor_buffer_size = invalid
Ejemplo n.º 3
0
    def test_statement_timeout(self):
        valid_inputs = [-1, 0, 15, 1.5]

        for valid in valid_inputs:
            statement = _SqlStatement("sql", [])
            statement.timeout = valid
            self.assertEqual(valid, statement.timeout)

        invalid_inputs = [-10, -100, "hey", None]

        for invalid in invalid_inputs:
            statement = _SqlStatement("sql", [])
            with self.assertRaises((ValueError, AssertionError)):
                statement.timeout = invalid
Ejemplo n.º 4
0
    def test_statement_expected_result_type(self):
        valid_inputs = [
            SqlExpectedResultType.ROWS,
            SqlExpectedResultType.UPDATE_COUNT,
            "ROWS",
            "ANY",
        ]

        for valid in valid_inputs:
            statement = _SqlStatement("something", [])
            statement.expected_result_type = valid
            self.assertEqual(
                try_to_get_enum_value(valid, SqlExpectedResultType),
                statement.expected_result_type)

        invalid_inputs = [None, 123, "hey"]

        for invalid in invalid_inputs:
            with self.assertRaises(TypeError):
                statement = _SqlStatement("something")
                statement.expected_result_type = invalid