Beispiel #1
0
    def xxxNOT_WORKING_YETxxxtestUpdateDirtyWithResultTimeKey(self):
        ua_string = ('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) '
                     'Gecko/2009011912 Firefox/3.0.6')
        result_parent = ResultParent.AddResult(self.test_set,
                                               '12.2.2.11',
                                               ua_string,
                                               'apple=0,banana=99,coconut=101',
                                               skip_update_dirty=True)
        skip_rt, update_rt, next_rt = result_parent.GetResultTimes()

        # Make so there is only one ResultTime to schedule after first update.
        skip_rt.dirty = False
        skip_rt.put()

        self.mox.StubOutWithMock(ResultTime, 'UpdateStats')
        self.mox.StubOutWithMock(ResultParent, 'ScheduleUpdateDirty')

        ResultTime.UpdateStats(update_rt)
        ResultParent.ScheduleUpdateDirty(next_rt.key())

        self.mox.ReplayAll()
        response = self.client.get('/admin/update_dirty/some_category',
                                   {'result_time_key': update_rt.key()},
                                   **mock_data.UNIT_TEST_UA)
        self.mox.VerifyAll()
Beispiel #2
0
 def testAddResult(self):
     parent = ResultParent.AddResult(
         self.test_set, '12.2.2.25',
         mock_data.GetUserAgentString('Firefox 3.5'),
         'apple=1,banana=11,coconut=111')
     expected_results = {
         'apple': 1,
         'banana': 11,
         'coconut': 111,
     }
     self.assertEqual(expected_results, parent.GetResults())
Beispiel #3
0
 def testGetMedianAndNumScores(self):
     for scores in ((0, 0, 500), (1, 1, 200), (0, 2, 300), (1, 3, 100),
                    (0, 4, 400)):
         parent = ResultParent.AddResult(
             self.test_set, '12.2.2.25',
             mock_data.GetUserAgentString('Firefox 3.5'),
             'apple=%s,banana=%s,coconut=%s' % scores)
     rankers = self.test_set.GetRankers('Firefox 3')
     self.assertEqual(
         [(0, 5), (2, 5),
          (300, 5)], [ranker.GetMedianAndNumScores() for ranker in rankers])
Beispiel #4
0
 def testGetMedianAndNumScoresWithParams(self):
     params = test_set_params.Params('w-params', 'a=b', 'c=d', 'e=f')
     self.test_set.default_params = params
     for scores in ((1, 0, 2), (1, 1, 1), (0, 2, 200)):
         parent = ResultParent.AddResult(
             self.test_set,
             '12.2.2.25',
             mock_data.GetUserAgentString('Firefox 3.5'),
             'apple=%s,banana=%s,coconut=%s' % scores,
             params_str=str(params))
     ranker = self.test_set.GetTest('coconut').GetRanker('Firefox 3')
     self.assertEqual((2, 3), ranker.GetMedianAndNumScores())
Beispiel #5
0
    def testRecentTestsBasic(self):
        result_parents = []
        for scores in ((1, 4, 50), (1, 1, 20), (0, 2, 30)):
            result = ResultParent.AddResult(
                self.test_set, '1.2.2.5',
                mock_data.GetUserAgentString('Firefox 3.5'),
                'apple=%s,banana=%s,coconut=%s' % scores)
            result_parents.append(result)

        params = {}
        response = self.client.get('/cron/update_recent_tests', params)

        recent_tests = memcache.get(key=util.RECENT_TESTS_MEMCACHE_KEY)
Beispiel #6
0
    def testUpdateDirtyGeneral(self):
        ua_string = ('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) '
                     'Gecko/2009011912 Firefox/3.0.6')

        self.mox.StubOutWithMock(manage_dirty, 'ScheduleCategoryUpdate')
        manage_dirty.ScheduleCategoryUpdate(mox.IgnoreArg())
        self.mox.ReplayAll()
        # AddResult schedules the dirty update.
        result_parent = ResultParent.AddResult(
            self.test_set, '12.2.2.11', ua_string,
            'apple=0,banana=99,coconut=101')
        self.mox.VerifyAll()
        self.assertEqual([False, False, False],
                         [x.dirty for x in result_parent.GetResultTimes()])
