'Test to ensure that when the default keyspace is changed in a session and that session,
is set in the connection class, that the new defaul keyspace is honored.
@since 3.1
@jira_ticket PYTHON-486
@expected_result CQLENGINE adopts whatever keyspace is passed in vai the set_session method as default
@test_category object_mapper'

def test_connection_session_switch(self):

    connection.set_session(self.session1)
    sync_table(TestConnectModel)
    TCM1 = TestConnectModel.create(id=1, keyspace=self.keyspace1)
    connection.set_session(self.session2)
    sync_table(TestConnectModel)
    TCM2 = TestConnectModel.create(id=1, keyspace=self.keyspace2)
    connection.set_session(self.session1)
    self.assertEqual(1, TestConnectModel.objects.count())
    self.assertEqual(TestConnectModel.objects.first(), TCM1)
    connection.set_session(self.session2)
    self.assertEqual(1, TestConnectModel.objects.count())
    self.assertEqual(TestConnectModel.objects.first(), TCM2)
