diff options
author | Klaus Kämpf <kkaempf@suse.de> | 2010-11-09 13:30:16 +0100 |
---|---|---|
committer | Klaus Kämpf <kkaempf@suse.de> | 2010-11-09 13:30:16 +0100 |
commit | 3c8c2932ffa944fbeec933d2f6b7cd077deec920 (patch) | |
tree | 168a5a6ca8a02149c1c7d9ad92e574027ed6ceb1 | |
parent | 00768743f7ab9dc9b2647b8a528e5b0af051c11a (diff) | |
download | libzypp-bindings-3c8c2932ffa944fbeec933d2f6b7cd077deec920.tar.gz libzypp-bindings-3c8c2932ffa944fbeec933d2f6b7cd077deec920.tar.bz2 libzypp-bindings-3c8c2932ffa944fbeec933d2f6b7cd077deec920.zip |
Complete CommitCallbacks with testcase
This complete the initial implementation of the callbacks concept.
Currently only the 'RemoveResolvable' callback is instrumented for
Python. More to come ...
-rw-r--r-- | swig/CommitCallbacks.h | 24 | ||||
-rw-r--r-- | swig/python/tests/commit_callbacks.py | 15 |
2 files changed, 35 insertions, 4 deletions
diff --git a/swig/CommitCallbacks.h b/swig/CommitCallbacks.h index a626122..881cd59 100644 --- a/swig/CommitCallbacks.h +++ b/swig/CommitCallbacks.h @@ -3,8 +3,8 @@ class CommitCallbacks { private: PatchMessageReportReceiver _messageReceiver; PatchScriptReportReceiver _scriptReceiver; - RemoveResolvableReportReceiver _installReceiver; - InstallResolvableReportReceiver _removeReceiver; + RemoveResolvableReportReceiver _removeReceiver; + InstallResolvableReportReceiver _installReceiver; Target_Type _instance; public: @@ -66,3 +66,23 @@ class CommitCallbacks { return _instance; } }; + + +/* + * A (dummy) commit callback emitter used for testing only + * + */ + +class CommitCallbacksEmitter { + private: + callback::SendReport<target::rpm::RemoveResolvableReport> remove_resolvable; + callback::SendReport<target::PatchMessageReport> patch_message; + callback::SendReport<target::PatchScriptReport> patch_script; + callback::SendReport<target::rpm::InstallResolvableReport> install_resolvable; + public: + void remove_start(zypp::ResObject::constPtr resobj) + { + remove_resolvable->start( resobj ); + } +}; + diff --git a/swig/python/tests/commit_callbacks.py b/swig/python/tests/commit_callbacks.py index c969927..ff002ae 100644 --- a/swig/python/tests/commit_callbacks.py +++ b/swig/python/tests/commit_callbacks.py @@ -10,7 +10,7 @@ cwd = os.path.abspath(os.path.dirname(__file__)) import sys sys.path.insert(0, cwd + "/../../../build/swig/python") -from zypp import CommitCallbacks +import zypp class CommitReceiver: def removal_start(self, resolvable): @@ -18,7 +18,12 @@ class CommitReceiver: class CommitCallbacksTestCase(unittest.TestCase): def testRemoveCallback(self): - commit_callbacks = CommitCallbacks() + Z = zypp.ZYppFactory_instance().getZYpp() + Z.initializeTarget( zypp.Pathname("/") ) + Z.target().load(); + + commit_callbacks_emitter = zypp.CommitCallbacksEmitter() + commit_callbacks = zypp.CommitCallbacks() # print "commit_callbacks " , commit_callbacks assert None == commit_callbacks.receiver() # print "callbacks receiver is NULL - good" @@ -28,6 +33,12 @@ class CommitCallbacksTestCase(unittest.TestCase): # print "connected to ", commit_receiver assert commit_receiver == commit_callbacks.receiver() # print "callbacks receiver is set - good" + + for item in Z.pool(): + print "Emitting removal of ", item.resolvable() + commit_callbacks_emitter.remove_start(item.resolvable()) + break + commit_callbacks.disconnect() # print "disconnected" assert None == commit_callbacks.receiver() |