コード例 #1
0
    def test_00_template_compile(self):
        template_path = os.path.join(selfdir(), "template_example_00.tmpl")

        c0 = TW.template_compile(template_path, {})
        c1 = TW.template_compile(template_path,
            {"title": "pyTenjin tests: context", }
        )

        # TBD:
        self.assertTrue(bool(c0))
        self.assertTrue(bool(c1))
コード例 #2
0
    def test__Makefile_am(self):
        tmpl = tmplpath("Makefile.am")

        paths = ["/a/b/c", "/a/b/d", "/a/e/f", "/a/g/h/i/j", "/x/y/z"]

        files = [FO.FileObject(p) for p in random.sample(paths, 3)] + \
            [FO.DirObject(p) for p in random.sample(paths, 3)] + \
            [FO.SymlinkObject(p, p) for p in random.sample(paths, 3)]

        distdata = [
            Bunch(id=i, files=random.sample(paths, 3), dir="/a/b") \
                for i in range(5)
        ]
        conflicts = Bunch(files=[1, 2, 3])  # dummy

        context = dict(
            name="foobar",
            format="rpm",
            distdata=distdata,
            files=files,
            conflicts=conflicts,
        )

        c = TW.template_compile(tmpl, context)
        self.assertNotEquals(c, "")
コード例 #3
0
    def test__format(self):
        tmpl = tmplpath("format")

        c = TW.template_compile(tmpl, {})
        c_ref = open(tmpl).read()

        self.assertEquals(c, c_ref)
コード例 #4
0
    def test__options(self):
        tmpl = tmplpath("options")

        c = TW.template_compile(tmpl, {})
        c_ref = open(tmpl).read()

        self.assertEquals(c, c_ref)
コード例 #5
0
ファイル: 1_autotools.py プロジェクト: ssato/packagemaker
    def test__01_package_spec(self):
        tmpl = tmplpath("package.spec")

        context = dict(
            name="foobarbaz",
            pversion="2.1.0",
            release="0.0.1",
            summary="pmaker RPM package example",
            group="Application/Text",
            license="GPLv3+",
            url="http://www.example.com/git/foobarbaz",
            compressor=Bunch(ext="xz", ),
            arch=False,
            hostname=E.hostname(),
            packager=E.get_fullname(),
            email=E.get_email(),
            date=Bunch(date="dummy date", timestamp="dummy timestamp"),
            files=[],
            conflicts=Bunch(files=[],),
            not_conflicts=Bunch(files=[],),
            relations=[],
            trigger=False,
        )

        c = TW.template_compile(tmpl, context)
コード例 #6
0
ファイル: 1_autotools.py プロジェクト: ssato/packagemaker
    def test__00_rpm_mk(self):
        tmpl = tmplpath("rpm.mk")

        c = TW.template_compile(tmpl, {})
        c_ref = open(tmpl).read()

        self.assertEquals(c, c_ref)
コード例 #7
0
    def test__compat(self):
        tmpl = tmplpath("compat")

        # Template and generated output from it should equals.
        c = TW.template_compile(tmpl, {})
        c_ref = open(tmpl).read()

        self.assertEquals(c, c_ref)
コード例 #8
0
    def test__copyright(self):
        tmpl = tmplpath("copyright")
        context = dict(
            packager="John Doe",
            email="*****@*****.**",
            date=Bunch(date="2011-11-10 20:03"),
            license="MIT",
        )

        c = TW.template_compile(tmpl, context)
        self.assertNotEquals(c, "")
コード例 #9
0
    def test__changelog__w_content(self):
        tmpl = tmplpath("changelog")

        c_ref = open(
            os.path.join(
                os.path.dirname(__file__), "debian_changelog_example_00"
            )
        ).read()

        c = TW.template_compile(tmpl, {"changelog": c_ref})
        self.assertEquals(c, c_ref)
