# 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/user.py
# def nick_change_graph(log_dict, DAY_BY_DAY_ANALYSIS=False):
# def top_keywords_for_nick(user_keyword_freq_dict, nick, threshold, min_words_spoken):
# def keywords(log_dict, nicks, nick_same_list):
#     def get_nick_receiver(nick_receiver, rec, nick_to_compare, nick_name, nicks, nick_same_list):
# def keywords_clusters(log_dict, nicks, nick_same_list, output_directory, out_file_name):
#     def build_centroid(km):
# def extended_stop_words(nicks_for_stop_words, stop_word_without_apostrophe):
# 
# Path: lib/in_out/reader.py
# def linux_input(log_directory, channels_requested, starting_date, ending_date):
#     def check_if_path_and_file_is_valid(work_path, channels_requested):
# 
# Path: lib/in_out/saver.py
# def check_if_dir_exists(output_directory):
# def draw_nx_graph(nx_graph, output_directory, output_file_name):
# def save_net_nx_graph(nx_graph, output_directory, output_file_name):
# def save_csv(matrix, output_directory, output_file_name):
# def save_js_arc(reduced_CC_graph, channels_hash, output_directory, output_file_name):
#     A = nx.nx.drawing.nx_agraph.to_agraph(nx_graph)
# 
# Path: lib/nickTracker.py
# def nick_tracker(log_dict, track_users_on_channels = False):
#     def nick_append(nick, nicks, nicks_today_on_this_channel, track_users_on_channels):
# def searchChannel(channel, channel_list):


import unittest
import networkx as nx
import lib.util as util
import lib.config as config
import os
import StringIO
import sys
import filecmp
from lib.analysis import network, user
from lib.in_out import reader , saver
from lib import nickTracker
from networkx.algorithms.components.connected import connected_components
from numpy.testing import assert_array_equal

class UserProfileTest(unittest.TestCase):

    def setUp(self):
        self.current_directory = os.path.dirname(os.path.realpath(__file__))
        self.out_dir = self.current_directory + "/data/output/2013/01/user_tracking/"

# 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/user.py
# def nick_change_graph(log_dict, DAY_BY_DAY_ANALYSIS=False):
# def top_keywords_for_nick(user_keyword_freq_dict, nick, threshold, min_words_spoken):
# def keywords(log_dict, nicks, nick_same_list):
#     def get_nick_receiver(nick_receiver, rec, nick_to_compare, nick_name, nicks, nick_same_list):
# def keywords_clusters(log_dict, nicks, nick_same_list, output_directory, out_file_name):
#     def build_centroid(km):
# def extended_stop_words(nicks_for_stop_words, stop_word_without_apostrophe):
# 
# Path: lib/in_out/reader.py
# def linux_input(log_directory, channels_requested, starting_date, ending_date):
#     def check_if_path_and_file_is_valid(work_path, channels_requested):
# 
# Path: lib/in_out/saver.py
# def check_if_dir_exists(output_directory):
# def draw_nx_graph(nx_graph, output_directory, output_file_name):
# def save_net_nx_graph(nx_graph, output_directory, output_file_name):
# def save_csv(matrix, output_directory, output_file_name):
# def save_js_arc(reduced_CC_graph, channels_hash, output_directory, output_file_name):
#     A = nx.nx.drawing.nx_agraph.to_agraph(nx_graph)
# 
# Path: lib/nickTracker.py
# def nick_tracker(log_dict, track_users_on_channels = False):
#     def nick_append(nick, nicks, nicks_today_on_this_channel, track_users_on_channels):
# def searchChannel(channel, channel_list):


# Path: test/functional-test/test_userprofile.py
import unittest
import networkx as nx
import lib.util as util
import lib.config as config
import os
import StringIO
import sys
import filecmp
from lib.analysis import network, user
from lib.in_out import reader , saver
from lib import nickTracker
from networkx.algorithms.components.connected import connected_components
from numpy.testing import assert_array_equal


class UserProfileTest(unittest.TestCase):

    def setUp(self):
        self.current_directory = os.path.dirname(os.path.realpath(__file__))
        self.out_dir = self.current_directory + "/data/output/2013/01/user_tracking/"

        self.log_data =  reader.linux_input(self.current_directory + "/data/input/", ["#kubuntu-devel", "#kubuntu",  "#ubuntu-devel"], "2013-1-1", "2013-1-7")