def generate_summary_file(): """ We need this function in order to test the real generate_summary_file function. Its name has been changed to __... :return: the time necessary to execute this function """ start_time = time() # Read configuration config = DITICConfig() # List of emails list_emails = set(config.get_email_to_user().keys()) # List of possible status list_status = config.get_list_status() # Let use system config list system = config.get_system() rt_object = RTApi(system['server'], system['username'], system['password']) summary = __generate_summary_file(rt_object, list_emails, list_status) # The summary of all files will be flushed to this file. try: with open(summary_filename(system['working_dir'], system['summary_file']), 'w') as file_handler: dump(summary, file_handler) except IOError as e: raise IOError('Error:' + str(e)) return '%0.2f seconds' % (time() - start_time)
def generate_summary_file(): """ We need this function in order to test the real generate_summary_file function. Its name has been changed to __... :return: the time necessary to execute this function """ start_time = time() # Read configuration config = DITICConfig() # List of emails list_emails = set(config.get_email_to_user().keys()) # List of possible status list_status = config.get_list_status() # Let use system config list system = config.get_system() rt_object = RTApi(system['server'], system['username'], system['password']) summary = __generate_summary_file(rt_object, list_emails, list_status) # The summary of all files will be flushed to this file. try: with open( summary_filename(system['working_dir'], system['summary_file']), 'w') as file_handler: dump(summary, file_handler) except IOError as e: raise IOError('Error:' + str(e)) return '%0.2f seconds' % (time() - start_time)
def test_get_list_status(): test_config = DITICConfig() test_config.list_status = [ 'new', 'open', ] response = test_config.get_list_status() assert response == [ 'new', 'open', ]
def get_summary_info(): """ returns a dictionary with the following format { 'email': { 'status': 'value', ... } ... } :return: """ #generate_summary_file() #retirar o comando generate_summary_file #stats_update_json_file() # retirar o comando update_statistics # Read configuration config = DITICConfig() # List of known emails list_emails = config.get_email_to_user().keys() # List of known status list_status = config.get_list_status() # Let use system config list system = config.get_system() # Get the file information try: with open( summary_filename(system['working_dir'], system['summary_file']), 'r') as file_handler: summary = load(file_handler) except IOError: # If there is an error, then return everything zeroed summary = { email: {status: 0 for status in list_status} for email in list_emails } summary['dir'] = {status: 0 for status in list_status} summary['dir-inbox'] = {status: 0 for status in list_status} summary['unknown'] = {status: 0 for status in list_status} return summary
def get_summary_info(): """ returns a dictionary with the following format { 'email': { 'status': 'value', ... } ... } :return: """ #generate_summary_file() #retirar o comando generate_summary_file #stats_update_json_file() # retirar o comando update_statistics # Read configuration config = DITICConfig() # List of known emails list_emails = config.get_email_to_user().keys() # List of known status list_status = config.get_list_status() # Let use system config list system = config.get_system() # Get the file information try: with open(summary_filename(system['working_dir'], system['summary_file']), 'r') as file_handler: summary = load(file_handler) except IOError: # If there is an error, then return everything zeroed summary = {email: {status: 0 for status in list_status} for email in list_emails} summary['dir'] = {status: 0 for status in list_status} summary['dir-inbox'] = {status: 0 for status in list_status} summary['unknown'] = {status: 0 for status in list_status} return summary