def get_latest_event_id(self): """Query the ftp server and determine the latest event id. :return: A string containing a valid event id. :raises: NetworkError """ ftp_client = FtpClient() try: ftp_client_list = ftp_client.get_listing() ftp_client_list.sort(key=lambda x: x.lower()) except NetworkError: raise now = datetime.now() now = int( '%04d%02d%02d%02d%02d%02d' % ( now.year, now.month, now.day, now.hour, now.minute, now.second )) event_id = now + 1 while int(event_id) > now: if len(ftp_client_list) < 1: raise EventIdError('Latest Event Id could not be obtained') event_id = ftp_client_list.pop().split('/')[-1].split('.')[0] if event_id is None: raise EventIdError('Latest Event Id could not be obtained') self.event_id = event_id
def get_latest_event_id(self): """Query the ftp server and determine the latest event id. :return: A string containing a valid event id. :raises: NetworkError """ ftp_client = FtpClient() try: ftp_client_list = ftp_client.get_listing() ftp_client_list.sort(key=lambda x: x.lower()) except NetworkError: raise now = datetime.now() now = int( '%04d%02d%02d%02d%02d%02d' % (now.year, now.month, now.day, now.hour, now.minute, now.second)) event_id = now + 1 while int(event_id) > now: if len(ftp_client_list) < 1: raise EventIdError('Latest Event Id could not be obtained') event_id = ftp_client_list.pop().split('/')[-1].split('.')[0] if event_id is None: raise EventIdError('Latest Event Id could not be obtained') self.event_id = event_id
def test_get_file(self): """Test that the ftp client can fetch a file ok""" client = FtpClient() file_list = client.get_listing() #Make it a single string file_list = '\n'.join(file_list) message = ('Expected outcome:\n%s\nActual outcome:\n%s' % (file_list, self._expectedMatches)) for expected_file in self._expectedMatches: assert re.search(expected_file, file_list), message
def test_get_directory_listing(self): """Check if we can get a nice directory listing""" client = FtpClient() file_list = client.get_listing() #Make it a single string file_list = '\n'.join(file_list) message = ('Expected this list:\n%s\nTo contain these items:\n%s' % (file_list, self._expectedMatches)) for expected_file in self._expectedMatches: assert re.search(expected_file, file_list), message
def test_get_directory_listing(self): """Check if we can get a nice directory listing""" client = FtpClient() file_list = client.get_listing() # Make it a single string file_list = '\n'.join(file_list) expected_output = ['20120726022003.inp.zip', '20120726022003.out.zip'] message = ('Expected this list:\n%s\nTo contain these items:\n%s' % (file_list, expected_output)) for expected_file in expected_output: assert re.search(expected_file, file_list), message
def test_get_file(self): """Test that the ftp client can fetch a file ok""" client = FtpClient() file_list = client.get_listing() #Make it a single string file_list = '\n'.join(file_list) message = ( 'Expected outcome:\n%s\nActual outcome:\n%s' % (file_list, self._expectedMatches)) for expected_file in self._expectedMatches: assert re.search(expected_file, file_list), message
def test_get_directory_listing(self): """Check if we can get a nice directory listing""" client = FtpClient() file_list = client.get_listing() #Make it a single string file_list = '\n'.join(file_list) message = ( 'Expected this list:\n%s\nTo contain these items:\n%s' % (file_list, self._expectedMatches)) for expected_file in self._expectedMatches: assert re.search(expected_file, file_list), message
def test_get_directory_listing(self): """Check if we can get a nice directory listing""" client = FtpClient() file_list = client.get_listing() # Make it a single string file_list = '\n'.join(file_list) expected_output = ['20120726022003.inp.zip', '20120726022003.out.zip'] message = ( 'Expected this list:\n%s\nTo contain these items:\n%s' % (file_list, expected_output)) for expected_file in expected_output: assert re.search(expected_file, file_list), message