Esempio n. 1
0
class TestFirefoxAndroid(TestCase):
    google_play_url_base = "https://play.google.com/store/apps/details?id=org.mozilla."

    def setUp(self):
        self.firefox_android = FirefoxAndroid(json_dir=PROD_DETAILS_DIR)

    def test_latest_release_version(self):
        """latest_version should return the latest release version."""
        for version in ["22.0.1", "100.0.1", "122.0.1"]:
            with self.subTest(version=version):
                with patch.object(
                    self.firefox_android._storage,
                    "data",
                    Mock(return_value=dict(version=version)),
                ):
                    assert self.firefox_android.latest_version("release") == version

    def test_latest_beta_version(self):
        """latest_version should return the latest beta version."""
        for version in ["23.0.1", "101.0.1", "123.0.1"]:
            with self.subTest(version=version):
                with patch.object(
                    self.firefox_android._storage,
                    "data",
                    Mock(return_value=dict(beta_version=version)),
                ):
                    assert self.firefox_android.latest_version("beta") == version

    def test_get_download_url_nightly(self):
        """
        get_download_url should return the same Google Play link of the
        'org.mozilla.fennec_aurora' product regardless of the architecture type,
        if the force_direct option is unspecified.
        """
        assert self.firefox_android.get_download_url("nightly", "arm").startswith(self.google_play_url_base + "fenix")
        assert self.firefox_android.get_download_url("nightly", "x86").startswith(self.google_play_url_base + "fenix")

    def test_get_download_url_nightly_direct(self):
        """
        get_download_url should return a bouncer link depending on the
        architecture type, if the force_direct option is True.
        """
        url = self.firefox_android.get_download_url("nightly", "arm", "multi", True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [
                ("product", "fennec-nightly-latest"),
                ("os", "android"),
                ("lang", "multi"),
            ],
        )
        url = self.firefox_android.get_download_url("nightly", "x86", "multi", True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [
                ("product", "fennec-nightly-latest"),
                ("os", "android-x86"),
                ("lang", "multi"),
            ],
        )

    def test_get_download_url_beta(self):
        """
        get_download_url should return the same Google Play link of the
        'org.mozilla.firefox_beta' product regardless of the architecture type,
        if the force_direct option is unspecified.
        """
        assert self.firefox_android.get_download_url("beta", "arm").startswith(self.google_play_url_base + "firefox_beta")
        assert self.firefox_android.get_download_url("beta", "x86").startswith(self.google_play_url_base + "firefox_beta")

    def test_get_download_url_beta_direct(self):
        """
        get_download_url should return a bouncer link depending on the
        architecture type, if the force_direct option is True.
        """
        url = self.firefox_android.get_download_url("beta", "arm", "multi", True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [("product", "fennec-beta-latest"), ("os", "android"), ("lang", "multi")],
        )
        url = self.firefox_android.get_download_url("beta", "x86", "multi", True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [
                ("product", "fennec-beta-latest"),
                ("os", "android-x86"),
                ("lang", "multi"),
            ],
        )

    def test_get_download_url_release(self):
        """
        get_download_url should return the same Google Play link of the
        'org.mozilla.firefox' product regardless of the architecture type,
        if the force_direct option is unspecified.
        """
        assert self.firefox_android.get_download_url("release", "arm").startswith(self.google_play_url_base + "firefox")
        assert self.firefox_android.get_download_url("release", "x86").startswith(self.google_play_url_base + "firefox")

    def test_get_download_url_release_direct(self):
        """
        get_download_url should return a bouncer link depending on the
        architecture type, if the force_direct option is True.
        """
        url = self.firefox_android.get_download_url("release", "arm", "multi", True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [("product", "fennec-latest"), ("os", "android"), ("lang", "multi")],
        )
        url = self.firefox_android.get_download_url("release", "x86", "multi", True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [("product", "fennec-latest"), ("os", "android-x86"), ("lang", "multi")],
        )
