'Test BatchQuery with Models that have a different connection
@since 3.7
@jira_ticket PYTHON-613
@expected_result queries should execute appropriately
@test_category object_mapper'

def test_batch_query_different_connection(self):

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