コード例 #10
0
    def test__configure_ac(self):
        tmpl = tmplpath("configure.ac")

        context = dict(
            name="foobar",
            pversion="0.0.1",
            compressor=Bunch(am_opt="dist-xz", ),
        )

        c = TW.template_compile(tmpl, context)
        self.assertNotEquals(c, "")
コード例 #11
0
    def test_01_package_spec(self):
        tmpl = tmplpath("minimal/package.spec")

        context = dict(
            name="foo",
            version="1.0",
            summary="foo library",
            license="GPLv2+",
        )

        c = TW.template_compile(tmpl, context)
コード例 #12
0
ファイル: 1_rpmspec_R.py プロジェクト: masatake/packagemaker
    def test_01_package_spec(self):
        tmpl = tmplpath("R/package.spec")

        context = dict(
            name="R-foo-bar-baz",
            version="1.0",
            license="GPLv2+",
            summary="R foo bar baz library",
        )

        c = TW.template_compile(tmpl, context)
コード例 #13
0
    def test_01_package_spec(self):
        tmpl = tmplpath("php-pear/package.spec")

        context = dict(
            name="php-pear-foo-bar-baz",
            version="1.0",
            license="PHP",
            summary="PHP PEAR foo bar baz library",
            description="PHP PEAR foo bar baz library",
        )

        c = TW.template_compile(tmpl, context)
コード例 #14
0
    def test__changelog__wo_content(self):
        tmpl = tmplpath("changelog")
        context = dict(
            name="foobar",
            pversion="0.0.2",
            packager="John Doe",
            email="*****@*****.**",
            date=Bunch(date="2011-11-10 20:03"),
        )

        c = TW.template_compile(tmpl, context)
        self.assertNotEquals(c, "")
コード例 #15
0
    def test__dirs(self):
        tmpl = tmplpath("dirs")
        files = [
            FO.DirObject("/a/b/c"),
            FO.FileObject("/a/b/c/x"),
            FO.DirObject("/d/e"),
            FO.FileObject("/d/e/y"),
            FO.DirObject("/f/g/h/i"),
            FO.SymlinkObject("/f/g/h/i/j", "/a/b/c/x"),
        ]

        c = TW.template_compile(tmpl, {"files": files})
        self.assertNotEquals(c, "")
コード例 #16
0
    def test_01_package_spec(self):
        tmpl = tmplpath("python/package.spec")

        context = dict(
            name="python-foo-bar-baz",
            version="1.0",
            license="MIT",
            url="http://example.com/foo-bar-baz",
            summary="Python foo bar baz library",
            description="Python foo bar baz library",
        )

        c = TW.template_compile(tmpl, context)
コード例 #17
0
    def test_01_package_spec(self):
        tmpl = tmplpath("lib/package.spec")

        context = dict(
            name="foo",
            version="1.0",
            license="GPLv3+",
            summary="foo bar baz tool and libs",
            description="""foo bar baz tool and libs.
blah blah blah ...
""",
        )

        c = TW.template_compile(tmpl, context)
コード例 #18
0
    def test_01_package_spec(self):
        tmpl = tmplpath("ghc-bin/package.spec")

        context = dict(
            name="foo",
            version="1.0",
            license="BSD3",
            summary="foo bar baz library",
            description="""foo bar baz library
blah blah blah ...
""",
        )

        c = TW.template_compile(tmpl, context)
コード例 #19
0
ファイル: 1_common.py プロジェクト: masatake/packagemaker
    def test__README(self):
        tmpl = tmplpath("README")

        d = Bunch(date="2011.11.10")

        context = dict(
            hostname="foobar.example.com",
            packager="John Doe",
            date=d,
        )

        # TBD:
        c = TW.template_compile(tmpl, context)
        self.assertTrue(c != "")
