def test_main_fun_path(): """ Function tests file's path which created by main_fun function. """ from soft4recieve_write_Rel2.main_lib import user_group_name2str # Get dictionary of binary files sfd = sort_file_dict(test_path['common']) # Get full first file's name fff_name = sfd[sorted(sfd)[0]] print "First file's name: \n", fff_name print print "Date and time: ", date_from_bin_file(fff_name) # Get list of available data new_packets = get_available_data(sfd) # Get group's names of available data group_data = user_group_name2str(new_packets) print 'Group\'s names of available data: \n', group_data local_path = fun_path['main_fun'] path = local_path(group_data,date_from_bin_file(fff_name)) print 'main_fun path file: \n', path, '\n'
def test_main_fun_path(): """ Function tests file's path which created by main_fun function. """ from soft4recieve_write_Rel2.main_lib import user_group_name2str # Get dictionary of binary files sfd = sort_file_dict(test_path['common']) # Get full first file's name fff_name = sfd[sorted(sfd)[0]] print "First file's name: \n", fff_name print print "Date and time: ", date_from_bin_file(fff_name) # Get list of available data new_packets = get_available_data(sfd) # Get group's names of available data group_data = user_group_name2str(new_packets) print 'Group\'s names of available data: \n', group_data local_path = fun_path['main_fun'] path = local_path(group_data, date_from_bin_file(fff_name)) print 'main_fun path file: \n', path, '\n'
# -*- coding: utf-8 -*- """ This file contains unittests for converter.py. """ import unittest import glob from soft4recieve_write_Rel2.main_lib import get_path,sort_files from soft4recieve_write_Rel2.set_working_path import test_data from soft4recieve_write_Rel2.Converter.converter import get_available_data from soft4recieve_write_Rel2.Converter.converter import show_available_data if __name__ == "__main__": # Create list of files for converting file_list = glob.glob(get_path(test_data)['common'] + '*.dat') # Create dictionary of binary files for converting file_dict = sort_files(file_list,'bin') # Get list of available data new_packets = get_available_data(file_dict) result = show_available_data(new_packets) print result
# main2() print '==================\n' print 'Test main3 func\n==================' # Create dict of named arguments func_pool2 = (test4,test5,test6) # kargs = {'arg1':'1','arg2':'2','arg3':'3'} kargs = {'arg1':None,'arg2':None,'arg3':None} # main3(func_pool2,kargs) print '==================\n' # Get dictionary of binary files sfd = sort_file_dict(test_path['common']) # Get full first file's name fff_name = sfd[sorted(sfd)[0]] # Get list of available data new_packets = get_available_data(sfd) # Get group's names of available data group_data = user_group_name2str(new_packets) print 'Group\'s names of available data: \n', group_data local_path = fun_path['main_fun'] path = local_path(group_data,date_from_bin_file(fff_name)) print "==================================================" # print (test3.__code__.co_varnames) # print 'Attribute test' # test1('3') # print dir(test1) # print test1.__dict __ # help(test1.func_dict)
group_buf = packets[0]['group'] # group_buf = '' for p in packets: p['bin'] = line[p['shift']*2:p['shift']*2 + p['size']*2] buf.append(p) # accumulate data for one group if group_buf != p['group']: # detecting groups changing group_buf = p['group'] buf1.append(buf.pop(-1))# last packet in buf is belonged to next group. moves it to buf1 sub_line = ''.join([i['bin'] for i in buf]) if len(''.join(sub_line.split('23'))): new_pack += [p for p in buf if p['cut_name']] buf = buf1 else: buf = buf1 buf1 = [] return new_pack + buf if __name__ == "__main__": # Create dictionary of binary files for converting file_dict = sort_file_dict(test_path['common']) # result = test1(file_dict) # for i in result: # print i['cut_name'] # print len(result) result = get_available_data(file_dict) print '===============================' print 'Available data: ',set([i['group'] for i in result if i.has_key('group')]) for i in result: print i['cut_name'] # print packets[0]['group']
# main2() print '==================\n' print 'Test main3 func\n==================' # Create dict of named arguments func_pool2 = (test4, test5, test6) # kargs = {'arg1':'1','arg2':'2','arg3':'3'} kargs = {'arg1': None, 'arg2': None, 'arg3': None} # main3(func_pool2,kargs) print '==================\n' # Get dictionary of binary files sfd = sort_file_dict(test_path['common']) # Get full first file's name fff_name = sfd[sorted(sfd)[0]] # Get list of available data new_packets = get_available_data(sfd) # Get group's names of available data group_data = user_group_name2str(new_packets) print 'Group\'s names of available data: \n', group_data local_path = fun_path['main_fun'] path = local_path(group_data, date_from_bin_file(fff_name)) print "==================================================" # print (test3.__code__.co_varnames) # print 'Attribute test' # test1('3') # print dir(test1) # print test1.__dict __ # help(test1.func_dict) # test1.my_file_name = 'test.dat' # test1.__setattr__('my_file_name','test\\test.dat')
""" This file contains unittests for get_available_data function in converter.py """ import unittest import copy from soft4recieve_write_Rel2.set_working_path import test_path from soft4recieve_write_Rel2.Converter.mapping_functions import func_pool from soft4recieve_write_Rel2.Converter.converter import get_available_data, sort_file_dict from soft4recieve_write_Rel2.Converter.converter import edit_func_pool, get_user_data, show_available_data def test1(file_dict): """ """ pass if __name__ == "__main__": # Create dictionary of binary files for converting file_dict = sort_file_dict(test_path['common']) data = get_available_data(file_dict) show_available_data(data) user_data = get_user_data(data) print '===============================' result = edit_func_pool(user_data) # print result for key in result: print result[key] print result.keys()
""" This file contains unittests for get_available_data function in converter.py """ import unittest import copy from soft4recieve_write_Rel2.set_working_path import test_path from soft4recieve_write_Rel2.Converter.mapping_functions import func_pool from soft4recieve_write_Rel2.Converter.converter import get_available_data, sort_file_dict from soft4recieve_write_Rel2.Converter.converter import edit_func_pool, get_user_data, show_available_data def test1(file_dict): """ """ pass if __name__ == "__main__": # Create dictionary of binary files for converting file_dict = sort_file_dict(test_path['common']) data = get_available_data(file_dict) show_available_data(data) user_data = get_user_data(data) print '===============================' result = edit_func_pool(user_data) # print result for key in result: print result[key] print result.keys()
# -*- coding: utf-8 -*- """ This file contains unittests for converter.py. """ import unittest import glob from soft4recieve_write_Rel2.main_lib import get_path, sort_files from soft4recieve_write_Rel2.set_working_path import conv_data, test_data from soft4recieve_write_Rel2.Converter.converter import get_available_data from soft4recieve_write_Rel2.Converter.converter import show_available_data from soft4recieve_write_Rel2.Converter.converter import get_user_data from soft4recieve_write_Rel2.Converter.converter import user_group_name2str if __name__ == "__main__": # Create list of files for converting file_list = glob.glob(get_path(test_data)['common'] + '*.dat') # Create dictionary of binary files for converting file_dict = sort_files(file_list, 'bin') # Get list of available data new_packets = get_available_data(file_dict) # Show list of available data show_available_data(new_packets) user_data = get_user_data(new_packets) # print user_data result = user_group_name2str(user_data) print 'Data group name is: ', result