From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- testing/mozbase/mozprofile/tests/test_addonid.py | 157 +++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100755 testing/mozbase/mozprofile/tests/test_addonid.py (limited to 'testing/mozbase/mozprofile/tests/test_addonid.py') diff --git a/testing/mozbase/mozprofile/tests/test_addonid.py b/testing/mozbase/mozprofile/tests/test_addonid.py new file mode 100755 index 0000000000..4a9bef0163 --- /dev/null +++ b/testing/mozbase/mozprofile/tests/test_addonid.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python + +import os + +import mozunit +import pytest +from mozprofile import addons + +here = os.path.dirname(os.path.abspath(__file__)) + + +"""Test finding the addon id in a variety of install.rdf styles""" + + +ADDON_ID_TESTS = [ + """ + + + winning + MozMill + 2.0a + Adam Christian + A testing extension based on the + Windmill Testing Framework client source + true + + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 3.5 + 8.* + + + + + + {3550f703-e582-4d05-9a08-453d09bdfdc6} + 3.0a1pre + 3.2* + + + + + + {718e30fb-e89b-41dd-9da7-e25a45638b28} + 0.6a1 + 1.0pre + + + + + + {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} + 2.0a1 + 2.1* + + + + + + songbird@songbirdnest.com + 0.3pre + 1.3.0a + + + + + toolkit@mozilla.org + 1.9.1 + 2.0* + + + +""", + """ + + + + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 3.5 + 8.* + + + winning + MozMill + 2.0a + Adam Christian + A testing extension based on the + Windmill Testing Framework client source + true + + """, + """ + + + winning + foo + 42 + A testing extension based on the + Windmill Testing Framework client source + +""", + """ + + + + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + 3.5 + 8.* + + + winning + MozMill + 2.0a + Adam Christian + A testing extension based on the + Windmill Testing Framework client source + true + + """, +] + + +@pytest.fixture( + params=ADDON_ID_TESTS, ids=[str(i) for i in range(0, len(ADDON_ID_TESTS))] +) +def profile(request, tmpdir): + test = request.param + path = tmpdir.mkdtemp().strpath + + with open(os.path.join(path, "install.rdf"), "w") as fh: + fh.write(test) + return path + + +def test_addonID(profile): + a = addons.AddonManager(os.path.join(profile, "profile")) + addon_id = a.addon_details(profile)["id"] + assert addon_id == "winning" + + +def test_addonID_xpi(): + a = addons.AddonManager("profile") + addon = a.addon_details(os.path.join(here, "addons", "empty.xpi")) + assert addon["id"] == "test-empty@quality.mozilla.org" + + +if __name__ == "__main__": + mozunit.main() -- cgit v1.2.3