コード例 #20
0
ファイル: 1_buildrpm.py プロジェクト: ssato/packagemaker
    def test__package_spec(self):
        filelist = os.path.join(
            selfdir(), "config_example_01.json"
        )
        args = "-n foo -C " + filelist
        pkgdata = BTC.init_pkgdata(args)

        # TODO:
        pkgdata.relations = []
        context = pkgdata

        tmpl = tmplpath("package.spec")

        c = TW.template_compile(tmpl, context)
        self.assertNotEquals(c, "")
コード例 #21
0
    def test_01_package_spec(self):
        tmpl = tmplpath("ghc-lib/package.spec")

        context = dict(
            name="foo",
            version="1.0",
            group="Development/Tools",
            license="BSD3",
            summary="foo bar baz tool and libs",
            description="""foo bar baz tool and libs.
blah blah blah ...
""",
        )

        c = TW.template_compile(tmpl, context)
コード例 #22
0
ファイル: 1_common.py プロジェクト: masatake/packagemaker
    def test__manifest_overrides(self):
        tmpl = tmplpath("manifest.overrides")

        context = dict(
            conflicts=Bunch(
                files=[
                    Bunch(install_path=p) for p in ["/a/b/c", "/w/x/y/z"]
                ]
            ),
        )
        c_ref = """\
/a/b/c
/w/x/y/z
"""

        c = TW.template_compile(tmpl, context)
        self.assertEquals(c, c_ref)
コード例 #23
0
ファイル: base.py プロジェクト: masatake/packagemaker
    def genfile(self, template, output):
        """
        Generate file in workdir from given template.

        :param template:  Template file path relative to search dirs
        :param output:  Output file path relative to workdir
        """
        out = os.path.join(self.workdir, output)
        tmpl = U.find_template(template, self.template_paths)

        if tmpl is None:
            raise RuntimeError(
                "Template not found in your search paths: " + template
            )

        content = T.template_compile(tmpl, self.pkgdata)
        open(out, "w").write(content)  # may throw IOError, OSError.
コード例 #24
0
ファイル: 1_common.py プロジェクト: masatake/packagemaker
    def test__revert_overrides__wo_conflicts(self):
        tmpl = tmplpath("revert-overrides")

        context = dict(
            conflicts=Bunch(
                files=[],
                savedir=CONFLICTS_SAVEDIR % {"name": "foo"},
                newdir=CONFLICTS_NEWDIR % {"name": "foo"},
            )
        )

        c = TW.template_compile(tmpl, context)
        c_ref = """\
#! /bin/bash
set -e

# No conflicts and nothing to do:
exit 0
"""
        self.assertEquals(c, c_ref)
コード例 #25
0
ファイル: 1_common.py プロジェクト: masatake/packagemaker
    def test__apply_overrides(self):
        tmpl = tmplpath("apply-overrides")

        paths = ["/a/b/c", "/a/b/d", "/a/e/f", "/a/g/h/i/j", "/x/y/z"]

        def g(f, paths=paths):
            f.original_path = random.choice(paths)
            return f

        files = [g(FO.FileObject(p)) for p in random.sample(paths, 4)]

        context = dict(
            conflicts=Bunch(
                files=files,
                savedir=CONFLICTS_SAVEDIR % {"name": "foo"},
                newdir=CONFLICTS_NEWDIR % {"name": "foo"},
            )
        )

        # TBD:
        c = TW.template_compile(tmpl, context)
        self.assertTrue(c != "")
コード例 #26
0
    def test__control(self):
        tmpl = tmplpath("control")

        context = dict(
            name="foobar",
            packager="John Doe",
            email="*****@*****.**",
            url="http://www.example.com/git/foobar.git",
            arch=False,
            relations=[
                Bunch(targets=["abc", "defg"], type="Depends"),
                Bunch(targets=["hi", "jklmn"], type="Depends"),
                Bunch(targets=["stu", "xyz"], type="Suggests"),
            ],
            summary="Debian package example",
        )

        c = TW.template_compile(tmpl, context)
        self.assertNotEquals(c, "")

        with open("/tmp/test.out", "w") as f:
            f.write(c)