import pandas as pd
from lexos.models.similarity_model import SimilarityModel
from lexos.receivers.similarity_receiver import SimilarityOption


# --------------------- test with similarity equals one --------------------
def test_with_similarity_equal_one():
    test_dtm = pd.DataFrame([[0.0, 0.0, 9.0, 9.0, 0.0, 0.0, 5.0, 4.0, 0.0, 9.0,
                              0.0, 0.0, 0.0, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0],
                             [0.0, 0.0, 9.0, 9.0, 0.0, 0.0, 0.0, 4.0, 5.0, 9.0,
                              0.0, 0.0, 0.0, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0],
                             [5.0, 10.0, 0.0, 0.0, 10.0, 5.0, 0.0, 0.0, 0.0,
                              0.0,
                              10.0, 5.0, 5.0, 5.0, 5.0, 0.0, 5.0, 5.0, 5.0]],
                            index=[0, 1, 2])
    test_option = SimilarityOption(comp_file_id=2)
    test_id_table = {0: "F1.txt", 1: "F2.txt", 2: "F3.txt"}
    similarity_model = SimilarityModel(test_dtm=test_dtm,
                                       test_option=test_option,
                                       test_id_temp_label_map=test_id_table)
    scores = similarity_model.get_similarity_score()
    labels = similarity_model.get_similarity_label()
    assert scores == '1.0***1.0***'
    assert labels == "F1.txt***F2.txt***"
# --------------------------------------------------------------------------


# --------------------- test with all same content -------------------------
def test_with_all_same_content_file():
    test_dtm = pd.DataFrame([[9.0, 9.0, 5.0, 4.0, 0.0, 9.0, 9.0],
                             [9.0, 9.0, 5.0, 4.0, 0.0, 9.0, 9.0],
                             [9.0, 9.0, 5.0, 4.0, 0.0, 9.0, 9.0]],
                            index=[0, 1, 2])
    test_option = SimilarityOption(comp_file_id=1)
    test_id_table = {0: "F1.txt", 1: "F2.txt", 2: "F3.txt"}
    similarity_model = SimilarityModel(test_dtm=test_dtm,
                                       test_option=test_option,
                                       test_id_temp_label_map=test_id_table)
    scores = similarity_model.get_similarity_score()
    labels = similarity_model.get_similarity_label()
    assert scores == '0.0***0.0***'
    assert labels == "F1.txt***F3.txt***"
# --------------------------------------------------------------------------

"""


    def test_with_two_dimension(self):
        dtm_data_frame = pd.DataFrame([[0.0, 1.0], [1.0, 2.0], [2.0, 1.0]],
                                      index=['file_1', 'file_2', 'file_3'])
        comp_file_index = 0
        assert_frame_equal(similarity_maker(dtm_data_frame, comp_file_index),
                           pd.DataFrame([[0.1056], [0.5528]],
                                        index=['file_2', 'file_3'],
                                        columns=["Cosine similarity"]))

    def test_with_three_dimension(self):
        dtm_data_frame = pd.DataFrame([[1.0, 1.0, 1.0],
                                       [1.0, 0.0, 0.0],
                                       [0.0, 2.0, 1.0]],
                                      index=['file_1', 'file_2', 'file_3'])
        comp_file_index = 1
        assert_frame_equal(similarity_maker(dtm_data_frame, comp_file_index),
                           pd.DataFrame([[0.4226], [1.0]],
                                        index=['file_1', 'file_3'],
                                        columns=["Cosine similarity"]))

    def test_similarity_maker_non_neg_index_precondition(self):
        try:
            dtm_data_frame = pd.DataFrame([[1.0], [1.0]],
                                          index=['test_1', 'test_2'])
            _ = similarity_maker(dtm_data_frame, comp_file_index=-1)
            raise AssertionError("negative index error did not raise.")
        except AssertionError as error:
            assert str(error) == NON_NEGATIVE_INDEX_MESSAGE
"""

@@ -2305,16 +2305,893 @@
 ------%0A%0A
+%0A# --------------------- test with with two dimension -----------------------%0Adef test_with_two_dimension():%0A    test_dtm = pd.DataFrame(%5B%5B0.0, 1.0%5D, %5B1.0, 2.0%5D, %5B2.0, 1.0%5D%5D,%0A                            index=%5B0, 1, 2%5D)%0A    test_option = SimilarityOption(comp_file_id=0)%0A    test_id_table = %7B0: %22F1.txt%22, 1: %22F2.txt%22, 2: %22F3.txt%22%7D%0A    similarity_model = SimilarityModel(test_dtm=test_dtm,%0A                                       test_option=test_option,%0A                                       test_id_temp_label_map=test_id_table)%0A    scores = similarity_model.get_similarity_score()%0A    labels = similarity_model.get_similarity_label()%0A    assert scores == '0.1056***0.5528***'%0A    assert labels == %22F2.txt***F3.txt***%22%0A# --------------------------------------------------------------------------%0A%0A%0A# --------------------- test with with two dimension -----------------------%0A%0A
 %22%22%22%0A%0A%0A  

update test