On 02/28/2011 09:01 AM, Kamil Paral wrote:
* The documentation is great, thank you. I find it nicely structured. But I'm missing
comparison with standard python unittest framework (I never used it) [1]. Can you add a
few lines about that?
I'm planning to do another proof of concept with
unittest/nose this
week. I'll make sure to go into more depth on the py.test/unitttest
comparison then.
* README.test is probably missing "python-py" package among
dependencies.
Those dependencies are handled in the virtualenv. The version of pylib
thats currently in the Fedora repos is too old for the way that those
tests are written.
But after installing that package, I still receive an error:
http://fpaste.org/zw5A/
pytest is located at:
/usr/lib/python2.7/site-packages/py/_cmdline/pytest.py
Where's the catch?
Whoops, my bad. I forgot that I have pip symlinked with a
non-standard
name. It's pip-python by default. I pushed up a fixed shell script and
it should run now.
* By removing inheritance of SimpleKojiClientSession from
koji.ClientSession, you'll disable calling many methods on that object. Is that a
desired behavior? Why's that necessary?
I don't see any broken functionality
in what we're currently using, was
there anything in particular you were worried about? Is there something
that I'm missing?
My rationale for removing the inheritance was twofold:
1) Getting rid of the tightly coupled code
Tightly coupled code is, by nature, difficult to isolate since you are
less able to mock/stub any of the inherited methods. If all of the code
was under our control, we could refactor the parent class to help with
the isolation but I sincerely doubt that a patch of that nature would be
accepted in koji.
By using dependency injection and writing wrapper methods where needed,
we can have more easily isolated code which lends to less complication
and dirty hacks in the unit tests in addition to protecting ourselves
from potential changes upstream (I'm not predicting changes, just
speaking generally).
2) Efficiency and Sanity
While it would normally be possible to isolate the child class from the
parent class through the use of mocks and monkeypatching,
KojiClientSession is a bit special here. It uses some introspection
magic to transform methods on the proxy class into results from the
remote server.
Unfortunately, this is in direct conflict with the way that
monkeypatching and mocking work in python and greatly increases the
complexity, fragility and size of the supporting code used for unit tests.
It would be possible to restore the inheritance but that would require a
decent amount of work and would result in more complex and fragile
testing code. I'm of the opinion that this is an improvement over what
is currently in master. It is more isolated from code we have no control
over and is more easily testable.
Tim