• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python crashes.Crashes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中socorro.external.postgresql.crashes.Crashes的典型用法代码示例。如果您正苦于以下问题:Python Crashes类的具体用法?Python Crashes怎么用?Python Crashes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Crashes类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_exploitibility_by_report_date

    def test_get_exploitibility_by_report_date(self):
        crashes = Crashes(config=self.config)
        yesterday_date = (self.now - datetime.timedelta(days=1)).date()
        yesterday = datetimeutil.date_to_string(yesterday_date)

        res_expected = {
            "hits": [
                {
                    "signature": "canIhaveYourSignature()",
                    "null_count": 2,
                    "none_count": 2,
                    "low_count": 2,
                    "medium_count": 2,
                    "high_count": 2
                },
                {
                    "signature": "ofCourseYouCan()",
                    "null_count": 4,
                    "none_count": 3,
                    "low_count": 2,
                    "medium_count": 1,
                    "high_count": 0
                }
            ],
            "total": 2,
        }

        res = crashes.get_exploitability(
            start_date=yesterday,
            end_date=yesterday
        )
        eq_(res, res_expected)
开发者ID:snorp,项目名称:socorro,代码行数:32,代码来源:test_crashes.py


示例2: test_get_exploitibility

    def test_get_exploitibility(self):
        crashes = Crashes(config=self.config)

        res_expected = {
            "hits": [
                {
                    "signature": "canIhaveYourSignature()",
                    "null_count": 2,
                    "none_count": 3,
                    "low_count": 4,
                    "medium_count": 5,
                    "high_count": 6
                },
                {
                    "signature": "ofCourseYouCan()",
                    "null_count": 5,
                    "none_count": 7,
                    "low_count": 2,
                    "medium_count": 2,
                    "high_count": 0
                }
            ],
            "total": 2,
        }

        res = crashes.get_exploitability()
        self.assertEqual(res, res_expected)
开发者ID:FishingCactus,项目名称:socorro,代码行数:27,代码来源:test_crashes.py


示例3: test_get_exploitibility_by_product

    def test_get_exploitibility_by_product(self):
        crashes = Crashes(config=self.config)

        res_expected = {
            "hits": [
                {
                    "signature": "canIhaveYourSignature()",
                    "null_count": 0,
                    "none_count": 1,
                    "low_count": 2,
                    "medium_count": 3,
                    "high_count": 4
                },
                {
                    "signature": "ofCourseYouCan()",
                    "null_count": 5,
                    "none_count": 7,
                    "low_count": 2,
                    "medium_count": 2,
                    "high_count": 0
                },

            ],
            "total": 2,
        }
        res = crashes.get_exploitability(product='Firefox')
        eq_(res, res_expected)
开发者ID:snorp,项目名称:socorro,代码行数:27,代码来源:test_crashes.py


示例4: test_get_signature_history

    def test_get_signature_history(self):
        api = Crashes(config=self.config)
        now = self.now
        lastweek = now - datetime.timedelta(days=7)

        params = {
            "product": "Firefox",
            "version": "8.0",
            "signature": "signature1",
            "start_date": lastweek,
            "end_date": now,
        }
        res = api.get_signature_history(**params)

        self.assertEqual(len(res["hits"]), 2)
        self.assertEqual(len(res["hits"]), res["total"])

        date = datetimeutil.date_to_string(now.date())
        self.assertEqual(res["hits"][0]["date"], date)
        self.assertEqual(res["hits"][1]["date"], date)

        self.assertEqual(res["hits"][0]["count"], 5)
        self.assertEqual(res["hits"][1]["count"], 14)

        self.assertEqual(round(res["hits"][0]["percent_of_total"], 2), round(5.0 / 19.0 * 100, 2))
        self.assertEqual(round(res["hits"][1]["percent_of_total"], 2), round(14.0 / 19.0 * 100, 2))

        # Test no results
        params = {
            "product": "Firefox",
            "version": "9.0",
            "signature": "signature1",
            "start_date": lastweek,
            "end_date": now,
        }
        res = api.get_signature_history(**params)
        res_expected = {"hits": [], "total": 0}
        self.assertEqual(res, res_expected)

        # Test default date parameters
        params = {"product": "Fennec", "version": "11.0.1", "signature": "signature3"}
        res = api.get_signature_history(**params)
        res_expected = {"hits": [{"date": now.date().isoformat(), "count": 14, "percent_of_total": 100}], "total": 1}
        self.assertEqual(res, res_expected)

        # Test missing parameters
        self.assertRaises(MissingOrBadArgumentError, api.get_signature_history)
        self.assertRaises(MissingOrBadArgumentError, api.get_signature_history, **{"product": "Firefox"})
        self.assertRaises(
            MissingOrBadArgumentError, api.get_signature_history, **{"product": "Firefox", "version": "8.0"}
        )
        self.assertRaises(
            MissingOrBadArgumentError, api.get_signature_history, **{"signature": "signature1", "version": "8.0"}
        )
开发者ID:smillaedler,项目名称:socorro,代码行数:54,代码来源:test_crashes_signatures.py


示例5: test_get_adu_by_signature

    def test_get_adu_by_signature(self):
        crashes = Crashes(config=self.config)

        signature = "canIhaveYourSignature()"
        channel = "release"
        yesterday_date = (self.now - datetime.timedelta(days=1)).date()
        yesterday = datetimeutil.date_to_string(yesterday_date)

        res_expected = {
            "hits": [
                {
                    "product_name": "WaterWolf",
                    "signature": signature,
                    "adu_date": yesterday,
                    "build_date": "2014-03-01",
                    "buildid": '201403010101',
                    "crash_count": 3,
                    "adu_count": 1023,
                    "os_name": "Mac OS X",
                    "channel": channel,
                },
                {
                    "product_name": "WaterWolf",
                    "signature": signature,
                    "adu_date": yesterday,
                    "build_date": "2014-04-01",
                    "buildid": '201404010101',
                    "crash_count": 4,
                    "adu_count": 1024,
                    "os_name": "Windows NT",
                    "channel": channel,
                },
            ],
            "total": 2,
        }

        res = crashes.get_adu_by_signature(
            product_name="WaterWolf",
            start_date=yesterday,
            end_date=yesterday,
            signature=signature,
            channel=channel,
        )
        eq_(res, res_expected)

        assert_raises(
            BadArgumentError,
            crashes.get_adu_by_signature,
            start_date=(yesterday_date - datetime.timedelta(days=366)),
            end_date=yesterday,
            signature=signature,
            channel=channel
        )
开发者ID:snorp,项目名称:socorro,代码行数:53,代码来源:test_crashes.py


示例6: test_get_count_by_day

    def test_get_count_by_day(self):
        crashes = Crashes(config=self.config)
        now = datetime.datetime.utcnow()
        yesterday = now - datetime.timedelta(1)
        tomorrow = now + datetime.timedelta(1)

        now = now.strftime("%Y-%m-%d")
        yesterday = yesterday.strftime("%Y-%m-%d")
        tomorrow = tomorrow.strftime("%Y-%m-%d")

        params = {
            'signature': 'js',
            'start_date': now
        }

        expected = {
            'hits': {now: 3},
            'total': 1
        }

        res = crashes.get_count_by_day(**params)
        eq_(res, expected)

        params = {
            'signature': 'nothing',
            'start_date': now
        }

        expected = {
            'hits': {now: 0},
            'total': 1
        }

        res = crashes.get_count_by_day(**params)
        eq_(res, expected)

        params = {
            'signature': 'js',
            'start_date': yesterday,
            'end_date': tomorrow
        }

        expected = {
            'hits': {
                yesterday: 2,
                now: 3
            },
            'total': 2
        }

        res = crashes.get_count_by_day(**params)
        eq_(res, expected)
