testing/mozbase/mozprofile/tests/test_bug758250.py
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Sun, 07 Aug 2022 18:55:32 +0000
changeset 626347 411a7fe740a6a39a3fec0ece5d4ff52f6b99ead2
parent 554551 994ae8e4833c90447d91f0e26a718573cff5a514
permissions -rwxr-xr-x
no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD be -> a2c794f1c5853b3063f08a50934e8dc5b1948ad3 he -> 90a868ca1576aa63dac81436b5991734b3ad9d2f kk -> af591ca4a31bbd78859cb5943312b39536a354f7 nb-NO -> de31b9f1b1dbbc2761cc1cecee6a726f39eb010d nn-NO -> 8e91323e7c7d271dd994742539b50fbb1ad8a9d5 pa-IN -> 59b9c5898869cfcc424f372a366cf6d5ed0e751d sk -> be0fcf54c543d60a0689ef592e5fb278a97cc14f tr -> 23541078ba1272345e59e125f640a54ac63231af

#!/usr/bin/env python

from __future__ import absolute_import

import mozprofile
import os
import shutil

import mozunit

here = os.path.dirname(os.path.abspath(__file__))

"""
use of --profile in mozrunner just blows away addon sources:
https://bugzilla.mozilla.org/show_bug.cgi?id=758250
"""


def test_profile_addon_cleanup(tmpdir):
    tmpdir = tmpdir.mkdtemp().strpath
    addon = os.path.join(here, "addons", "empty")

    # sanity check: the empty addon should be here
    assert os.path.exists(addon)
    assert os.path.isdir(addon)
    assert os.path.exists(os.path.join(addon, "install.rdf"))

    # because we are testing data loss, let's make sure we make a copy
    shutil.rmtree(tmpdir)
    shutil.copytree(addon, tmpdir)
    assert os.path.exists(os.path.join(tmpdir, "install.rdf"))

    # make a starter profile
    profile = mozprofile.FirefoxProfile()
    path = profile.profile

    # make a new profile based on the old
    newprofile = mozprofile.FirefoxProfile(profile=path, addons=[tmpdir])
    newprofile.cleanup()

    # the source addon *should* still exist
    assert os.path.exists(tmpdir)
    assert os.path.exists(os.path.join(tmpdir, "install.rdf"))


if __name__ == "__main__":
    mozunit.main()