From e4d39fbf6f5a8c7d125dc68c4aada665f810bd0b Mon Sep 17 00:00:00 2001 From: Kishan Karunaratne Date: Thu, 21 May 2015 17:05:40 -0700 Subject: [PATCH] [PYTHON-207] Test for automatic repreparation error --- .../standard/test_prepared_statements.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/integration/standard/test_prepared_statements.py b/tests/integration/standard/test_prepared_statements.py index 9240996c..a2a9beb8 100644 --- a/tests/integration/standard/test_prepared_statements.py +++ b/tests/integration/standard/test_prepared_statements.py @@ -325,3 +325,31 @@ class PreparedStatementTests(unittest.TestCase): self.assertEqual(results[0].v, None) cluster.shutdown() + + def test_raise_error_on_prepared_statement_execution_dropped_table(self): + """ + test for error in executing prepared statement on a dropped table + + test_raise_error_on_execute_prepared_statement_dropped_table tests that an InvalidRequest is raised when a + prepared statement is executed after its corresponding table is dropped. This happens because if a prepared + statement is invalid, the driver attempts to automatically re-prepare it on a non-existing table. + + @expected_errors InvalidRequest If a prepared statement is executed on a dropped table + + @since 2.6.0 + @jira_ticket PYTHON-207 + @expected_result InvalidRequest error should be raised upon prepared statement execution. + + @test_category prepared_statements + """ + cluster = Cluster(protocol_version=PROTOCOL_VERSION) + session = cluster.connect("test3rf") + + session.execute("CREATE TABLE error_test (k int PRIMARY KEY, v int)") + prepared = session.prepare("SELECT * FROM error_test WHERE k=?") + session.execute("DROP TABLE error_test") + + with self.assertRaises(InvalidRequest): + session.execute(prepared, [0]) + + cluster.shutdown() \ No newline at end of file