开发者ID:snorp,项目名称:socorro,代码行数:52,代码来源:test_crashes.py


示例7: test_get_comments

    def test_get_comments(self):
        crashes = Crashes(config=self.config)
        today = datetimeutil.date_to_string(self.now)

        # Test 1: results
        params = {
            "signature": "js",
        }
        res_expected = {
            "hits": [
                {
                    "email": None,
                    "date_processed": today,
                    "uuid": "def",
                    "user_comments": "hello"
                },
                {
                    "email": None,
                    "date_processed": today,
                    "uuid": "hij",
                    "user_comments": "hah"
                }
            ],
            "total": 2
        }

        res = crashes.get_comments(**params)
        self.assertEqual(res, res_expected)

        # Test 2: no results
        params = {
            "signature": "blah",
        }
        res_expected = {
            "hits": [],
            "total": 0
        }

        res = crashes.get_comments(**params)
        self.assertEqual(res, res_expected)

        # Test 3: missing parameter
        self.assertRaises(MissingArgumentError, crashes.get_comments)
开发者ID:esamanas,项目名称:socorro,代码行数:43,代码来源:test_crashes.py


示例8: test_get_exploitibility_by_product_and_version

    def test_get_exploitibility_by_product_and_version(self):
        crashes = Crashes(config=self.config)

        res_expected = {
            "hits": [
                {
                    "signature": "ofCourseYouCan()",
                    "null_count": 1,
                    "none_count": 4,
                    "low_count": 0,
                    "medium_count": 1,
                    "high_count": 0
                }
            ],
            "total": 1,
        }

        res = crashes.get_exploitability(product='Firefox', version='14.0b')
        eq_(res, res_expected)
开发者ID:snorp,项目名称:socorro,代码行数:19,代码来源:test_crashes.py


示例9: test_get_frequency

    def test_get_frequency(self):
        self.config.platforms = (
            {
                "id": "windows",
                "name": "Windows NT"
            },
            {
                "id": "linux",
                "name": "Linux"
            }
        )
        crashes = Crashes(config=self.config)

        #......................................................................
        # Test 1
        params = {
            "signature": "js"
        }
        res_expected = {
            "hits": [
                {
                    "build_date": "2012033117",
                    "count": 1,
                    "frequency": 1.0,
                    "total": 1,
                    "count_windows": 1,
                    "frequency_windows": 1.0,
                    "count_linux": 0,
                    "frequency_linux": 0
                },
                {
                    "build_date": "2012033116",
                    "count": 2,
                    "frequency": 1.0,
                    "total": 2,
                    "count_windows": 1,
                    "frequency_windows": 1.0,
                    "count_linux": 1,
                    "frequency_linux": 1.0
                }
            ],
            "total": 2
        }
        res = crashes.get_frequency(**params)

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 2
        params = {
            "signature": "blah"
        }
        res_expected = {
            "hits": [
                {
                    "build_date": "2012033117",
                    "count": 1,
                    "frequency": 1.0,
                    "total": 1,
                    "count_windows": 0,
                    "frequency_windows": 0.0,
                    "count_linux": 0,
                    "frequency_linux": 0.0
                }
            ],
            "total": 1
        }
        res = crashes.get_frequency(**params)

        self.assertEqual(res, res_expected)
开发者ID:phb,项目名称:socorro,代码行数:70,代码来源:test_crashes.py


