* [gentoo-commits] proj/g-sorcery:master commit in: scripts/, tests/
@ 2013-06-20 22:53 Jauhien Piatlicki
0 siblings, 0 replies; 2+ messages in thread
From: Jauhien Piatlicki @ 2013-06-20 22:53 UTC (permalink / raw
To: gentoo-commits
commit: d538523c6ce720b9dd120e3cb9385878afa5dcb7
Author: Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Wed Jun 19 20:53:20 2013 +0000
Commit: Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Wed Jun 19 20:53:20 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=d538523c
dummy test
---
scripts/run_tests.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/test_dummy.py | 27 ++++++++++++++++++++++++++
2 files changed, 81 insertions(+)
diff --git a/scripts/run_tests.py b/scripts/run_tests.py
new file mode 100755
index 0000000..17395ea
--- /dev/null
+++ b/scripts/run_tests.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ run_tests.py
+ ~~~~~~~~~~~~
+
+ a simple script that runs all the tests from the *tests* directory
+ (.py files)
+
+ :copyright: (c) 2010 by Rafael Goncalves Martins
+ :copyright: (c) 2013 by Jauhien Piatlicki
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import os
+import sys
+import unittest
+
+root_dir = os.path.realpath(os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), '..'
+))
+
+tests_dir = os.path.join(root_dir, 'tests')
+
+# adding the tests directory to the top of the PYTHONPATH
+sys.path = [root_dir, tests_dir] + sys.path
+
+suites = []
+
+# getting the test suites from the python modules (files that ends whit .py)
+for f in os.listdir(tests_dir):
+ if not f.endswith('.py') or not f.startswith('test_'):
+ continue
+ try:
+ my_test = __import__(f[:-len('.py')])
+ except ImportError:
+ continue
+
+ # all the python modules MUST have a 'suite' method, that returns the
+ # test suite of the module
+ suites.append(my_test.suite())
+
+# unifying all the test suites in only one
+suites = unittest.TestSuite(suites)
+
+# creating the Test Runner object
+test_runner = unittest.TextTestRunner(descriptions=2, verbosity=2)
+
+# running the tests
+result = test_runner.run(suites)
+
+if result.failures or result.errors:
+ sys.exit(1)
diff --git a/tests/test_dummy.py b/tests/test_dummy.py
new file mode 100644
index 0000000..dfa9700
--- /dev/null
+++ b/tests/test_dummy.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ test_dummy.py
+ ~~~~~~~~~~~~~
+
+ dummy test suite
+
+ :copyright: (c) 2013 by Jauhien Piatlicki
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import unittest
+
+class TestDummy(unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def test_dummy(self):
+ self.assertEqual('works', 'works')
+
+def suite():
+ suite = unittest.TestSuite()
+ suite.addTest(TestDummy('test_dummy'))
+ return suite
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/g-sorcery:master commit in: scripts/, tests/
@ 2013-09-16 0:19 Jauhien Piatlicki
0 siblings, 0 replies; 2+ messages in thread
From: Jauhien Piatlicki @ 2013-09-16 0:19 UTC (permalink / raw
To: gentoo-commits
commit: 4210ddc888ca6146467897a7023a3648457b13ab
Author: Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Mon Sep 16 00:19:17 2013 +0000
Commit: Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Mon Sep 16 00:19:17 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=4210ddc8
tests/test_PackageDB: initial commit
---
scripts/all_pythons.sh | 2 +-
tests/test_PackageDB.py | 62 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/scripts/all_pythons.sh b/scripts/all_pythons.sh
index a31dbea..9160dd0 100755
--- a/scripts/all_pythons.sh
+++ b/scripts/all_pythons.sh
@@ -2,7 +2,7 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-for VER in 2.7 3.2 3.3 #2.6 to be added later
+for VER in 2.7 3.2 3.3
do
echo
echo "testing python${VER}"
diff --git a/tests/test_PackageDB.py b/tests/test_PackageDB.py
new file mode 100644
index 0000000..87cf3ea
--- /dev/null
+++ b/tests/test_PackageDB.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ test_PackageDB.py
+ ~~~~~~~~~~~~~~~~
+
+ PackageDB test suite
+
+ :copyright: (c) 2013 by Jauhien Piatlicki
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import os
+import time
+import unittest
+
+from g_sorcery.compatibility import TemporaryDirectory
+from g_sorcery.exceptions import SyncError
+from g_sorcery.g_collections import Package
+from g_sorcery.package_db import PackageDB
+
+from tests.base import BaseTest
+from tests.server import Server
+
+
+class TestDB(PackageDB):
+ def get_real_db_uri(self, db_uri):
+ return db_uri + "/dummy.tar.gz"
+
+
+class TestPackageDB(BaseTest):
+
+ def test_functionality(self):
+ orig_tempdir = TemporaryDirectory()
+ orig_path = os.path.join(orig_tempdir.name, "db")
+ os.makedirs(orig_path)
+ orig_db = PackageDB(orig_path)
+ orig_db.add_category("app-test1")
+ orig_db.add_category("app-test2")
+ ebuild_data = {"test1": "test1", "test2": "test2"}
+ orig_db.add_package(Package("app-test1", "test", "1"), ebuild_data)
+ orig_db.add_package(Package("app-test1", "test", "2"))
+ orig_db.add_package(Package("app-test1", "test1", "1"), ebuild_data)
+ orig_db.add_package(Package("app-test2", "test2", "1"), ebuild_data)
+ orig_db.write_and_manifest()
+ os.system("cd " + orig_tempdir.name + " && tar cvzf dummy.tar.gz db")
+
+ test_db = TestDB(self.tempdir.name)
+ self.assertRaises(SyncError, test_db.sync, "127.0.0.1:8080")
+
+ srv = Server(orig_tempdir.name)
+ srv.start()
+ test_db.sync("127.0.0.1:8080")
+ srv.shutdown()
+ srv.join()
+
+
+def suite():
+ suite = unittest.TestSuite()
+ suite.addTest(TestPackageDB('test_functionality'))
+ return suite
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-16 0:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-20 22:53 [gentoo-commits] proj/g-sorcery:master commit in: scripts/, tests/ Jauhien Piatlicki
-- strict thread matches above, loose matches on Subject: below --
2013-09-16 0:19 Jauhien Piatlicki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox