Andi Vajda wrote:

For a long time there has been a method defined on Item called check() that will perform a number of repository consistency checks and report failures in the log.

That functionality is even available from the Chandler UI's Test menu with the 'Check Repository' menu item. It will recursively walk the UI repository view, loading *all* items and calling check() on them.

This method has been invaluable to me for ensuring that a real Chandler repository is still consistent after some use. No amount of unit test writing can replace such a real life test.

I just added another method, called Item.checkItem(), that is meant to be overriden by developers to write additional checks to verify that the semantics of a given item are still valid within their domain of use. When Item.check() succeeds, it calls checkItem() before returning.

This is great! So should we be returning False on an error, or throwing an exception? i.e. should we populate Item.checkItem() with asserts, or just a bunch of if statements?

Alec

For a hypothetical example, I'd expect a calendar event item to have an 'endDate' that is after its 'startDate'. It'd be pretty simple to override checkItem() on that class and verify this constraint.

When overriding Item.checkItem(), please don't forget to call super() and combine its return value with yours, ie, if super() returned False, return False even if all your checks succeeded. When you find a failure, log it, but try to continue running all checks in the method unless they depend on each other, then return False. If all checks passed, return True.

Unless there is a bug triggered by the checkItem() code itself, checkItem() returns False in case of error and True otherwise. This should make it convenient to use in unit tests as well...

Andi..
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev

Reply via email to