public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Jauhien Piatlicki" <piatlicki@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/g-sorcery:master commit in: tests/
Date: Wed, 18 Sep 2013 22:52:03 +0000 (UTC)	[thread overview]
Message-ID: <1379543745.8a2a0fa3e3fd7f3f7df5dea20d64d005f4521e50.jauhien@gentoo> (raw)

commit:     8a2a0fa3e3fd7f3f7df5dea20d64d005f4521e50
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Sep 18 22:35:45 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Sep 18 22:35:45 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=8a2a0fa3

tests/test_ebuild

---
 tests/test_ebuild.py | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/tests/test_ebuild.py b/tests/test_ebuild.py
new file mode 100644
index 0000000..e227c97
--- /dev/null
+++ b/tests/test_ebuild.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+    test_ebuild.py
+    ~~~~~~~~~~~~~~
+    
+    ebuild test suite
+    
+    :copyright: (c) 2013 by Jauhien Piatlicki
+    :license: GPL-2, see LICENSE for more details.
+"""
+
+import collections
+import os
+import unittest
+
+from g_sorcery.compatibility import TemporaryDirectory
+from g_sorcery.g_collections import Package
+from g_sorcery.ebuild import EbuildGeneratorFromFile, DefaultEbuildGenerator
+from g_sorcery.package_db import PackageDB
+
+from tests.base import BaseTest
+
+
+Layout = collections.namedtuple("Layout",
+    ["vars_before_inherit", "inherit",
+     "vars_after_description", "vars_after_keywords"])
+
+class TestEbuildGenerator(BaseTest):
+
+    ebuild_data = {"herd": ["testers", "crackers"],
+                   'maintainer': [{'email': 'test@example.com',
+                                   'name': 'tux'}],
+                   "longdescription": "very long description here",
+                   "use": {"flag": {"use1": "testing use1", "use2": "testing use2"}},
+                   "homepage": "example.com",
+                   "description": "testing ebuild",
+                   "array": "(a b c d)"}
+    package = Package("app-test", "metadata_tester", "0.1")
+
+    def setUp(self):
+        super(TestEbuildGenerator, self).setUp()
+        self.pkg_db = PackageDB(self.tempdir.name)
+        self.pkg_db.add_category("app-test")
+        self.pkg_db.add_package(self.package, self.ebuild_data)
+
+    def test_ebuild_generator_from_file(self):
+        template = os.path.join(self.tempdir.name, "test.tmpl")
+        os.system("echo 'TEST_SUBST=%(array)s' > " + template)
+        
+        ebuild_g = EbuildGeneratorFromFile(self.pkg_db, template)
+        ebuild = ebuild_g.generate(self.package)
+        self.assertEqual(ebuild, ['TEST_SUBST=(a b c d)'])
+
+    def test_default_ebuild_generator(self):
+        vars_before_inherit = \
+          [{"name":"test_raw_value", "value":"raw_value", "raw":True},
+           {"name":"test_value", "value":"value"}]
+
+        inherit = ["g-test"]
+        
+        vars_after_description = \
+          ["homepage"]
+
+        vars_after_keywords = \
+          [{"name":"array"},
+           {"name":"array", "raw":True}]
+
+        layout = Layout(vars_before_inherit,
+                    inherit, vars_after_description, vars_after_keywords)
+
+        ebuild_g = DefaultEbuildGenerator(self.pkg_db, layout)
+        ebuild = ebuild_g.generate(self.package)
+        self.assertEqual(ebuild, ['# automatically generated by g-sorcery',
+                                  '# please do not edit this file', '',
+                                  'EAPI=5', '',
+                                  'TEST_RAW_VALUE=raw_value', 'TEST_VALUE="value"', '',
+                                  'inherit g-test', '',
+                                  'DESCRIPTION="testing ebuild"', '',
+                                  'HOMEPAGE="example.com"', '',
+                                  'SLOT="0"', 'KEYWORDS="~amd64 ~x86"', '',
+                                  'ARRAY="(a b c d)"', 'ARRAY=(a b c d)', ''])
+
+
+def suite():
+    suite = unittest.TestSuite()
+    suite.addTest(TestEbuildGenerator('test_ebuild_generator_from_file'))
+    suite.addTest(TestEbuildGenerator('test_default_ebuild_generator'))
+    return suite


             reply	other threads:[~2013-09-18 22:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18 22:52 Jauhien Piatlicki [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-05-04 15:50 [gentoo-commits] proj/g-sorcery:master commit in: tests/ Ulrich Müller
2021-05-04 15:50 Ulrich Müller
2021-05-04 15:50 Ulrich Müller
2013-09-18 22:52 Jauhien Piatlicki
2013-09-18 22:09 Jauhien Piatlicki
2013-09-18 22:09 Jauhien Piatlicki
2013-09-18  0:57 Jauhien Piatlicki
2013-09-16 14:33 Jauhien Piatlicki
2013-09-16  0:19 Jauhien Piatlicki
2013-09-15 22:38 Jauhien Piatlicki
2013-09-15 22:38 Jauhien Piatlicki
2013-09-15 22:38 Jauhien Piatlicki
2013-07-17 15:41 Jauhien Piatlicki
2013-07-14 23:39 Jauhien Piatlicki
2013-07-08 23:53 Jauhien Piatlicki
2013-07-02 14:48 Jauhien Piatlicki
2013-07-02 10:21 Jauhien Piatlicki
2013-06-23  0:44 Jauhien Piatlicki
2013-06-23  0:44 Jauhien Piatlicki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379543745.8a2a0fa3e3fd7f3f7df5dea20d64d005f4521e50.jauhien@gentoo \
    --to=piatlicki@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox