Exemplo n.º 1
0
    def test_create(self):
        ti = TreeInfo()
        ti.release.name = "Fedora"
        ti.release.short = "F"
        ti.release.version = "20"

        ti.tree.arch = "x86_64"
        ti.tree.build_timestamp = 123456

        variant = Variant(ti)
        variant.id = "Fedora"
        variant.uid = "Fedora"
        variant.name = "Fedora"
        variant.type = "variant"

        variant.paths.repository = "repo"
        variant.paths.packages = "pkgs"
        variant.paths.source_repository = "src repo"
        variant.paths.source_packages = "src pkgs"
        variant.paths.debug_repository = "debug repo"
        variant.paths.debug_packages = "debug pkgs"
        variant.paths.identity = "cert.pem"

        ti.variants.add(variant)

        ti.dump(self.ini_path)
        self._test_identity(ti)
Exemplo n.º 2
0
    def test_create(self):
        ti = TreeInfo()
        ti.release.name = "Fedora"
        ti.release.short = "F"
        ti.release.version = "20"

        ti.tree.arch = "x86_64"
        ti.tree.build_timestamp = 123456

        variant = Variant(ti)
        variant.id = "Fedora"
        variant.uid = "Fedora"
        variant.name = "Fedora"
        variant.type = "variant"

        variant.paths.repository = "repo"
        variant.paths.packages = "pkgs"
        variant.paths.source_repository = "src repo"
        variant.paths.source_packages = "src pkgs"
        variant.paths.debug_repository = "debug repo"
        variant.paths.debug_packages = "debug pkgs"
        variant.paths.identity = "cert.pem"

        ti.variants.add(variant)

        ti.dump(self.ini_path)
        self._test_identity(ti)
Exemplo n.º 3
0
    def test_create_with_two_variants(self):
        ti = TreeInfo()
        ti.release.name = "Fedora"
        ti.release.short = "F"
        ti.release.version = "20"

        ti.tree.arch = "x86_64"
        ti.tree.build_timestamp = 123456

        variant_1 = Variant(ti)
        variant_1.id = "AppStream"
        variant_1.uid = "AppStream"
        variant_1.name = "AppStream"
        variant_1.type = "variant"

        variant_1.paths.repository = "repo"
        variant_1.paths.packages = "pkgs"
        variant_1.paths.source_repository = "src repo"
        variant_1.paths.source_packages = "src pkgs"
        variant_1.paths.debug_repository = "debug repo"
        variant_1.paths.debug_packages = "debug pkgs"
        variant_1.paths.identity = "cert.pem"

        ti.variants.add(variant_1)

        variant_2 = Variant(ti)
        variant_2.id = "BaseOS"
        variant_2.uid = "BaseOS"
        variant_2.name = "BaseOS"
        variant_2.type = "variant"

        variant_2.paths.repository = "repo_2"
        variant_2.paths.packages = "pkgs_2"
        variant_2.paths.source_repository = "src repo 2"
        variant_2.paths.source_packages = "src pkgs 2"
        variant_2.paths.debug_repository = "debug repo 2"
        variant_2.paths.debug_packages = "debug pkgs 2"
        variant_2.paths.identity = "cert2.pem"

        ti.variants.add(variant_2)

        ti.dump(self.ini_path, main_variant='BaseOS')
        with open(
                self.ini_path, 'r'
        ) as treeinfo_1, open(
            os.path.join(DIR, "treeinfo/multivariants_treeinfo")
        ) as treeinfo_2:
            treeinfo_1_lines = treeinfo_1.readlines()
            treeinfo_2_lines = treeinfo_2.readlines()
        self.assertEqual(
            treeinfo_1_lines,
            treeinfo_2_lines,
        )
Exemplo n.º 4
0
    def _test_identity(self, ti):
        first = os.path.join(self.tmp_dir, "first")
        second = os.path.join(self.tmp_dir, "second")

        # write original file
        ti.dump(first)

        # read file and write it back
        ti = TreeInfo()
        ti.load(first)
        ti.dump(second)

        # check if first and second files are identical
        self.assertSameFiles(first, second)
Exemplo n.º 5
0
    def _test_identity(self, ti):
        first = os.path.join(self.tmp_dir, "first")
        second = os.path.join(self.tmp_dir, "second")

        # write original file
        ti.dump(first)

        # read file and write it back
        ti = TreeInfo()
        ti.load(first)
        ti.dump(second)

        # check if first and second files are identical
        self.assertSameFiles(first, second)
Exemplo n.º 6
0
def append_custom_repo_to_treeinfo(treeinfo_content, path):
    ti = TreeInfo()
    ti.loads(treeinfo_content)

    variant = Variant(ti)

    variant.id = CUSTOM_REPO_NAME
    variant.uid = CUSTOM_REPO_NAME
    variant.name = CUSTOM_REPO_NAME
    variant.paths.repository = os.path.join(".", CUSTOM_REPO_NAME)
    variant.paths.packages = os.path.join(".", CUSTOM_REPO_NAME, PACKAGES_DIR)
    variant.type = "variant"

    ti.variants.add(variant)

    ti.dump(path)