views:

141

answers:

2

How does one test a method that does some interactions with the local D-Bus (accessing a HAL object)?

Results of tests will differ depending on the system that the test is run on, so I don't know how to provide the method reliable input.

I'm working in Python, by the way.

+2  A: 

If you can not mock the environment then it's probably impossible for you to write the test. If your access to HAL/D-Bus is via an object and you provide a mock instance to your test then it should be possible to emulate the necessary inputs to your test from the mock implementation.

lothar
+1 -> I was about to post the same thing; emulate the interface so that you can load the test inputs/responses that you expect and make sure your software responds as it should.
Jon Cage
A: 

It's also possible to create a temporary D-Bus buses for tests, and emulate any services your program uses in your test code. You can use this approach for programs which are D-Bus services, D-Bus clients, or both. The downside is that the bus setup is a bit hairy. There's code for doing this in e.g. Telepathy Gabble.

daf