Esempio n. 2
0
class TestFirefoxAndroid(TestCase):
    google_play_url_base = ('https://play.google.com/store/apps/details'
                            '?id=org.mozilla.')

    def setUp(self):
        self.firefox_android = FirefoxAndroid(json_dir=PROD_DETAILS_DIR)

    def test_latest_release_version(self):
        """latest_version should return the latest release version."""
        with patch.object(
                self.firefox_android._storage,
                'data',
                Mock(return_value=dict(version='22.0.1')),
        ):
            assert self.firefox_android.latest_version('release') == '22.0.1'

    def test_latest_beta_version(self):
        """latest_version should return the latest beta version."""
        with patch.object(
                self.firefox_android._storage,
                'data',
                Mock(return_value=dict(beta_version='23.0')),
        ):
            assert self.firefox_android.latest_version('beta') == '23.0'

    def test_get_download_url_nightly(self):
        """
        get_download_url should return the same Google Play link of the
        'org.mozilla.fennec_aurora' product regardless of the architecture type,
        if the force_direct option is unspecified.
        """
        assert self.firefox_android.get_download_url(
            'nightly', 'arm').startswith(self.google_play_url_base + 'fenix')
        assert self.firefox_android.get_download_url(
            'nightly', 'x86').startswith(self.google_play_url_base + 'fenix')

    def test_get_download_url_nightly_direct(self):
        """
        get_download_url should return a bouncer link depending on the
        architecture type, if the force_direct option is True.
        """
        url = self.firefox_android.get_download_url('nightly', 'arm', 'multi',
                                                    True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [
                ('product', 'fennec-nightly-latest'),
                ('os', 'android'),
                ('lang', 'multi'),
            ],
        )
        url = self.firefox_android.get_download_url('nightly', 'x86', 'multi',
                                                    True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [
                ('product', 'fennec-nightly-latest'),
                ('os', 'android-x86'),
                ('lang', 'multi'),
            ],
        )

    def test_get_download_url_beta(self):
        """
        get_download_url should return the same Google Play link of the
        'org.mozilla.firefox_beta' product regardless of the architecture type,
        if the force_direct option is unspecified.
        """
        assert self.firefox_android.get_download_url(
            'beta',
            'arm').startswith(self.google_play_url_base + 'firefox_beta')
        assert self.firefox_android.get_download_url(
            'beta',
            'x86').startswith(self.google_play_url_base + 'firefox_beta')

    def test_get_download_url_beta_direct(self):
        """
        get_download_url should return a bouncer link depending on the
        architecture type, if the force_direct option is True.
        """
        url = self.firefox_android.get_download_url('beta', 'arm', 'multi',
                                                    True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [('product', 'fennec-beta-latest'), ('os', 'android'),
             ('lang', 'multi')],
        )
        url = self.firefox_android.get_download_url('beta', 'x86', 'multi',
                                                    True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [
                ('product', 'fennec-beta-latest'),
                ('os', 'android-x86'),
                ('lang', 'multi'),
            ],
        )

    def test_get_download_url_release(self):
        """
        get_download_url should return the same Google Play link of the
        'org.mozilla.firefox' product regardless of the architecture type,
        if the force_direct option is unspecified.
        """
        assert self.firefox_android.get_download_url(
            'release', 'arm').startswith(self.google_play_url_base + 'firefox')
        assert self.firefox_android.get_download_url(
            'release', 'x86').startswith(self.google_play_url_base + 'firefox')

    def test_get_download_url_release_direct(self):
        """
        get_download_url should return a bouncer link depending on the
        architecture type, if the force_direct option is True.
        """
        url = self.firefox_android.get_download_url('release', 'arm', 'multi',
                                                    True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [('product', 'fennec-latest'), ('os', 'android'),
             ('lang', 'multi')],
        )
        url = self.firefox_android.get_download_url('release', 'x86', 'multi',
                                                    True)
        self.assertListEqual(
            parse_qsl(urlparse(url).query),
            [('product', 'fennec-latest'), ('os', 'android-x86'),
             ('lang', 'multi')],
        )