示例10: test_get_exploitibility_with_pagination

    def test_get_exploitibility_with_pagination(self):
        crashes = Crashes(config=self.config)
        yesterday_date = (self.now - datetime.timedelta(days=1)).date()
        day_before_yesterday = (self.now - datetime.timedelta(days=2)).date()

        j = 100  # some number so it's not used by other tests or fixtures

        rand = lambda: random.randint(0, 10)
        exploit_values = []
        signature_values = []
        for day in day_before_yesterday, yesterday_date, self.now:
            for i in range(10):
                exploit_values.append(
                    "(%s, 3, 'Signature%s%s', '%s', %s, %s, %s, %s, %s)" % (
                        j + 1, j, i, day,
                        rand(), rand(), rand(), rand(), rand()
                    )
                )
                signature_values.append(
                    "(%s, 'Signature%s%s', %s, '%s')" % (
                        j + 1, j, i, day.strftime('%Y%m%d%H'), day
                    )
                )
                j += 1
        cursor = self.connection.cursor()

        insert = """
        INSERT INTO signatures
            (signature_id, signature, first_build, first_report)
        VALUES
        """
        insert += ',\n'.join(signature_values)
        cursor.execute(insert)

        insert = """
        INSERT INTO exploitability_reports
           (signature_id, product_version_id, signature, report_date,
            null_count, none_count, low_count, medium_count, high_count)
        VALUES
        """
        insert += ',\n'.join(exploit_values)
        cursor.execute(insert)
        self.connection.commit()

        res = crashes.get_exploitability()
        eq_(len(res['hits']), res['total'])
        ok_(res['total'] >= 3 * 10)

        res = crashes.get_exploitability(
            start_date=yesterday_date,
            end_date=self.now
        )
        eq_(len(res['hits']), res['total'])
        ok_(res['total'] >= 2 * 10)
        ok_(res['total'] < 3 * 10)

        # passing a `page` without `batch` will yield an error
        assert_raises(
            MissingArgumentError,
            crashes.get_exploitability,
            page=2
        )
        # `page` starts on one so anything smaller is bad
        assert_raises(
            BadArgumentError,
            crashes.get_exploitability,
            page=0,
            batch=15
        )

        # Note, `page=1` is on number line starting on 1
        res = crashes.get_exploitability(
            page=1,
            batch=15
        )
        self.assertNotEqual(len(res['hits']), res['total'])
        eq_(len(res['hits']), 15)
        ok_(res['total'] >= 3 * 10)
        # since it's ordered by "medium + high"...

        med_or_highs = [
            x['medium_count'] + x['high_count']
            for x in res['hits']
        ]
        eq_(
            med_or_highs[0],
            max(med_or_highs)
        )
        eq_(
            med_or_highs[-1],
            min(med_or_highs)
        )
开发者ID:snorp,项目名称:socorro,代码行数:92,代码来源:test_crashes.py


