'Test that we cannot override a BatchQuery connection per model
@since 3.7
@jira_ticket PYTHON-613
@expected_result Proper exceptions should be raised
@test_category object_mapper'

def test_batch_query_connection_override(self):

    with self.assertRaises(CQLEngineException):
        with BatchQuery(connection='cluster') as b:
            TestModel.batch(b).using(connection='test').save()
    with self.assertRaises(CQLEngineException):
        with BatchQuery(connection='cluster') as b:
            TestModel.using(connection='test').batch(b).save()
    with ContextQuery(TestModel, AnotherTestModel, connection='cluster') as (tm, atm):
        obj1 = tm.objects.get(partition=1, cluster=1)
        obj1.__connection__ = None
    with self.assertRaises(CQLEngineException):
        with BatchQuery(connection='cluster') as b:
            obj1.using(connection='test').batch(b).save()
    with self.assertRaises(CQLEngineException):
        with BatchQuery(connection='cluster') as b:
            obj1.batch(b).using(connection='test').save()
