# 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):


import unittest
import lib.config as config
import lib.nickTracker as nickTracker
import networkx as nx
import lib.util as util
import os
import StringIO
import sys
import filecmp
from lib.analysis import user
from lib.in_out import reader
from mock import patch

    def setUp(self):
        self.current_directory = os.path.dirname(os.path.realpath(__file__))
        self.test_data_dir = self.current_directory + "/../../../data/test_lib/test_analysis/user_test/"
        self.log_data = util.load_from_disk(self.test_data_dir + "log_data")
        self.nicks = util.load_from_disk(self.test_data_dir + "nicks")
        self.nick_same_list = util.load_from_disk(self.test_data_dir + "nick_same_list")


    def tearDown(self):
        self.current_directory = None
        self.test_data_dir = None
        self.log_data = None
        self.nicks = None
        self.nick_same_list = None


    @patch("lib.util.splice_find", autospec = True)
    @patch("lib.util.build_graphs", autospec = True)
    @patch("lib.util.get_year_month_day", autospec = True)
    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.test_data_dir + "nick_change_graph_list")
        expected_aggregate_nick_change_graph = util.load_from_disk(self.test_data_dir + "aggregate_nick_change_graph")


# 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: test/unit-test/test_lib/test_analysis/test_user.py
import unittest
import lib.config as config
import lib.nickTracker as nickTracker
import networkx as nx
import lib.util as util
import os
import StringIO
import sys
import filecmp
from lib.analysis import user
from lib.in_out import reader
from mock import patch


    def setUp(self):
        self.current_directory = os.path.dirname(os.path.realpath(__file__))
        self.test_data_dir = self.current_directory + "/../../../data/test_lib/test_analysis/user_test/"
        self.log_data = util.load_from_disk(self.test_data_dir + "log_data")
        self.nicks = util.load_from_disk(self.test_data_dir + "nicks")
        self.nick_same_list = util.load_from_disk(self.test_data_dir + "nick_same_list")


    def tearDown(self):
        self.current_directory = None
        self.test_data_dir = None
        self.log_data = None
        self.nicks = None
        self.nick_same_list = None


    @patch("lib.util.splice_find", autospec = True)
    @patch("lib.util.build_graphs", autospec = True)
    @patch("lib.util.get_year_month_day", autospec = True)
    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.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)