def test_msg_time_graph(self, log_data, nicks, nick_same_list): update_expected_output_directory(log_data) msg_time_graph = network.message_time_graph(log_data, nicks, nick_same_list) self.assertTrue(compare_graph_outputs(msg_time_graph, "message_time_graph.gpickle"), msg=None)
def test_degree_analysis_on_nodes(self, log_data, nicks, nick_same_list): update_expected_output_directory(log_data) message_number_graph = network.message_number_graph( log_data, nicks, nick_same_list) message_time_graph = network.message_time_graph( log_data, nicks, nick_same_list) nick_change_graph = user.nick_change_graph(log_data) degree_anal_message_number = network.degree_analysis_on_graph( message_number_graph) degree_anal_message_time = network.degree_analysis_on_graph( message_time_graph) degree_anal_nick_change = network.degree_analysis_on_graph( nick_change_graph) expected_analysis_msg_number = [] expected_analysis_msg_time = [] expected_analysis_nick_change = [] unjson('degree_anal_message_number.json', expected_analysis_msg_number) unjson('degree_anal_message_time.json', expected_analysis_msg_time) unjson('degree_anal_nick_change.json', expected_analysis_nick_change) self.assertDictEqual(degree_anal_message_number, expected_analysis_msg_number[0], msg=None) self.assertDictEqual(degree_anal_message_time, expected_analysis_msg_time[0], msg=None) self.assertDictEqual(degree_anal_nick_change, expected_analysis_nick_change[0], msg=None)
def test_message_time_graph(self, mock_get_nick_sen_rec, mock_correct_last_char_list, \ mock_rec_list_splice, mock_check_if_msg_line, mock_create_connected_nick_list, mock_to_graph): to_graph_ret = util.load_from_disk(self.current_directory + "/data/message_time_graph/to_graph") conn_list = list(connected_components(to_graph_ret)) mock_to_graph.return_value = to_graph_ret mock_rec_list_splice.side_effect = util.load_from_disk( self.current_directory + "/data/message_time_graph/rec_list_splice") mock_create_connected_nick_list.return_value = util.load_from_disk( self.current_directory + "/data/message_time_graph/conn_comp_list") mock_check_if_msg_line.side_effect = util.load_from_disk( self.current_directory + "/data/message_time_graph/check_if_msg_line") mock_get_nick_sen_rec.side_effect = util.load_from_disk( self.current_directory + "/data/message_time_graph/get_nick_sen_rec") mock_correct_last_char_list.side_effect = util.load_from_disk( self.current_directory + "/data/message_time_graph/correct_last_char_list") capturedOutput = StringIO.StringIO() sys.stdout = capturedOutput ret = network.message_time_graph(self.log_data, self.nicks, self.nick_same_list, DAY_BY_DAY_ANALYSIS=False) sys.stdout = sys.__stdout__ capturedOutput.close() mock_to_graph.assert_called_once_with(self.nick_same_list) mock_create_connected_nick_list.assert_called_once_with(conn_list) self.assertTrue( nx.is_isomorphic( ret, util.load_from_disk( self.current_directory + "/data/message_time_graph/msg_time_aggr_graph")))
def test_message_time_graph(self): capturedOutput = StringIO.StringIO() sys.stdout = capturedOutput msg_time_aggr_graph = network.message_time_graph( self.log_data, self.nicks, self.nick_same_list, DAY_BY_DAY_ANALYSIS=False) sys.stdout = sys.__stdout__ capturedOutput.close() self.assertTrue( nx.is_isomorphic( msg_time_aggr_graph, util.load_from_disk(self.test_data_dir + "message_time_graph/msg_time_aggr_graph")))
def test_message_time_graph_day_analysis(self): capturedOutput = StringIO.StringIO() sys.stdout = capturedOutput msg_time_aggr_graph = network.message_time_graph( self.log_data, self.nicks, self.nick_same_list, DAY_BY_DAY_ANALYSIS=True) expected_graph_list = util.load_from_disk( self.test_data_dir + "message_time_graph/msg_time_graph_list") sys.stdout = sys.__stdout__ capturedOutput.close() self.assertTrue( nx.is_isomorphic(msg_time_aggr_graph[0], expected_graph_list[0])) self.assertTrue( nx.is_isomorphic(msg_time_aggr_graph[1], expected_graph_list[1]))
def test_degree_analysis_on_nodes(self, log_data, nicks, nick_same_list): update_expected_output_directory(log_data) message_number_graph = network.message_number_graph(log_data, nicks, nick_same_list) message_time_graph = network.message_time_graph(log_data, nicks, nick_same_list) nick_change_graph = user.nick_change_graph(log_data) degree_anal_message_number = network.degree_analysis_on_graph(message_number_graph) degree_anal_message_time = network.degree_analysis_on_graph(message_time_graph) degree_anal_nick_change = network.degree_analysis_on_graph(nick_change_graph) expected_analysis_msg_number = [] expected_analysis_msg_time = [] expected_analysis_nick_change = [] unjson('degree_anal_message_number.json', expected_analysis_msg_number) unjson('degree_anal_message_time.json', expected_analysis_msg_time) unjson('degree_anal_nick_change.json', expected_analysis_nick_change) self.assertDictEqual(degree_anal_message_number, expected_analysis_msg_number[0], msg=None) self.assertDictEqual(degree_anal_message_time, expected_analysis_msg_time[0], msg=None) self.assertDictEqual(degree_anal_nick_change, expected_analysis_nick_change[0], msg=None)
ending_date = config.ENDING_DATE output_directory = config.OUTPUT_DIRECTORY # ============== INPUT================== log_data = reader.linux_input(log_directory, channel_name, starting_date, ending_date) nicks, nick_same_list = nickTracker.nick_tracker(log_data) # ============== ANALYSIS ============= message_number_graph = network.message_number_graph(log_data, nicks, nick_same_list, False) message_number_graph_day_list = network.message_number_graph( log_data, nicks, nick_same_list, True) degree_anal_message_numder = network.degree_analysis_on_graph( message_number_graph) message_time_graph_list = network.message_time_graph(log_data, nicks, nick_same_list, True) message_time_graph = network.message_time_graph(log_data, nicks, nick_same_list, False) out_degree_node_number, in_degree_node_number, total_degree_node_number = network.degree_node_number_csv( log_data, nicks, nick_same_list) nick_change_graph_list = user.nick_change_graph(log_data, True) bin_matrix, total_messages = network.message_number_bins_csv( log_data, nicks, nick_same_list) conv_len, conv_ref_time = channel.conv_len_conv_refr_time( log_data, nicks, nick_same_list) resp_time = channel.response_time(log_data, nicks, nick_same_list) user.keywords_clusters(log_data, nicks, nick_same_list) network.degree_analysis_on_graph(message_number_graph) # adjCC_graph, adjCC_membership = community.infomap_igraph(ig_graph=None, net_file_location="/home/rohan/Desktop/adjCC.net")
log_directory = config.LOG_DIRECTORY channel_name = config.CHANNEL_NAME starting_date = config.STARTING_DATE ending_date = config.ENDING_DATE output_directory = config.OUTPUT_DIRECTORY # ============== INPUT================== log_data = reader.linux_input(log_directory, channel_name, starting_date, ending_date) nicks, nick_same_list = nickTracker.nick_tracker(log_data) # ============== ANALYSIS ============= message_number_graph = network.message_number_graph(log_data, nicks, nick_same_list, False) message_number_graph_day_list = network.message_number_graph(log_data, nicks, nick_same_list, True) degree_anal_message_numder = network.degree_analysis_on_graph(message_number_graph) message_time_graph_list = network.message_time_graph(log_data, nicks, nick_same_list, True) message_time_graph = network.message_time_graph(log_data, nicks, nick_same_list, False) out_degree_node_number, in_degree_node_number, total_degree_node_number = network.degree_node_number_csv(log_data, nicks, nick_same_list) nick_change_graph_list = user.nick_change_graph(log_data, True) bin_matrix, total_messages = network.message_number_bins_csv(log_data, nicks, nick_same_list) conv_len, conv_ref_time = channel.conv_len_conv_refr_time(log_data, nicks, nick_same_list) resp_time = channel.response_time(log_data, nicks, nick_same_list) user.keywords_clusters(log_data, nicks, nick_same_list) network.degree_analysis_on_graph(message_number_graph) # adjCC_graph, adjCC_membership = community.infomap_igraph(ig_graph=None, net_file_location="/home/rohan/Desktop/adjCC.net") # ============== OUTPUT ================ saver.draw_nx_graph(message_number_graph, output_directory, "message_number_graph") saver.save_csv(degree_anal_message_numder["out_degree"]["formatted_for_csv"], output_directory, "out_degree")