# Path: lib/analysis/network.py
# def message_number_graph(log_dict, nicks, nick_same_list, DAY_BY_DAY_ANALYSIS=False):
#     def msg_no_analysis_helper(rec_list, corrected_nick, nick, conn_comp_list,conversations,today_conversation):
#     def message_no_add_egde(message_graph, conversation):
# def channel_user_presence_graph_and_csv(nicks, nick_same_list, channels_for_user, nick_channel_dict, nicks_hash, channels_hash):
#     def create_adj_matrix(hashed_list1, hashed_list2):
#     def add_channel_weighted_edge(graph, adjlist, nicks_hash, channels_hash, channel):
#     def add_common_users_weighted_edge(graph, index1, index2, common_users):
#     def print_node_degree(nodes, max_degree_possible):
#     def inc_degree(degree_list, nodes, max_degree_possible):        
#     def get_top_indices(sum_list, how_many_vals):        
#     def get_indices_to_delete(hash_list, top_indices):
# def filter_edge_list(edgelist_file_loc, max_hash, how_many_top):
# def degree_analysis_on_graph(nx_graph, date=None, directed = True):
#     def nodes_with_degree_populator(degree_values, label): 
#     def give_userlist_where_degree_helper(degree_dict, degree):
#     def raw_node_append(nodes, raw, degree_type):        
# def message_time_graph(log_dict, nicks, nick_same_list, DAY_BY_DAY_ANALYSIS=False):
#     def compare_spliced_nick(nick_to_compare, spliced_nick, nick_name, line):
# def message_number_bins_csv(log_dict, nicks, nick_same_list):
#     def bin_increment(nick_name, messager, nick_spliced, bins, bin_index):
# def degree_node_number_csv(log_dict, nicks, nick_same_list):
#     def format_degree_list(degree_list, max_range, degree_type):
# def nick_receiver_from_conn_comp(nick, conn_comp_list):
# def identify_hubs_and_experts(log_dict, nicks, nick_same_list):
#     G = util.to_graph(nick_same_list)
#     G = util.to_graph(nick_same_list)
# 
# Path: lib/analysis/channel.py
# def conv_len_conv_refr_time(log_dict, nicks, nick_same_list, rt_cutoff_time, cutoff_percentile):
#     def build_conversation(rec_list, nick, send_time, nick_to_search,
#                            nick_receiver, nick_sender, dateadd,
#                            conversations, conn_comp_list, line):
#     def conv_helper(rec, nick, send_time, nick_to_search, nick_receiver,
#                     nick_sender, dateadd, conversations, conn_comp_list, line):
#     def conv_mat_diff(i,j,conversations):
#     def conv_append(conversations, index, dateadd, line):
#     def parse_log_lines_for_conv(log_dict, nicks, conn_comp_list, conversations):
# def response_time(log_dict, nicks, nick_same_list, cutoff_percentile):
#     def build_mean_list(conversations, index, mean_list):
#     def resp_helper(rec, nick, send_time, nick_to_search, nick_receiver, nick_sender, conversations, conn_comp_list):
# def build_stat_dist(number_list):
# def truncate_table(table, cutoff_percentile):
#     G = util.to_graph(nick_same_list)
#     G = util.to_graph(nick_same_list)


import unittest
import os
import lib.in_out.reader as reader
import lib.nickTracker as nickTracker
import lib.util as util
import lib.vis as vis
from lib.analysis import network,channel
from mock import patch


class ChannelProfileTest(unittest.TestCase):

    def setUp(self):
        self.current_directory = os.path.dirname(os.path.realpath(__file__))
        self.log_data_dir = self.current_directory+"/data/input/"
        self.log_data_kubuntu_devel = reader.linux_input(self.log_data_dir,["#kubuntu-devel"], '2013-01-01', '2013-01-31')
        self.nicks, self.nick_same_list = nickTracker.nick_tracker(self.log_data_kubuntu_devel)

    def tearDown(self):
        self.current_directory = None
        self.log_data_dir = None
        self.log_data_kubuntu_devel = None
        self.nicks = None
        self.nick_same_list = None

    def test_activity_graph(self):
        self.expected_result = util.load_from_disk(self.current_directory+"/data/output/activity_graph")

# Path: lib/analysis/network.py
# def message_number_graph(log_dict, nicks, nick_same_list, DAY_BY_DAY_ANALYSIS=False):
#     def msg_no_analysis_helper(rec_list, corrected_nick, nick, conn_comp_list,conversations,today_conversation):
#     def message_no_add_egde(message_graph, conversation):
# def channel_user_presence_graph_and_csv(nicks, nick_same_list, channels_for_user, nick_channel_dict, nicks_hash, channels_hash):
#     def create_adj_matrix(hashed_list1, hashed_list2):
#     def add_channel_weighted_edge(graph, adjlist, nicks_hash, channels_hash, channel):
#     def add_common_users_weighted_edge(graph, index1, index2, common_users):
#     def print_node_degree(nodes, max_degree_possible):
#     def inc_degree(degree_list, nodes, max_degree_possible):        
#     def get_top_indices(sum_list, how_many_vals):        
#     def get_indices_to_delete(hash_list, top_indices):
# def filter_edge_list(edgelist_file_loc, max_hash, how_many_top):
# def degree_analysis_on_graph(nx_graph, date=None, directed = True):
#     def nodes_with_degree_populator(degree_values, label): 
#     def give_userlist_where_degree_helper(degree_dict, degree):
#     def raw_node_append(nodes, raw, degree_type):        
# def message_time_graph(log_dict, nicks, nick_same_list, DAY_BY_DAY_ANALYSIS=False):
#     def compare_spliced_nick(nick_to_compare, spliced_nick, nick_name, line):
# def message_number_bins_csv(log_dict, nicks, nick_same_list):
#     def bin_increment(nick_name, messager, nick_spliced, bins, bin_index):
# def degree_node_number_csv(log_dict, nicks, nick_same_list):
#     def format_degree_list(degree_list, max_range, degree_type):
# def nick_receiver_from_conn_comp(nick, conn_comp_list):
# def identify_hubs_and_experts(log_dict, nicks, nick_same_list):
#     G = util.to_graph(nick_same_list)
#     G = util.to_graph(nick_same_list)
# 
# Path: lib/analysis/channel.py
# def conv_len_conv_refr_time(log_dict, nicks, nick_same_list, rt_cutoff_time, cutoff_percentile):
#     def build_conversation(rec_list, nick, send_time, nick_to_search,
#                            nick_receiver, nick_sender, dateadd,
#                            conversations, conn_comp_list, line):
#     def conv_helper(rec, nick, send_time, nick_to_search, nick_receiver,
#                     nick_sender, dateadd, conversations, conn_comp_list, line):
#     def conv_mat_diff(i,j,conversations):
#     def conv_append(conversations, index, dateadd, line):
#     def parse_log_lines_for_conv(log_dict, nicks, conn_comp_list, conversations):
# def response_time(log_dict, nicks, nick_same_list, cutoff_percentile):
#     def build_mean_list(conversations, index, mean_list):
#     def resp_helper(rec, nick, send_time, nick_to_search, nick_receiver, nick_sender, conversations, conn_comp_list):
# def build_stat_dist(number_list):
# def truncate_table(table, cutoff_percentile):
#     G = util.to_graph(nick_same_list)
#     G = util.to_graph(nick_same_list)


# Path: test/functional-test/test_channelprofile.py
import unittest
import os
import lib.in_out.reader as reader
import lib.nickTracker as nickTracker
import lib.util as util
import lib.vis as vis
from lib.analysis import network,channel
from mock import patch



class ChannelProfileTest(unittest.TestCase):

    def setUp(self):
        self.current_directory = os.path.dirname(os.path.realpath(__file__))
        self.log_data_dir = self.current_directory+"/data/input/"
        self.log_data_kubuntu_devel = reader.linux_input(self.log_data_dir,["#kubuntu-devel"], '2013-01-01', '2013-01-31')
        self.nicks, self.nick_same_list = nickTracker.nick_tracker(self.log_data_kubuntu_devel)

    def tearDown(self):
        self.current_directory = None
        self.log_data_dir = None
        self.log_data_kubuntu_devel = None
        self.nicks = None
        self.nick_same_list = None

    def test_activity_graph(self):
        self.expected_result = util.load_from_disk(self.current_directory+"/data/output/activity_graph")

        bin_matrix, total_messages = network.message_number_bins_csv(self.log_data_kubuntu_devel, self.nicks, self.nick_same_list)