'Test the sending of data.'

@patch('socket.socket')
def test_send_to_graphite(self, mock_socket):

    self.gf._send_to_graphite('foo')
    self.assertEqual(mock_socket.call_count, 1)
    self.assertEqual(mock_socket.call_args, mock.call(socket.AF_INET, socket.SOCK_STREAM))
    sock = mock_socket.return_value
    self.assertEqual(sock.connect.call_count, 1)
    self.assertEqual(sock.connect.call_args, mock.call(('foo', 123)))
    self.assertEqual(sock.sendall.call_count, 1)
    self.assertEqual(sock.sendall.call_args, mock.call('foo'.encode('ascii')))
    self.assertEqual(sock.send.call_count, 1)
    self.assertEqual(sock.send.call_args, mock.call('\n'.encode('ascii')))
    self.assertEqual(sock.close.call_count, 1)
    self.assertEqual(sock.close.call_args, mock.call())