示例11: test_get_signatures

    def test_get_signatures(self):
        tcbs = Crashes(config=self.config)
        now = datetimeutil.utc_now()
        today = datetime.datetime(now.year, now.month, now.day)
        lastweek = today - datetime.timedelta(days=7)

        tomorrow_str = (today + datetime.timedelta(days=1)).strftime('%Y-%m-%d')
        today_str = today.strftime('%Y-%m-%d')
        sixdaysago_str = (lastweek + datetime.timedelta(days=1)).strftime('%Y-%m-%d')
        lastweek_str = lastweek.strftime('%Y-%m-%d')
        lastweek_str_full = lastweek.strftime('%Y-%m-%d %H:%M:%S')

        # Test 1: all TCBS for Firefox
        params = {
            "product": "Firefox",
            "version": "8.0"
        }
        res = tcbs.get_signatures(**params)
        res_expected = {
            'totalPercentage': 1.0,
            'end_date': tomorrow_str,
            'start_date': sixdaysago_str,
            'crashes': [
                {
                    'count': 19L,
                    'mac_count': 1L,
                    'content_count': 0,
                    'first_report': lastweek_str,
                    'previousRank': 0,
                    'currentRank': 0,
                    'startup_percent': None,
                    'versions': 'plugin1, plugin2',
                    'first_report_exact': lastweek_str_full,
                    'percentOfTotal': 0.86363636363636398,
                    'changeInRank': 0,
                    'win_count': 12L,
                    'changeInPercentOfTotal': -0.13636363636363602,
                    'linux_count': 6L,
                    'hang_count': 5L,
                    'signature': 'signature1',
                    'versions_count': 2,
                    'previousPercentOfTotal': 1.0,
                    'plugin_count': 0
                },
                {
                    'count': 3L,
                    'mac_count': 1L,
                    'content_count': 0,
                    'first_report': lastweek_str,
                    'previousRank': 'null',
                    'currentRank': 1,
                    'startup_percent': None,
                    'versions': 'plugin1, plugin2, plugin3, plugin4, plugin5, plugin6',
                    'first_report_exact': lastweek_str_full,
                    'percentOfTotal': 0.13636363636363599,
                    'changeInRank': 'new',
                    'win_count': 1L,
                    'changeInPercentOfTotal': 'new',
                    'linux_count': 1L,
                    'hang_count': 0L,
                    'signature': 'signature2',
                    'versions_count': 6,
                    'previousPercentOfTotal': 'null',
                    'plugin_count': 0
                }
            ],
            'totalNumberOfCrashes': 22L
        }

        self.assertEqual(res, res_expected)

        # Test 2: Limit to one crash type
        params = {
            "product": "Firefox",
            "version": "8.0",
            "crash_type": "hang"
        }
        res = tcbs.get_signatures(**params)
        res_expected = {
            'totalPercentage': 1.0,
            'end_date': tomorrow_str,
            'start_date': sixdaysago_str,
            'crashes': [
                {
                    'count': 5L,
                    'mac_count': 0L,
                    'content_count': 0,
                    'first_report': lastweek_str,
                    'previousRank': 'null',
                    'currentRank': 0,
                    'startup_percent': None,
                    'versions': 'plugin1, plugin2',
                    'first_report_exact': lastweek_str_full,
                    'percentOfTotal': 1.0,
                    'changeInRank': 'new',
                    'win_count': 0L,
                    'changeInPercentOfTotal': 'new',
                    'linux_count': 5L,
                    'hang_count': 5L,
                    'signature': 'signature1',
#.........这里部分代码省略.........
开发者ID:ajsb85,项目名称:socorro,代码行数:101,代码来源:test_crashes_signatures.py


示例12: test_get_frequency

    def test_get_frequency(self):
        self.config.webapi = util.DotDict()
        self.config.webapi.platforms = (
            {
                "id": "windows",
                "name": "Windows NT"
            },
            {
                "id": "linux",
                "name": "Linux"
            }
        )
        crashes = Crashes(config=self.config)

        # .....................................................................
        # Test 1
        params = {
            "signature": "js"
        }
        res_expected = {
            "hits": [
                {
                    "build_date": "2012033117",
                    "count": 1,
                    "frequency": 1.0,
                    "total": 1,
                    "count_windows": 1,
                    "frequency_windows": 1.0,
                    "count_linux": 0,
                    "frequency_linux": 0
                },
                {
                    "build_date": "2012033116",
                    "count": 2,
                    "frequency": 1.0,
                    "total": 2,
                    "count_windows": 1,
                    "frequency_windows": 1.0,
                    "count_linux": 1,
                    "frequency_linux": 1.0
                }
            ],
            "total": 2
        }
        res = crashes.get_frequency(**params)

        eq_(res, res_expected)

        # .....................................................................
        # Test 2
        params = {
            "signature": "blah"
        }
        res_expected = {
            "hits": [
                {
                    "build_date": "2012033117",
                    "count": 1,
                    "frequency": 1.0,
                    "total": 1,
                    "count_windows": 0,
                    "frequency_windows": 0.0,
                    "count_linux": 0,
                    "frequency_linux": 0.0
                }
            ],
            "total": 1
        }
        res = crashes.get_frequency(**params)

        eq_(res, res_expected)

        # .....................................................................
        # Verify that it is not possible to break the query.
        params = {
            "signature": "sig'"
        }
        res = crashes.get_frequency(**params)
        eq_(res["total"], 0)
开发者ID:snorp,项目名称:socorro,代码行数:79,代码来源:test_crashes.py


示例13: test_get_daily

    def test_get_daily(self):
        crashes = Crashes(config=self.config)
        now = self.now.date()
        today = now.isoformat()
        yesterday = (now - datetime.timedelta(days=1)).isoformat()

        # Test 1: one product, one version (simple version)
        params = {
            "product": "Firefox",
            "versions": ["11.0"]
        }
        res_expected = {
            "hits": {
                "Firefox:11.0": {
                    today: {
                        "product": "Firefox",
                        "version": "11.0",
                        "date": today,
                        "report_count": 5,
                        "adu": 20,
                        "crash_hadu": 0.12
                    }
                }
            }
        }

        res = crashes.get_daily(**params)
        eq_(res, res_expected)

        # Test 2: one product, several versions, range by build date,
        # simple version
        params = {
            "product": "Firefox",
            "versions": ["11.0", "12.0"],
            "date_range_type": "build"
        }
        res_expected = {
            "hits": {
                "Firefox:11.0": {
                    today: {
                        "product": "Firefox",
                        "version": "11.0",
                        "date": today,
                        "report_count": 5,
                        "adu": 200,
                        "crash_hadu": 25.0
                    },
                    yesterday: {
                        "product": "Firefox",
                        "version": "11.0",
                        "date": yesterday,
                        "report_count": 3,
                        "adu": 274,
                        "crash_hadu": 10.949
                    }
                },
                "Firefox:12.0": {
                    today: {
                        "product": "Firefox",
                        "version": "12.0",
                        "date": today,
                        "report_count": 3,
                        "adu": 109,
                        "crash_hadu": 27.523
                    }
                }
            }
        }

        res = crashes.get_daily(**params)
        eq_(res, res_expected)

        # Test 3: report type filter, complex version
        params = {
            "product": "Firefox",
            "versions": ["13.0"],
            "report_type": "hang"
        }
        res_expected = {
            "hits": {
                "Firefox:13.0": {
                    today: {
                        "product": "Firefox",
                        "version": "13.0",
                        "date": today,
                        "report_count": 90,
                        "adu": 12000,
                        "crash_hadu": 0.75,
                        "throttle": 0.1
                    }
                }
            }
        }

        res = crashes.get_daily(**params)
        eq_(res, res_expected)

        # Test 4: extended fields, by build date and with report type,
        # complex version
        params = {
#.........这里部分代码省略.........
开发者ID:snorp,项目名称:socorro,代码行数:101,代码来源:test_crashes.py


示例14: test_get_comments

    def test_get_comments(self):
        crashes = Crashes(config=self.config)
        today = datetimeutil.date_to_string(self.now)

        # Test 1: results
        params = {
            "signature": "js",
        }
        res_expected = {
            "hits": [
                {
                    "email": None,
                    "date_processed": today,
                    "uuid": "def",
                    "user_comments": "hello"
                },
                {
                    "email": None,
                    "date_processed": today,
                    "uuid": "hij",
                    "user_comments": "hah"
                }
            ],
            "total": 2
        }

        res = crashes.get_comments(**params)
        eq_(res, res_expected)

        # Test 2: no results
        params = {
            "signature": "blah",
        }
        res_expected = {
            "hits": [],
            "total": 0
        }

        res = crashes.get_comments(**params)
        eq_(res, res_expected)

        # Test 3: missing parameter
        assert_raises(MissingArgumentError, crashes.get_comments)

        # Test a valid rapid beta versions
        params = {
            "signature": "cool_sig",
            "products": "Firefox",
            "versions": "Firefox:14.0b",
        }
        res_expected = {
            'hits': [
                {
                    'email': None,
                    'date_processed': today,
                    'uuid': 'nop',
                    'user_comments': 'hi!'
                }
            ],
            'total': 1
        }

        res = crashes.get_comments(**params)
        eq_(res, res_expected)

        # Test an invalid rapid beta versions
        params = {
            "signature": "cool_sig",
            "versions": "WaterWolf:2.0b",
        }
        res_expected = {
            'hits': [
                {
                    'email': None,
                    'date_processed': today,
                    'uuid': 'qrs',
                    'user_comments': 'meow'
                }
            ],
            'total': 1
        }

        res = crashes.get_comments(**params)
        eq_(res, res_expected)

        # use pagination
        params = {
            "signature": "cool_sig",
            "result_number": 1,
            "result_offset": 0,
        }
        params['result_number'] = 1
        params['result_offset'] = 0
        res = crashes.get_comments(**params)
        eq_(len(res['hits']), 1)
        eq_(res['total'], 2)
开发者ID:snorp,项目名称:socorro,代码行数:96,代码来源:test_crashes.py


示例15: test_get_comments

    def test_get_comments(self):
        crashes = Crashes(config=self.config)
        today = datetimeutil.date_to_string(self.now)

        # Test 1: results
        params = {
            "signature": "js",
        }
        res_expected = {
            "hits": [
                {
                    "email": None,
                    "date_processed": today,
                    "uuid": "def",
                    "user_comments": "hello"
                },
                {
                    "email": None,
                    "date_processed": today,
                    "uuid": "hij",
                    "user_comments": "hah"
                }
            ],
            "total": 2
        }

        res = crashes.get_comments(**params)
        self.assertEqual(res, res_expected)

        # Test 2: no results
        params = {
            "signature": "blah",
        }
        res_expected = {
            "hits": [],
            "total": 0
        }

        res = crashes.get_comments(**params)
        self.assertEqual(res, res_expected)

        # Test 3: missing parameter
        self.assertRaises(MissingArgumentError, crashes.get_comments)

        # Test a valid rapid beta versions
        params = {
            "signature": "cool_sig",
            "products": "Firefox",
            "versions": "Firefox:14.0b",
        }
        res_expected = {
            'hits': [
                {
                    'email': None,
                    'date_processed': today,
                    'uuid': 'nop',
                    'user_comments': 'hi!'
                }
            ],
            'total': 1
        }

        res = crashes.get_comments(**params)
        self.assertEqual(res, res_expected)

        # Test an invalid rapid beta versions
        params = {
            "signature": "cool_sig",
            "versions": "WaterWolf:2.0b",
        }

        res = crashes.get_comments(**params)
        self.assertTrue(res)
开发者ID:kidundead,项目名称:socorro,代码行数:73,代码来源:test_crashes.py


示例16: test_get_paireduuid

    def test_get_paireduuid(self):
        crashes = Crashes(config=self.config)
        yesterday = self.now - datetime.timedelta(days=1)
        uuid = "%%s-%s" % self.now.strftime("%y%m%d")
        yesterday_uuid = "%%s-%s" % yesterday.strftime("%y%m%d")

        #......................................................................
        # Test 1: a uuid and a hangid
        params = {
            "uuid": uuid % "a1",
            "hangid": "ab1"
        }
        res = crashes.get_paireduuid(**params)
        res_expected = {
            "hits": [
                {
                    "uuid": uuid % "a2"
                }
            ],
            "total": 1
        }
        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 2: a uuid only
        params = {
            "uuid": uuid % "a1"
        }
        res = crashes.get_paireduuid(**params)
        res_expected = {
            "hits": [
                {
                    "uuid": uuid % "a2"
                },
                {
                    "uuid": uuid % "a3"
                }
            ],
            "total": 2
        }
        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 3: a query with no result
        params = {
            "uuid": uuid % "b1"
        }
        res = crashes.get_paireduuid(**params)
        res_expected = {
            "hits": [],
            "total": 0
        }
        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 4: one result that was yesterday
        params = {
            "uuid": uuid % "c1"
        }
        res = crashes.get_paireduuid(**params)
        res_expected = {
            "hits": [
                {
                    "uuid": yesterday_uuid % "c2"
                }
            ],
            "total": 1
        }
        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 5: missing argument
        params = {
            "hangid": "c1"
        }
        self.assertRaises(MissingArgumentError,
                          crashes.get_paireduuid,
                          **params)
开发者ID:kidundead,项目名称:socorro,代码行数:78,代码来源:test_crashes.py


示例17: test_get_signatures

    def test_get_signatures(self):
        tcbs = Crashes(config=self.config)
        now = self.now
        today = datetime.datetime(now.year, now.month, now.day)
        lastweek = today - datetime.timedelta(days=7)

        tomorrow_str = (today + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
        sixdaysago_str = (lastweek + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
        lastweek_str = lastweek.strftime("%Y-%m-%d")
        lastweek_str_full = lastweek.strftime("%Y-%m-%d %H:%M:%S")

        # Test 1: all TCBS for Firefox
        params = {"product": "Firefox", "version": "8.0"}
        res = tcbs.get_signatures(**params)
        res_expected = {
            "totalPercentage": 1.0,
            "end_date": tomorrow_str,
            "start_date": sixdaysago_str,
            "crashes": [
                {
                    "count": 19L,
                    "mac_count": 1L,
                    "content_count": 0,
                    "first_report": lastweek_str,
                    "previousRank": 0,
                    "currentRank": 0,
                    "startup_percent": None,
                    "versions": "plugin1, plugin2",
                    "first_report_exact": lastweek_str_full,
                    "percentOfTotal": 0.86363636363636398,
                    "changeInRank": 0,
                    "win_count": 12L,
                    "changeInPercentOfTotal": -0.13636363636363602,
                    "linux_count": 6L,
                    "hang_count": 5L,
                    "signature": "signature1",
                    "versions_count": 2,
                    "previousPercentOfTotal": 1.0,
                    "plugin_count": 0,
                    "is_gc_count": 11L,
                },
                {
                    "count": 3L,
                    "mac_count": 1L,
                    "content_count": 0,
                    "first_report": lastweek_str,
                    "previousRank": "null",
                    "currentRank": 1,
                    "startup_percent": None,
                    "versions": "plugin1, plugin2, plugin3, plugin4, plugin5, plugin6",
                    "first_report_exact": lastweek_str_full,
                    "percentOfTotal": 0.13636363636363599,
                    "changeInRank": "new",
                    "win_count": 1L,
                    "changeInPercentOfTotal": "new",
                    "linux_count": 1L,
                    "hang_count": 0L,
                    "signature": "signature2",
                    "versions_count": 6,
                    "previousPercentOfTotal": "null",
                    "plugin_count": 0,
                    "is_gc_count": 1L,
                },
            ],
            "totalNumberOfCrashes": 22L,
        }

        self.assertEqual(res, res_expected)

        # Test 2: Limit to one crash type
        params = {"product": "Firefox", "version": "8.0", "crash_type": "hang"}
        res = tcbs.get_signatures(**params)
        res_expected = {
            "totalPercentage": 1.0,
            "end_date": tomorrow_str,
            "start_date": sixdaysago_str,
            "crashes": [
                {
                    "count": 5L,
                    "mac_count": 0L,
                    "content_count": 0,
                    "first_report": lastweek_str,
                    "previousRank": "null",
                    "currentRank": 0,
                    "startup_percent": None,
                    "versions": "plugin1, plugin2",
                    "first_report_exact": lastweek_str_full,
                    "percentOfTotal": 1.0,
                    "changeInRank": "new",
                    "win_count": 0L,
                    "changeInPercentOfTotal": "new",
                    "linux_count": 5L,
                    "hang_count": 5L,
                    "signature": "signature1",
                    "versions_count": 2,
                    "previousPercentOfTotal": "null",
                    "plugin_count": 0,
                    "is_gc_count": 10L,
                }
            ],
#.........这里部分代码省略.........
开发者ID:smillaedler,项目名称:socorro,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python crashstorage.PostgreSQLCrashStorage类代码示例发布时间:2022-05-27
下一篇:
Python index_creator.IndexCreator类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap