Exemplo n.º 1
0
    def test_nick_change_graph(self, mock_get_year_month_day,
                               mock_build_graphs, mock_splice_find):
        mock_splice_find_data = util.load_from_disk(
            self.current_directory +
            "/data/user_test/nick_change_graph/splice_find_list")
        mock_build_graphs_data = util.load_from_disk(
            self.current_directory + "/data/user_test/build_graphs_list")
        mock_get_year_month_day_data = util.load_from_disk(
            self.current_directory + "/data/user_test/get_year_month_day_list")
        mock_splice_find.side_effect = mock_splice_find_data
        mock_build_graphs.side_effect = mock_build_graphs_data
        mock_get_year_month_day.side_effect = mock_get_year_month_day_data
        expected_nick_change_graph_list = util.load_from_disk(
            self.current_directory + "/data/user_test/nick_change_graph_list")
        expected_aggregate_nick_change_graph = util.load_from_disk(
            self.current_directory +
            "/data/user_test/aggregate_nick_change_graph")

        nick_change_graph_list = user.nick_change_graph(self.log_data, True)

        mock_splice_find.side_effect = mock_splice_find_data
        mock_build_graphs.side_effect = mock_build_graphs_data
        mock_get_year_month_day.side_effect = mock_get_year_month_day_data

        aggregate_nick_change_graph = user.nick_change_graph(
            self.log_data, False)

        for i in xrange(len(nick_change_graph_list)):
            self.assertTrue(
                nx.is_isomorphic(expected_nick_change_graph_list[i],
                                 nick_change_graph_list[i]))

        self.assertTrue(
            nx.is_isomorphic(expected_aggregate_nick_change_graph,
                             aggregate_nick_change_graph))
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    def test_nick_change_graph(self):
        expected_nick_change_graph_list = util.load_from_disk(
            self.test_data_dir + "nick_change_graph_list")
        expected_aggregate_nick_change_graph = util.load_from_disk(
            self.test_data_dir + "aggregate_nick_change_graph")

        nick_change_graph_list = user.nick_change_graph(self.log_data, True)

        aggregate_nick_change_graph = user.nick_change_graph(
            self.log_data, False)

        for i in xrange(len(nick_change_graph_list)):
            self.assertTrue(
                nx.is_isomorphic(expected_nick_change_graph_list[i],
                                 nick_change_graph_list[i]))

        self.assertTrue(
            nx.is_isomorphic(expected_aggregate_nick_change_graph,
                             aggregate_nick_change_graph))
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
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"],
Exemplo n.º 6
0
 def test_nick_change_graph(self, log_data):
     update_expected_output_directory(log_data)
     nick_change_graph = user.nick_change_graph(log_data)
     self.assertTrue(compare_graph_outputs(nick_change_graph,
                                           "nick_change_graph.gpickle"),
                     msg=None)
Exemplo n.º 7
0
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")
saver.save_csv(degree_anal_message_numder["in_degree"]["formatted_for_csv"], output_directory, "in_degree")
saver.save_csv(degree_anal_message_numder["total_degree"]["formatted_for_csv"], output_directory, "total_degree")
saver.save_csv(out_degree_node_number, output_directory, "node_out_degree" + starting_date +'-'+ending_date)
Exemplo n.º 8
0
 def test_nick_change_graph(self, log_data):
     update_expected_output_directory(log_data)
     nick_change_graph = user.nick_change_graph(log_data)
     self.assertTrue(compare_graph_outputs(nick_change_graph, "nick_change_graph.gpickle"), msg=None)