示例#1
0
文件: test_main.py 项目: mkopr/wlm
 def test_print_result(self):
     self.measure.websites_list = WebsiteMeasurement.get_sorted_ranking(
         self.measure.websites_list)
     self.measure.result_data = {'info_1': 1, 'info_2': 2}
     new_output = io.StringIO()
     sys.stdout = new_output
     self.measure.print_result()
     self.assertTrue(self.other_website_1 in new_output.getvalue())
     self.assertTrue(self.other_website_2 in new_output.getvalue())
示例#2
0
文件: main.py 项目: mkopr/wlm
    def save_to_object(self, url: str, start_time: time,
                       end_time: time) -> WebsiteMeasurement:
        """
        Save measurement data to WebsiteMeasurement dataclass.

        :param url: str
        :param start_time: time
        :param end_time: time
        :return: WebsiteMeasurement
        """
        return WebsiteMeasurement(url, start_time, end_time)
示例#3
0
文件: main.py 项目: mkopr/wlm
    def prepare_additional_data(self):
        """
        Create result_data dictionary with data about measurements result
        based on sorted and ranked list of WebsiteMeasurement objects.

        :return: None
        """
        self.websites_list.append(self.main_website)
        self.websites_list = WebsiteMeasurement.get_sorted_ranking(
            self.websites_list)
        result_data = dict()
        result_data['comparison_result'] = self.get_comparison_result()
        result_data['comparison_date'] = str(datetime.datetime.now())

        self.result_data = result_data
示例#4
0
文件: test_website.py 项目: mkopr/wlm
    def setUp(self):
        self.object_1 = WebsiteMeasurement('', 1, 2.22222)
        self.object_2 = WebsiteMeasurement('', 1, 3.33333)
        self.object_3 = WebsiteMeasurement('', 1, 4.44444)

        self.all_objects = [self.object_1, self.object_2, self.object_3]
示例#5
0
文件: test_website.py 项目: mkopr/wlm
 def test_get_sorted_ranking(self):
     ranked_objects = WebsiteMeasurement.get_sorted_ranking(
         self.all_objects)
     self.assertTrue(ranked_objects[0].ranking_place < ranked_objects[1].
                     ranking_place < ranked_objects[2].ranking_place)
示例#6
0
文件: test_website.py 项目: mkopr/wlm
 def test_set_ranking_place(self):
     sorted_objects = WebsiteMeasurement.sort(self.all_objects)
     ranked_objects = WebsiteMeasurement.set_ranking_place(sorted_objects)
     self.assertTrue(ranked_objects[0].ranking_place < ranked_objects[1].
                     ranking_place < ranked_objects[2].ranking_place)
示例#7
0
文件: test_website.py 项目: mkopr/wlm
 def test_sort(self):
     sorted_objects = WebsiteMeasurement.sort(self.all_objects)
     self.assertTrue(sorted_objects[0].time < sorted_objects[1].time <
                     sorted_objects[2].time)
示例#8
0
文件: test_main.py 项目: mkopr/wlm
 def get_website_object(self, url, start_time=time(), end_time=time()):
     return WebsiteMeasurement(url, start_time, end_time)