def test_bad_keyspace(self): """Ensure that a bad keyspace results in an errback.""" self.client_proto.set_keyspace.return_value = defer.fail(ttypes.NotFoundException()) client = CQLClient(self.endpoint, 'blah') d = client.describe_version() self.assertFailed(d, ttypes.NotFoundException) self.client_proto.set_keyspace.assert_called_once_with('blah')
def test_describe_version(self): """Connect and check the version.""" client = CQLClient(self.endpoint, 'blah') d = client.describe_version() self.assertEqual(self.assertFired(d), '1.2.3') self.assertEqual(self.client_proto.describe_version.call_count, 1) self.client_proto.set_keyspace.assert_called_once_with('blah')
def test_disconnect(self): """ When disconnect is called, the on demand thrift client is disconnected """ client = CQLClient(self.endpoint, 'blah') self.assertFired(client.describe_version()) client.disconnect() self.twisted_transport.loseConnection.assert_called_once_with()
def test_login(self): """Test that login works as expected.""" client = CQLClient(self.endpoint, 'blah', 'groucho', 'swordfish') d = client.describe_version() self.assertEqual(self.assertFired(d), '1.2.3') self.client_proto.describe_version.assert_called_once_with() self.client_proto.set_keyspace.assert_called_once_with('blah') creds = {'user': '******', 'password': '******'} authreq = ttypes.AuthenticationRequest(creds) self.client_proto.login.assert_called_once_with(authreq)
def test_login(self): """Test that login works as expected.""" client = CQLClient(self.endpoint, "blah", "groucho", "swordfish") d = client.describe_version() self.assertEqual(self.assertFired(d), "1.2.3") self.client_proto.describe_version.assert_called_once_with() self.client_proto.set_keyspace.assert_called_once_with("blah") creds = {"user": "******", "password": "******"} authreq = ttypes.AuthenticationRequest(creds) self.client_proto.login.assert_called_once_with(authreq)