def test_that_nicola_uses_the_word_laters_twice_word_frequency(self): word_frequency_df = main.run(self.path + self.single_test_json, types=[st.WORD_FREQUENCY]) expected_value = 2 self.assertEqual(expected_value, word_frequency_df["Nicola Scott"]["laters"]) self.assertEqual(0, word_frequency_df["Cameron Hill"]["laters"])
def test_that_generating_user_histogram_data_has_7_nicola_3_cameron(self): occurences_of_cameron_in_data = 3 occurences_of_nicola_in_data = 7 user_histogram_df = main.run(self.path + self.single_test_json, types=[st.USER_HISTOGRAM]) self.assertEqual(occurences_of_cameron_in_data, user_histogram_df["Cameron Hill"]) self.assertEqual(occurences_of_nicola_in_data, user_histogram_df["Nicola Scott"])
def test_that_generating_message_histogram_data_has_accurate_values(self): message_histogram_df = main.run(self.path + self.single_test_json, types=[st.MESSAGE_HISTOGRAM]) camerons_june_17_messages = 2 nicolas_july_18_messages = 1 self.assertEqual(camerons_june_17_messages, message_histogram_df["Cameron Hill"][(2017, 6)]) self.assertEqual(nicolas_july_18_messages, message_histogram_df["Nicola Scott"][(2018, 7)])
def test_that_generating_cumulative_frequency_data_produces_expected_values( self): cumulative_frequency_df = main.run(self.path + self.single_test_json, types=[st.CUMULATIVE_FREQUENCY]) camerons_messages_sent_by_june_17 = 2 nicolas_messages_sent_by_june_17 = 5 camerons_messages_sent_by_july_18 = 3 nicolas_messages_sent_by_july_18 = 7 self.assertEqual(camerons_messages_sent_by_june_17, cumulative_frequency_df["Cameron Hill"][(2017, 6)]) self.assertEqual(nicolas_messages_sent_by_june_17, cumulative_frequency_df["Nicola Scott"][(2017, 6)]) self.assertEqual(camerons_messages_sent_by_july_18, cumulative_frequency_df["Cameron Hill"][(2018, 7)]) self.assertEqual(nicolas_messages_sent_by_july_18, cumulative_frequency_df["Nicola Scott"][(2018, 7)])
def test_that_generating_user_histogram_on_group_data_data_has_expected_results( self): occurences_of_lindsay_in_data = 9 occurences_of_cameron_in_data = 7 occurences_of_ameilia_in_data = 2 occurences_of_douglas_in_data = 1 user_histogram_df = main.run(self.path + self.group_test_json, types=[st.USER_HISTOGRAM]) self.assertEqual(occurences_of_lindsay_in_data, user_histogram_df["Lindsay Young"]) self.assertEqual(occurences_of_cameron_in_data, user_histogram_df["Cameron Hill"]) self.assertEqual(occurences_of_douglas_in_data, user_histogram_df["Douglas Matheson"]) self.assertEqual(occurences_of_ameilia_in_data, user_histogram_df["Amelia Ford"])
def test_that_generating_message_histogram_on_group_data_has_accurate_values( self): message_histogram_df = main.run(self.path + self.group_test_json, types=[st.MESSAGE_HISTOGRAM]) expected_values_for_lindsay = {"2015": 9} expected_values_for_cameron = {"2015": 7} expected_values_for_amelia = {"2015": 2} expected_values_for_douglas = {"2015": 1} self.assertEqual(expected_values_for_lindsay["2015"], message_histogram_df["Lindsay Young"][(2015, 3)]) self.assertEqual(expected_values_for_cameron["2015"], message_histogram_df["Cameron Hill"][(2015, 3)]) self.assertEqual(expected_values_for_amelia["2015"], message_histogram_df["Amelia Ford"][(2015, 3)]) self.assertEqual(expected_values_for_douglas["2015"], message_histogram_df["Douglas Matheson"][(2015, 3)])
def test_that_generating_cumulative_frequency_group_data_produces_expected_values( self): cumulative_frequency_df = main.run(self.path + self.group_test_json, types=[st.CUMULATIVE_FREQUENCY]) expected_values_for_lindsay = {"2015": 9} expected_values_for_cameron = {"2015": 7} expected_values_for_amelia = {"2015": 2} expected_values_for_douglas = {"2015": 1} self.assertEqual(expected_values_for_lindsay["2015"], cumulative_frequency_df["Lindsay Young"][(2015, 3)]) self.assertEqual(expected_values_for_cameron["2015"], cumulative_frequency_df["Cameron Hill"][(2015, 3)]) self.assertEqual(expected_values_for_amelia["2015"], cumulative_frequency_df["Amelia Ford"][(2015, 3)]) self.assertEqual( expected_values_for_douglas["2015"], cumulative_frequency_df["Douglas Matheson"][(2015, 3)])
def test_that_requesting_a_single_data_frame_returns_only_that_data_frame( self): word_frequency_df = main.run(self.path + self.single_test_json, types=[st.CUMULATIVE_FREQUENCY]) self.assertEqual(type(pd.DataFrame()), type(word_frequency_df))