Esempio n. 1
0
    def test_update_featured(self):
        service = Releases(config=self.config)

        #......................................................................
        # Test 1: one product, several versions
        params = {"Firefox": ["15.0a1", "14.0a2", "13.0b1"]}
        res = service.update_featured(**params)
        self.assertTrue(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Firefox": ["13.0b1", "14.0a2", "15.0a1"],
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["15.0a1"]
            },
            "total": 5
        }
        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 2: several products, several versions
        params = {"Firefox": ["13.0b1"], "FennecAndroid": ["14.0a1"]}
        res = service.update_featured(**params)
        self.assertTrue(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Firefox": ["13.0b1"],
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["14.0a1"]
            },
            "total": 3
        }
        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 3: an unknown product
        params = {"Unknown": ["15.0a1"]}
        res = service.update_featured(**params)
        self.assertFalse(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Firefox": ["13.0b1"],
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["14.0a1"]
            },
            "total": 3
        }
        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 4: an unknown product and an existing product
        params = {"Firefox": ["14.0a2"], "Unknown": ["15.0a1"]}
        res = service.update_featured(**params)
        self.assertTrue(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Firefox": ["14.0a2"],
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["14.0a1"]
            },
            "total": 3
        }
        self.assertEqual(res, res_expected)

        #......................................................................
        # Test 4: an unknown version
        params = {
            "Firefox": [
                "200.0a1"  # that's like, in 2035, dude
            ]
        }
        res = service.update_featured(**params)
        self.assertTrue(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["14.0a1"]
            },
            "total": 2
        }
        self.assertEqual(res, res_expected)
Esempio n. 2
0
    def test_update_featured(self):
        self._insert_release_channels()
        self._insert_product_release_channels()

        service = Releases(config=self.config)

        #......................................................................
        # Test 1: one product, several versions
        params = {
            "Firefox": [
                "15.0a1",
                "14.0a2",
                "13.0b1"
            ]
        }
        res = service.update_featured(**params)
        ok_(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Firefox": ["13.0b1", "14.0a2", "15.0a1"],
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["15.0a1"]
            },
            "total": 5
        }
        eq_(res, res_expected)

        #......................................................................
        # Test 2: several products, several versions
        params = {
            "Firefox": [
                "13.0b1"
            ],
            "FennecAndroid": [
                "14.0a1"
            ]
        }
        res = service.update_featured(**params)
        ok_(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Firefox": ["13.0b1"],
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["14.0a1"]
            },
            "total": 3
        }
        eq_(res, res_expected)

        #......................................................................
        # Test 3: an unknown product
        params = {
            "Unknown": [
                "15.0a1"
            ]
        }
        res = service.update_featured(**params)
        ok_(not res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Firefox": ["13.0b1"],
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["14.0a1"]
            },
            "total": 3
        }
        eq_(res, res_expected)

        #......................................................................
        # Test 4: an unknown product and an existing product
        params = {
            "Firefox": [
                "14.0a2"
            ],
            "Unknown": [
                "15.0a1"
            ]
        }
        res = service.update_featured(**params)
        ok_(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Firefox": ["14.0a2"],
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["14.0a1"]
            },
            "total": 3
        }
        eq_(res, res_expected)

        #......................................................................
        # Test 4: an unknown version
        params = {
            "Firefox": [
                "200.0a1"  # that's like, in 2035, dude
            ]
        }
        res = service.update_featured(**params)
        ok_(res)

        res = service.get_featured()
        res_expected = {
            "hits": {
                "Thunderbird": ["15.0a1"],
                "FennecAndroid": ["14.0a1"]
            },
            "total": 2
        }
        eq_(res, res_expected)
Esempio n. 3
0
    def test_update_featured(self):
        service = Releases(config=self.config)

        # ......................................................................
        # Test 1: one product, several versions
        params = {"Firefox": ["15.0a1", "14.0a2", "13.0b1"]}
        res = service.update_featured(**params)
        self.assertTrue(res)

        res = service.get_featured()
        res_expected = {
            "hits": {"Firefox": ["13.0b1", "14.0a2", "15.0a1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["15.0a1"]},
            "total": 5,
        }
        self.assertEqual(res, res_expected)

        # ......................................................................
        # Test 2: several products, several versions
        params = {"Firefox": ["13.0b1"], "FennecAndroid": ["14.0a1"]}
        res = service.update_featured(**params)
        self.assertTrue(res)

        res = service.get_featured()
        res_expected = {
            "hits": {"Firefox": ["13.0b1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"]},
            "total": 3,
        }
        self.assertEqual(res, res_expected)

        # ......................................................................
        # Test 3: an unknown product
        params = {"Unknown": ["15.0a1"]}
        res = service.update_featured(**params)
        self.assertFalse(res)

        res = service.get_featured()
        res_expected = {
            "hits": {"Firefox": ["13.0b1"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"]},
            "total": 3,
        }
        self.assertEqual(res, res_expected)

        # ......................................................................
        # Test 4: an unknown product and an existing product
        params = {"Firefox": ["14.0a2"], "Unknown": ["15.0a1"]}
        res = service.update_featured(**params)
        self.assertTrue(res)

        res = service.get_featured()
        res_expected = {
            "hits": {"Firefox": ["14.0a2"], "Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"]},
            "total": 3,
        }
        self.assertEqual(res, res_expected)

        # ......................................................................
        # Test 4: an unknown version
        params = {"Firefox": ["200.0a1"]}  # that's like, in 2035, dude
        res = service.update_featured(**params)
        self.assertTrue(res)

        res = service.get_featured()
        res_expected = {"hits": {"Thunderbird": ["15.0a1"], "FennecAndroid": ["14.0a1"]}, "total": 2}
        self.assertEqual(res, res_expected)