Пример #1
0
    def test_github_down(self):
        """Connection error returns None."""
        with requests_mock.Mocker() as req_mock:
            url = '%s/Firefox.json' % settings.PRODUCT_DETAILS_BASE_URL
            req_mock.get(url, exc=requests.exceptions.ConnectionError)

            featured = utils.get_manually_maintained_featured_versions(
                'Firefox')
            assert featured is None
Пример #2
0
    def test_exists(self):
        with requests_mock.Mocker() as req_mock:
            url = '%s/Firefox.json' % settings.PRODUCT_DETAILS_BASE_URL
            req_mock.get(
                url, json={'featured_versions': ['68.0a1', '67.0b', '66.0']})

            featured = utils.get_manually_maintained_featured_versions(
                'Firefox')
            assert featured == ['68.0a1', '67.0b', '66.0']
Пример #3
0
    def test_exists(self):
        with requests_mock.Mocker() as req_mock:
            url = "%s/Firefox.json" % settings.PRODUCT_DETAILS_BASE_URL
            req_mock.get(
                url, json={"featured_versions": ["68.0a1", "67.0b", "66.0"]})

            featured = utils.get_manually_maintained_featured_versions(
                "Firefox")
            assert featured == ["68.0a1", "67.0b", "66.0"]
Пример #4
0
    def test_invalid_file(self):
        """Not JSON or no featured_versions returns None."""
        # Not JSON
        with requests_mock.Mocker() as req_mock:
            url = '%s/Firefox.json' % settings.PRODUCT_DETAILS_BASE_URL
            req_mock.get(url, text='this is not json')

            featured = utils.get_manually_maintained_featured_versions(
                'Firefox')
            assert featured is None

        # No featured_versions
        with requests_mock.Mocker() as req_mock:
            url = '%s/Firefox.json' % settings.PRODUCT_DETAILS_BASE_URL
            req_mock.get(url, json={})

            featured = utils.get_manually_maintained_featured_versions(
                'Firefox')
            assert featured is None