'Tests the use of context queries with non default keyspaces
@since 3.6
@jira_ticket PYTHON-598
@expected_result queries should be routed to appropriate keyspaces
@test_category query'

def test_context_keyspace(self):

    for i in range(5):
        with ContextQuery(TestModel, keyspace='ks4') as tm:
            tm.objects.create(partition=i, cluster=i)
    with ContextQuery(TestModel, keyspace='ks4') as tm:
        self.assertEqual(5, len(tm.objects.all()))
    self.assertEqual(0, len(TestModel.objects.all()))
    for ks in self.KEYSPACES[:2]:
        with ContextQuery(TestModel, keyspace=ks) as tm:
            self.assertEqual(0, len(tm.objects.all()))
    with ContextQuery(TestModel, keyspace='ks4') as tm:
        obj = tm.objects.get(partition=1)
        obj.update(count=42)
        self.assertEqual(42, tm.objects.get(partition=1).count)
