def test_read_success_percent(self, mo): collector = Collector(["--persuccess"]) options = collector.parser.options self.assertEquals(options.persuccess, True) collector.collect_statistics() self.assertEquals(collector.success_counter, 2) self.assertEquals(collector.request_counter, 3)
def test_collect_statistics_html(self, parse_answer_count, get_stackexchange_data): uri = "whatever" collector = Collector([ "--since", "2016-06-04 10:00:00", "--until", "2016-06-05 10:00:00", "--output-format", "html" ]) collector.get_stackexchange_data(uri) get_stackexchange_data.assert_called_once_with(uri) # fill asnwers with json file f = open("test.json") collector.answer = f.read() f.close() collector.collect_statistics() self.assertEqual(collector.results['total_accepted_answers'], 1) self.assertEqual(collector.results['accepted_answers_average_score'], 6.0) self.assertEqual(collector.results['average_answers_per_question'], 3.0) self.assertEqual(collector.results['top_ten_answers_comment_count'], { 45535808: 0, 46051675: 0, 45017555: 4 }) collector.produce_report()
def test_10topdict_general(self, mo): collector = Collector(["--persuccess"]) options = collector.parser.options self.assertEquals(options.persuccess, True) collector.collect_statistics() self.assertEquals(collector.success_counter, 4) self.assertEquals(collector.request_counter, 6) expected_dict = { 'in24.inetnebr.com': Counter({ '/shuttle/missions/sts-68/news/another.txt': 1, '/shuttle/missions/sts-68/news/sts-68-mcc-05.txt': 5 }) } self.assertEquals(collector.top10hosts_dict, expected_dict)
def test_collect_success_percent(self): collector = Collector(["--persuccess"], input_file="../data/test_file", output_file="../data/report1.txt") collector.collect_statistics()
def test_top10hosts(self): collector = Collector(["--top10hosts"], input_file="../data/test_file", output_file="../data/report5.txt") collector.collect_statistics()
def test_collect_top10requests(self): collector = Collector(["--top10"], input_file="../data/test_file", output_file="../data/report3.txt") options = collector.parser.options collector.collect_statistics()
def test_collect_fail_percent(self): collector = Collector(["--perfail"], input_file="../data/test_file", output_file="../data/report2.txt") collector.collect_statistics()