diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/mozbase/mozinstall/tests/test_install.py | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozbase/mozinstall/tests/test_install.py')
-rw-r--r-- | testing/mozbase/mozinstall/tests/test_install.py | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/testing/mozbase/mozinstall/tests/test_install.py b/testing/mozbase/mozinstall/tests/test_install.py new file mode 100644 index 0000000000..2dceb2cc78 --- /dev/null +++ b/testing/mozbase/mozinstall/tests/test_install.py @@ -0,0 +1,90 @@ +import subprocess + +import mozinfo +import mozinstall +import mozunit +import pytest + + +@pytest.mark.skipif( + mozinfo.isWin, + reason="Bug 1157352 - New firefox.exe needed for mozinstall 1.12 and higher.", +) +def test_is_installer(request, get_installer): + """Test that we can identify a correct installer.""" + if mozinfo.isLinux: + assert mozinstall.is_installer(get_installer("tar.bz2")) + + if mozinfo.isWin: + # test zip installer + assert mozinstall.is_installer(get_installer("zip")) + + # test exe installer + assert mozinstall.is_installer(get_installer("exe")) + + try: + # test stub browser file + # without pefile on the system this test will fail + import pefile # noqa + + stub_exe = ( + request.node.fspath.dirpath("build_stub").join("firefox.exe").strpath + ) + assert not mozinstall.is_installer(stub_exe) + except ImportError: + pass + + if mozinfo.isMac: + assert mozinstall.is_installer(get_installer("dmg")) + + +def test_invalid_source_error(get_installer): + """Test that InvalidSource error is raised with an incorrect installer.""" + if mozinfo.isLinux: + with pytest.raises(mozinstall.InvalidSource): + mozinstall.install(get_installer("dmg"), "firefox") + + elif mozinfo.isWin: + with pytest.raises(mozinstall.InvalidSource): + mozinstall.install(get_installer("tar.bz2"), "firefox") + + elif mozinfo.isMac: + with pytest.raises(mozinstall.InvalidSource): + mozinstall.install(get_installer("tar.bz2"), "firefox") + + # Test an invalid url handler + with pytest.raises(mozinstall.InvalidSource): + mozinstall.install("file://foo.bar", "firefox") + + +@pytest.mark.skipif( + mozinfo.isWin, + reason="Bug 1157352 - New firefox.exe needed for mozinstall 1.12 and higher.", +) +def test_install(tmpdir, get_installer): + """Test to install an installer.""" + if mozinfo.isLinux: + installdir = mozinstall.install(get_installer("tar.bz2"), tmpdir.strpath) + assert installdir == tmpdir.join("firefox").strpath + + elif mozinfo.isWin: + installdir_exe = mozinstall.install( + get_installer("exe"), tmpdir.join("exe").strpath + ) + assert installdir_exe == tmpdir.join("exe", "firefox").strpath + + installdir_zip = mozinstall.install( + get_installer("zip"), tmpdir.join("zip").strpath + ) + assert installdir_zip == tmpdir.join("zip", "firefox").strpath + + elif mozinfo.isMac: + installdir = mozinstall.install(get_installer("dmg"), tmpdir.strpath) + assert installdir == tmpdir.realpath().join("Firefox Stub.app").strpath + + mounted_images = subprocess.check_output(["hdiutil", "info"]).decode("ascii") + assert get_installer("dmg") not in mounted_images + + +if __name__ == "__main__": + mozunit.main() |