Exemple #1
0
    def test_get(self):
        crash = Crash(config=self.config)
        now = datetimeutil.utc_now()
        uuid = "%%s-%s" % now.strftime("%y%m%d")

        #......................................................................
        # Test 1: a valid crash with duplicates
        params = {
            "uuid": uuid % "a1"
        }
        res = crash.get(**params)
        res_expected = {
            "hits": [
                {
                    "email": "*****@*****.**",
                    "url": "http://mywebsite.com",
                    "addons_checked": True,
                    "exploitability": "interesting",
                    "duplicate_of": "a2"
                }
            ],
            "total": 1
        }

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 2: an invalid crash
        params = {
            "uuid": uuid % "a4"
        }
        res = crash.get(**params)
        res_expected = {
            "hits": [],
            "total": 0
        }

        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 3: a valid crash without duplicates
        params = {
            "uuid": uuid % "b1"
        }
        res = crash.get(**params)
        res_expected = {
            "hits": [
                {
                    "email": "*****@*****.**",
                    "url": "http://myotherwebsite.com",
                    "addons_checked": False,
                    "exploitability": "medium",
                    "duplicate_of": None
                }
            ],
            "total": 1
        }

        self.assertEqual(res, res_expected)