Merge lp:~robru/python-dbusmock/querycalls into lp:~pitti/python-dbusmock/old-bzr-trunk
Proposed by
Robert Bruce Park
Status: | Merged |
---|---|
Merged at revision: | 100 |
Proposed branch: | lp:~robru/python-dbusmock/querycalls |
Merge into: | lp:~pitti/python-dbusmock/old-bzr-trunk |
Diff against target: |
105 lines (+70/-0) 2 files modified
dbusmock/mockobject.py (+23/-0) tests/test_api.py (+47/-0) |
To merge this branch: | bzr merge lp:~robru/python-dbusmock/querycalls |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Pitt | Approve | ||
Robert Bruce Park (community) | Approve | ||
Review via email: mp+143153@code.launchpad.net |
Description of the change
This change makes it possible to query for the called method signatures over dbus, and also makes it possible to clear this log, such that each individual test can start with a fresh state (so no worries about one test checking the log and finding method invocations logged from the previous test).
Let me know how you feel about the implementation, I would be happy to alter it to fit your standards.
To post a comment you must log in.
I think this is a great idea, thanks for working on this!
If a program uses the D-BUS queries for the logs, and it wants to suppress stdout, you can already use "-l /dev/null", so I don't think we need another command line argument for this. Do you agree?
My main nitpick with this is QueryCalls() returning a single string, which the caller then has to pick apart again. In some cases you just want to know "has this function being called", but in other cases you actually want to verify the arguments of a particular call. So how about:
- ClearLog() sounds good to me.
- GetLog() ("Query.." is unusual in D-BUS interfaces) has a return signature a(tsav), returning a list of (timestamp, method, args) tuples.
- GetMethodCalls( method) has a return signature a(tav), returning a list of (timestamp, args) tuples; by merely checking the returned list length against 0, a caller can conveniently check whether a method was called.
> self.assertTrue (self.dbus_ mock.QueryCalls ().index( ' Wop "foo"'))
Please don't use this test form, it looks confusing as index() can return 0 if the string is right at the start, and 0 counts as False. Please use
self. assertTrue( 'search' in QueryCalls() ...)
(Won't be relevant after above API changes, of course).
+ def test_new_ logging( self):
Please name this "test_dbus_ logging" .
Thanks!