Beispiel #7
0
 def testAddResultForTestSetWithAdjustResults(self):
     AddAdjustResults(self.test_set)
     parent = ResultParent.AddResult(
         self.test_set, '12.2.2.25',
         mock_data.GetUserAgentString('Firefox 3.5'),
         'apple=0,banana=80,coconut=200')
     self.assertEqual(0, parent.apple)
     self.assertEqual(80, parent.banana)
     self.assertEqual(200, parent.coconut)
     expected_results = {
         'apple': 0,
         'banana': 40,
         'coconut': 100,
     }
     self.assertEqual(expected_results, parent.GetResults())
Beispiel #8
0
 def testAddResultWithExpando(self):
     AddAdjustResults(self.test_set)
     parent = ResultParent.AddResult(
         self.test_set, '12.2.2.25',
         mock_data.GetUserAgentString('Firefox 3.5'),
         'apple=1,banana=49,coconut=499')
     self.assertEqual(1, parent.apple)
     self.assertEqual(49, parent.banana)
     self.assertEqual(499, parent.coconut)
     expected_results = {
         'apple': 1,
         'banana': 25,
         'coconut': 250,
     }
     self.assertEqual(expected_results, parent.GetResults())
Beispiel #9
0
    def testAddResult(self):
        chrome_ua_string = ('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) '
                            'AppleWebKit/530.1 (KHTML, like Gecko) '
                            'Chrome/2.0.169.1 Safari/530.1')
        ua_string = (
            'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 6.0; Trident/4.0; '
            'chromeframe; SLCC1; .NET CLR 2.0.5077; 3.0.30729),gzip(gfe),gzip(gfe)'
        )

        parent = ResultParent.AddResult(self.test_set,
                                        '12.2.2.25',
                                        ua_string,
                                        'apple=1,banana=3,coconut=500',
                                        js_user_agent_string=chrome_ua_string)
        self.assertEqual(chrome_ua_string,
                         parent.user_agent.js_user_agent_string)
    def testGetStats(self):
        add_result_params = (
            # ((apple, banana, coconut), firefox_version)
            ((0, 0, 500), 'Firefox 3.0.7'),
            ((1, 1, 200), 'Firefox 3.0.7'),
            ((0, 2, 300), 'Firefox 3.0.7'),
            ((1, 3, 100), 'Firefox 3.5'),
            ((0, 4, 400), 'Firefox 3.5'))
        for scores, browser in add_result_params:
            parent = ResultParent.AddResult(
                self.test_set, '12.2.2.25',
                mock_data.GetUserAgentString(browser),
                'apple=%s,banana=%s,coconut=%s' % scores)
        level_1_stats = {
            'Firefox 3': {
                'summary_score': 605,
                'summary_display': '302',
                'total_runs': 5,
                'results': {
                    'coconut': {
                        'score': 600,
                        'raw_score': 300,
                        'display': 'd:600'
                    },
                    'apple': {
                        'score': 1,
                        'raw_score': 0,
                        'display': 'no'
                    },
                    'banana': {
                        'score': 4,
                        'raw_score': 2,
                        'display': 'd:4'
                    }
                }
            },
            'total_runs': 5,
        }
        self.assertEqual(
            level_1_stats,
            result_stats.CategoryStatsManager.GetStats(
                self.test_set,
                browsers=('Firefox 3', ),
                test_keys=['apple', 'banana', 'coconut']))

        level_3_stats = {
            'Firefox 3.0.7': {
                'summary_score': 603,
                'summary_display': '301',
                'total_runs': 3,
                'results': {
                    'coconut': {
                        'score': 600,
                        'raw_score': 300,
                        'display': 'd:600'
                    },
                    'apple': {
                        'score': 1,
                        'raw_score': 0,
                        'display': 'no'
                    },
                    'banana': {
                        'score': 2,
                        'raw_score': 1,
                        'display': 'd:2'
                    }
                }
            },
            'Firefox 3.5': {
                'summary_score': 908,
                'summary_display': '405',
                'total_runs': 2,
                'results': {
                    'coconut': {
                        'score': 800,
                        'raw_score': 400,
                        'display': 'd:800'
                    },
                    'apple': {
                        'score': 100,
                        'raw_score': 1,
                        'display': 'yes'
                    },
                    'banana': {
                        'score': 8,
                        'raw_score': 4,
                        'display': 'd:8'
                    }
                }
            },
            'total_runs': 5,
        }
        self.assertEqual(
            level_3_stats,
            result_stats.CategoryStatsManager.GetStats(
                self.test_set,
                browsers=('Firefox 3.0.7', 'Firefox 3.5'),
                test_keys=['apple', 'banana', 'coconut']))