[unittest] add entropy.core unittest module

This commit is contained in:
Fabio Erculiani
2009-11-12 18:40:46 +01:00
parent 187a087e66
commit 3b074c2daa
2 changed files with 59 additions and 2 deletions

56
libraries/tests/core.py Normal file
View File

@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
import sys
sys.path.insert(0, 'client')
sys.path.insert(0, '../../client')
sys.path.insert(0, '.')
sys.path.insert(0, '../')
import unittest
from entropy.core import EntropyPluginStore, Singleton
import tests._misc as _misc
class CoreTest(unittest.TestCase):
def setUp(self):
sys.stdout.write("%s called\n" % (self,))
sys.stdout.flush()
def tearDown(self):
"""
tearDown is run after each test
"""
sys.stdout.write("%s ran\n" % (self,))
sys.stdout.flush()
def test_plugin_store(self):
store = EntropyPluginStore()
plug_object = object()
plug_id = "plug"
store.add_plugin(plug_id, plug_object)
self.assertEqual(store.get_plugins(), {plug_id: plug_object})
store.remove_plugin(plug_id)
self.assertEqual(store.get_plugins(), {})
store.add_plugin(plug_id, plug_object)
self.assertEqual(store.get_plugins(), {plug_id: plug_object})
store.drop_plugins()
self.assertEqual(store.get_plugins(), {})
def test_core_singleton(self):
class myself(Singleton):
def init_singleton(self):
pass
obj = myself()
obj2 = myself()
self.assert_(obj is obj2)
if __name__ == '__main__':
if "--debug" in sys.argv:
sys.argv.remove("--debug")
from entropy.const import etpUi
etpUi['debug'] = True
unittest.main()

View File

@@ -18,11 +18,12 @@ if "--debug" in sys.argv:
sys.argv.remove("--debug")
etpUi['debug'] = True
from tests import db, client, server, misc, transceivers, tools, i18n, spm, qa
from tests import db, client, server, misc, transceivers, tools, i18n, spm, \
qa, core
rc = 0
# Add to the list the module to test
mods = [db, client, server, misc, transceivers, tools, i18n, spm, qa]
mods = [db, client, server, misc, transceivers, tools, i18n, spm, qa, core]
tests = []
for mod in mods: