From: "Jauhien Piatlicki" <piatlicki@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/g-sorcery:master commit in: tests/
Date: Sun, 14 Jul 2013 23:39:57 +0000 (UTC) [thread overview]
Message-ID: <1373845198.81fa1eb9662c77bb0cdae8efa1d62874e03ae62f.jauhien@gentoo> (raw)
commit: 81fa1eb9662c77bb0cdae8efa1d62874e03ae62f
Author: Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Sun Jul 14 23:39:58 2013 +0000
Commit: Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Sun Jul 14 23:39:58 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=81fa1eb9
tests fixed
---
tests/test_backend.py | 88 ----------------------------------------------
tests/test_dispatcher.py | 29 ---------------
tests/test_ebuild.py | 25 ++++---------
tests/test_elpa_db.py | 2 +-
tests/test_elpa_ebuild.py | 89 -----------------------------------------------
tests/test_g_sorcery.py | 70 -------------------------------------
6 files changed, 7 insertions(+), 296 deletions(-)
diff --git a/tests/test_backend.py b/tests/test_backend.py
deleted file mode 100644
index 0ed5ff2..0000000
--- a/tests/test_backend.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
- test_backend.py
- ~~~~~~~~~~~~~~~
-
- backend test suite
-
- :copyright: (c) 2013 by Jauhien Piatlicki
- :license: GPL-2, see LICENSE for more details.
-"""
-
-import os, tempfile, unittest
-
-from g_sorcery import backend, ebuild, metadata, package_db
-
-from tests import test_ebuild, test_metadata
-
-from tests.base import BaseTest
-
-class DummyBackend(backend.Backend):
- def __init__(self, PackageDB, EbuildGenrator, MetadataGenerator, directory,
- sync_db=True, eclass_dir=""):
- super(DummyBackend, self).__init__(PackageDB, EbuildGenrator, MetadataGenerator, directory,
- sync_db=sync_db, eclass_dir=eclass_dir)
-
-
-class TestBackend(BaseTest):
-
- def test_list_eclasses(self):
- backend = DummyBackend(package_db.PackageDB, ebuild.EbuildGenerator,
- metadata.MetadataGenerator,
- self.tempdir.name, eclass_dir = self.tempdir.name)
- self.assertEqual(backend.list_eclasses(), [])
- lst = ['test', 'supertest', 'anothertest']
- for f_name in lst:
- with open(os.path.join(self.tempdir.name, f_name + '.eclass'), 'w') as f:
- f.write("test")
- self.assertEqual(set(backend.list_eclasses()), set(lst))
-
- def test_generate_eclass(self):
- backend = DummyBackend(package_db.PackageDB, ebuild.EbuildGenerator,
- metadata.MetadataGenerator,
- self.tempdir.name, eclass_dir = self.tempdir.name)
- eclass = ["testing eclass", "nothing interesting here"]
- eclass_name = "test"
- with open(os.path.join(self.tempdir.name, eclass_name + '.eclass'), 'w') as f:
- for line in eclass:
- f.write(line + '\n')
- g_eclass = backend.generate_eclass(eclass_name)
- self.assertEqual(eclass, g_eclass)
-
- def test_list_ebuilds(self):
- backend = DummyBackend(test_ebuild.DummyDB, test_ebuild.DummyEbuildGenerator,
- metadata.MetadataGenerator,
- self.tempdir.name, eclass_dir = self.tempdir.name, sync_db = False)
- backend.sync()
- ebuilds = backend.list_ebuilds()
- self.assertEqual(set(ebuilds), set([test_ebuild.package, test_ebuild.package2]))
-
- def test_generate_ebuild(self):
- backend = DummyBackend(test_ebuild.DummyDB, test_ebuild.DummyEbuildGenerator,
- metadata.MetadataGenerator,
- self.tempdir.name, eclass_dir = self.tempdir.name, sync_db = False)
- backend.sync()
- ebuild = backend.generate_ebuild(test_ebuild.package)
- self.assertEqual(ebuild, ['test', 'author: jauhien',
- 'homepage: 127.0.0.1', 'var: $var'])
-
- def test_generate_metadata(self):
- backend = DummyBackend(test_metadata.DummyDB, ebuild.EbuildGenerator,
- metadata.MetadataGenerator,
- self.tempdir.name, eclass_dir = self.tempdir.name, sync_db = False)
- backend.sync()
- self.assertEqual(backend.generate_metadata("app-test", "test"),
- test_metadata.resulting_metadata)
-
-
-
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(TestBackend('test_list_eclasses'))
- suite.addTest(TestBackend('test_generate_eclass'))
- suite.addTest(TestBackend('test_list_ebuilds'))
- suite.addTest(TestBackend('test_generate_ebuild'))
- suite.addTest(TestBackend('test_generate_metadata'))
- return suite
diff --git a/tests/test_dispatcher.py b/tests/test_dispatcher.py
deleted file mode 100644
index 517158d..0000000
--- a/tests/test_dispatcher.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
- test_dispatcher.py
- ~~~~~~~~~~~~~~~~~~
-
- backend dispatcher test suite
-
- :copyright: (c) 2013 by Jauhien Piatlicki
- :license: GPL-2, see LICENSE for more details.
-"""
-
-import unittest
-
-from g_sorcery import dispatcher
-
-from tests.base import BaseTest
-
-class TestDispatcher(BaseTest):
-
- def test_dispatcher(self):
- pass
-
-
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(TestDispatcher('test_dispatcher'))
- return suite
diff --git a/tests/test_ebuild.py b/tests/test_ebuild.py
index 47c4e40..7488152 100644
--- a/tests/test_ebuild.py
+++ b/tests/test_ebuild.py
@@ -13,7 +13,7 @@
import os, tempfile, unittest
-from g_sorcery import ebuild, package_db, exceptions
+from g_sorcery import ebuild, package_db, exceptions, g_collections
from tests.base import BaseTest
@@ -34,7 +34,7 @@ class DummyDB(package_db.PackageDB):
class DummyEbuildGenerator(ebuild.EbuildGenerator):
def get_template(self, ebuild, description):
- tmpl = ["test", "author: $author", "homepage: $homepage", "var: $$var"]
+ tmpl = ["test", "author: %(author)s", "homepage: %(homepage)s", "var: $var"]
return tmpl
@@ -43,7 +43,7 @@ class TestEbuildGenerator(BaseTest):
def test_process(self):
eg = DummyEbuildGenerator(None)
tst_dict = {"a" : "d", "b" : "e", "c" : "f"}
- ebuild = ["$a", "$b", "$c"]
+ ebuild = ["%(a)s", "%(b)s", "%(c)s"]
ebuild = eg.process(ebuild, tst_dict)
self.assertEqual(ebuild, ["d", "e", "f"])
@@ -73,31 +73,18 @@ class TestEbuildGeneratorFromFile(BaseTest):
tmpl = os.path.join(self.tempdir.name, 'tst.tmpl')
with open(tmpl, 'w') as f:
f.write("""test
-author: $author
-homepage: $homepage
-var: $$var""")
+author: %(author)s
+homepage: %(homepage)s
+var: $var""")
eg = DummyEbuildGeneratorFromFile(db, tmpl)
ebuild = eg.generate(package)
self.assertEqual(ebuild, ['test', 'author: jauhien',
'homepage: 127.0.0.1', 'var: $var'])
-
-class TestSubstituteList(BaseTest):
-
- def test_substitute_list(self):
- text = ['a', 'test', 'DEPEND="#n#depend#"', 'IUSE="# #iuse#"']
- desc = {'depend' : ['app-test/test1', 'app-test/test2'],
- 'iuse' : ['test', 'check']}
- result = ['a', 'test', 'DEPEND="app-test/test1\napp-test/test2"', 'IUSE="test check"']
- for idx, string in enumerate(text):
- self.assertEqual(ebuild.substitute_list(string, desc), result[idx])
- self.assertRaises(exceptions.DescriptionError, ebuild.substitute_list, text[2], {})
-
def suite():
suite = unittest.TestSuite()
suite.addTest(TestEbuildGenerator('test_process'))
suite.addTest(TestEbuildGenerator('test_generate'))
suite.addTest(TestEbuildGeneratorFromFile('test_generate'))
- suite.addTest(TestSubstituteList('test_substitute_list'))
return suite
diff --git a/tests/test_elpa_db.py b/tests/test_elpa_db.py
index ec50b14..3df86e1 100644
--- a/tests/test_elpa_db.py
+++ b/tests/test_elpa_db.py
@@ -121,7 +121,7 @@ class TestElpaDB(BaseTest):
deps.append(package_db.Package('app-emacs',
d[0],
'.'.join(map(str, d[1]))))
- depend.append('app-emacs' + '/' + d[0] + '-' + '.'.join(map(str, d[1])))
+ depend.append('app-emacs' + '/' + d[0])
dependencies = description['dependencies']
for d in dependencies:
diff --git a/tests/test_elpa_ebuild.py b/tests/test_elpa_ebuild.py
deleted file mode 100644
index 1895340..0000000
--- a/tests/test_elpa_ebuild.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
- test_elpa_ebuild.py
- ~~~~~~~~~~~~~~~~~~~
-
- ELPA ebuild generator test suite
-
- :copyright: (c) 2013 by Jauhien Piatlicki
- :license: GPL-2, see LICENSE for more details.
-"""
-
-import os, unittest
-
-from g_sorcery import package_db
-
-from g_elpa import elpa_db, ebuild
-
-from tests.base import BaseTest
-
-from tests.test_elpa_db import fill_database, packages
-
-class TestElpaEbuildGenerator(BaseTest):
-
- def test_generate_without_digest(self):
- edb = elpa_db.ElpaDB(os.path.join(self.tempdir.name, 'db'),
- repo_uri = 'http://127.0.0.1:8080')
- fill_database(edb, packages, self.tempdir.name)
- ebuild_generator = ebuild.ElpaEbuildWithoutDigestGenerator(edb)
- src = ebuild_generator.generate(package_db.Package('app-emacs', 'ack', '1.2'))
- self.assertEqual(src,
- ['# automatically generated by g-elpa',
- '# please do not edit this file', '',
- 'EAPI=5', '', 'REPO_URI="http://127.0.0.1:8080"',
- 'PKG_TYPE="tar"', 'REALNAME="ack"', '', 'inherit g-elpa', '',
- 'DESCRIPTION="Interface to ack-like source code search tools"',
- 'HOMEPAGE="http://127.0.0.1:8080"', 'SRC_URI=""',
- 'LICENSE="GPL-2"', '', 'SLOT="0"', 'KEYWORDS="~amd64 ~x86"',
- 'IUSE=""', '', 'DEPEND=""', 'RDEPEND=""'])
- src = ebuild_generator.generate(package_db.Package('app-emacs', 'dict-tree', '0.12.8'))
- self.assertEqual(src,
- ['# automatically generated by g-elpa',
- '# please do not edit this file', '', 'EAPI=5', '',
- 'REPO_URI="http://127.0.0.1:8080"', 'PKG_TYPE="tar"',
- 'REALNAME="dict-tree"', '',
- 'inherit g-elpa', '', 'DESCRIPTION="Dictionary data structure"',
- 'HOMEPAGE="http://127.0.0.1:8080"', 'SRC_URI=""',
- 'LICENSE="GPL-2"', '', 'SLOT="0"',
- 'KEYWORDS="~amd64 ~x86"', 'IUSE=""', '',
- 'DEPEND="app-emacs/trie-0.2.5\napp-emacs/tNFA-0.1.1\napp-emacs/heap-0.3"',
- 'RDEPEND="app-emacs/trie-0.2.5\napp-emacs/tNFA-0.1.1\napp-emacs/heap-0.3"'])
-
- def test_generate_with_digest(self):
- edb = elpa_db.ElpaDB(os.path.join(self.tempdir.name, 'db'),
- repo_uri = 'http://127.0.0.1:8080')
- fill_database(edb, packages, self.tempdir.name)
- ebuild_generator = ebuild.ElpaEbuildWithDigestGenerator(edb)
- src = ebuild_generator.generate(package_db.Package('app-emacs', 'ack', '1.2'))
- self.assertEqual(src,
- ['# automatically generated by g-elpa',
- '# please do not edit this file', '',
- 'EAPI=5', '', 'REPO_URI="http://127.0.0.1:8080"',
- 'PKG_TYPE="tar"', 'REALNAME="ack"', '', 'inherit g-elpa', '',
- 'DESCRIPTION="Interface to ack-like source code search tools"',
- 'HOMEPAGE="http://127.0.0.1:8080"',
- 'SRC_URI="${REPO_URI}${REALNAME}-${PV}.${SUFFIX}"',
- 'LICENSE="GPL-2"', '', 'SLOT="0"', 'KEYWORDS="~amd64 ~x86"',
- 'IUSE=""', '', 'DEPEND=""', 'RDEPEND=""'])
- src = ebuild_generator.generate(package_db.Package('app-emacs', 'dict-tree', '0.12.8'))
- self.assertEqual(src,
- ['# automatically generated by g-elpa',
- '# please do not edit this file', '', 'EAPI=5', '',
- 'REPO_URI="http://127.0.0.1:8080"', 'PKG_TYPE="tar"',
- 'REALNAME="dict-tree"', '',
- 'inherit g-elpa', '', 'DESCRIPTION="Dictionary data structure"',
- 'HOMEPAGE="http://127.0.0.1:8080"',
- 'SRC_URI="${REPO_URI}${REALNAME}-${PV}.${SUFFIX}"',
- 'LICENSE="GPL-2"', '', 'SLOT="0"',
- 'KEYWORDS="~amd64 ~x86"', 'IUSE=""', '',
- 'DEPEND="app-emacs/trie-0.2.5\napp-emacs/tNFA-0.1.1\napp-emacs/heap-0.3"',
- 'RDEPEND="app-emacs/trie-0.2.5\napp-emacs/tNFA-0.1.1\napp-emacs/heap-0.3"'])
-
-
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(TestElpaEbuildGenerator('test_generate_without_digest'))
- suite.addTest(TestElpaEbuildGenerator('test_generate_with_digest'))
- return suite
diff --git a/tests/test_g_sorcery.py b/tests/test_g_sorcery.py
deleted file mode 100644
index 2004a9a..0000000
--- a/tests/test_g_sorcery.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
- test_g_sorcery.py
- ~~~~~~~~~~~~~~~~~
-
- executable and main module test suite
-
- :copyright: (c) 2013 by Jauhien Piatlicki
- :license: GPL-2, see LICENSE for more details.
-"""
-
-import os, subprocess, tempfile, unittest
-
-from g_sorcery import g_sorcery
-
-from tests.dummy_backend import backend as dummyBackend
-
-from tests.base import BaseTest
-
-class TestBin(BaseTest):
- def setUp(self):
- super(TestBin, self).setUp()
-
- binpath = os.path.join(os.path.dirname(
- os.path.dirname(os.path.realpath(__file__))), 'bin')
- self.binary = os.path.join(binpath, 'g-sorcery')
-
- def test_g_sorcery(self):
- self.assertEqual(subprocess.check_output(self.binary), b'No backend specified\n')
-
- def test_nonexistent_backend(self):
- prev = os.getcwd()
- os.chdir(self.tempdir.name)
- os.system('ln -s ' + self.binary + ' g-nonexistent')
- self.assertRaises(subprocess.CalledProcessError, subprocess.check_output, './g-nonexistent')
- os.chdir(prev)
-
- def test_empty_config(self):
- prev = os.getcwd()
- os.chdir(self.tempdir.name)
- os.system('ln -s ' + self.binary + ' g-empty')
- os.system('echo {} > ./g-empty.json')
- self.assertRaises(subprocess.CalledProcessError, subprocess.check_output, './g-empty')
- os.chdir(prev)
-
- def test_config(self):
- prev = os.getcwd()
- os.chdir(self.tempdir.name)
- os.system('ln -s ' + self.binary + ' g-dummy')
- os.system('echo {\\"package\\": \\"dummy_backend\\"} > ./g-dummy.json')
- self.assertEqual(subprocess.check_output(['./g-dummy', 'test']).decode("utf-8")[:-1],
- 'test')
- os.chdir(prev)
-
-class TestGSorcery(BaseTest):
-
- def test_get_backend(self):
- self.assertEqual(g_sorcery.get_backend('nonexistent_backend'), None)
- self.assertEqual(g_sorcery.get_backend('dummy_backend').dispatcher, dummyBackend.dispatcher)
-
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(TestBin('test_g_sorcery'))
- suite.addTest(TestBin('test_nonexistent_backend'))
- suite.addTest(TestBin('test_empty_config'))
- suite.addTest(TestBin('test_config'))
- suite.addTest(TestGSorcery('test_get_backend'))
- return suite
next reply other threads:[~2013-07-14 23:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-14 23:39 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: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-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=1373845198.81fa1eb9662c77bb0cdae8efa1d62874e03ae62f.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