# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import datetime import pathlib import sys import tempfile import unittest from contextlib import nullcontext as does_not_raise
import mozpack.path as mozpath import mozunit import pytest
# Patch os.path.exists. We want to simulate: # - The expected RPM package file's existence is governed by our parameter. # - The upload_dir does not exist (so that os.mkdir is triggered). # - All other paths exist. def fake_exists(path):
expected_rpm_path = mozpath.join(
temp_testing_dir_name, "target_dir", "i386", "firefox-111.0-1.i386.rpm"
) if path == expected_rpm_path: return does_rpm_package_exist if path == upload_dir: returnFalse# force creation of the upload_dir returnTrue
# Patch pathlib.Path.glob for the noarch directory. # We'll have the glob return a list with one dummy RPM file.
original_glob = pathlib.Path.glob
def fake_glob(self, pattern): if pattern == "*.rpm": # The function will copy a dummy langpack RPM file into UPLOAD_DIR. # Construct a dummy path that resembles the full path. return [
str(
self.joinpath(
temp_testing_dir_name, "target_dir", "noarch", "langpack.dummy.rpm",
)
)
] return original_glob(self, pattern)
# If the RPM package exists, verify that all file copies and directory creation occurred. if does_rpm_package_exist: # The function first copies the tarball.
expected_tar_dest = mozpath.join(
temp_testing_dir_name, "source_dir", "rpm", "firefox.tar.xz"
) assert ( "copy",
mozpath.join(temp_testing_dir_name, "tmp", "firefox.tar.xz"),
expected_tar_dest,
) in copy_call_history
# Then it copies the RPM package.
expected_rpm_path = mozpath.join(
temp_testing_dir_name, "target_dir", "i386", "firefox-111.0-1.i386.rpm"
) assert ("copy", expected_rpm_path, "target.rpm") in copy_call_history
# Finally, it copies any langpack RPM files from the noarch directory based on the LANGUAGES build variable.
expected_dummy_path = mozpath.join(
temp_testing_dir_name, "target_dir", "noarch", "firefox-l10n-dummy-111.0-1.noarch.rpm",
)
expected_dest = mozpath.join(upload_dir, "langpack-dummy.noarch.rpm") # Look for a call that copies the langpack file to the upload dir:
found = any(
str(src) == expected_dummy_path and dst == expected_dest for _, src, dst in copy_call_history
) assert found, "The dummy langpack RPM file was not copied to the upload_dir."
# Verify that the function created the upload directory. assert upload_dir in mkdir_calls
temp_testing_dir.cleanup()
def test_generate_rpm_archive_missing_upload_dir(monkeypatch): # Ensure UPLOAD_DIR is not defined.
monkeypatch.delenv("UPLOAD_DIR", raising=False)
# For this test, let the expected RPM file exist. def fake_exists(path):
expected_rpm_path = mozpath.join( "/target_dir", "i386", "firefox-111.0-1.i386.rpm"
) if path == expected_rpm_path: returnTrue returnTrue
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.1Bemerkung:
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-08-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.