[Pulp-list] Agent decoupling

Jay Dobies jason.dobies at redhat.com
Thu Feb 24 19:37:58 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

As part of the bind refactor, I'm adding test cases for the bind API
call. Currently, the agent call is tightly coupled into the API call:

def bind(self, id, repoid):
[snip]
        agent = Agent(id, async=True)
        repolib = agent.Repo()
        repolib.update()

That doesn't let us mock out the qpidd call, so if we had unit tests for
any non-async agent calls they would fail because the receiver wasn't
present.

It's best to just mock out something like a message bus connection in a
unit test (the tests for the Agent itself can be handled separately), so
I added a factory method to agent.py.

Going forward, instead of instantiating an Agent object directly in the
API, use the factory method (agent.retrieve_agent()). That way we can
monkey patch that method in the API unit test to return a mock so we can
track that the API methods are invoking the correct methods on an agent,
just not doing them over a live bus.

That factory method currently exists in the bind-refactor branch and
should be in master in the next few days.

- -- 
Jay Dobies
RHCE# 805008743336126
Freenode: jdob
http://pulpproject.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNZrOWAAoJEOMmcTqOSQHCx0YIAJFEw0ru9LdeWgWhc7j+n/wz
HBKNHHgt1Dcj8WTXjaZyqaGjPIsS/R5tg7ufXi72VkAvQvu7JKaO4OfFHMICGJff
fEi1Nv6oDh9BetwNuJKJbjWfRE2J8tK698I+bvCGZdxYiVCj4sjmtpIYQAMvIv4c
l07GXhRVheSZ7L3ElvYesdg4ESSLn+tecsU/3GqjiZDf4qDF97ERsKVEv8u+gaxY
1zfwoHV+IS1z7Eu5ddm7nCcNOd+h5ijFW1l1egyD3uuMZPnV0V14rYBXN+ge4UUu
sErmtQ/Tg+EhSNuuOsaV43Z3/RcjJOHxNGXfXelOzs9JzuwuT6Zr84l3mSF06yk=
=b+4y
-----END PGP SIGNATURE-----




More information about the Pulp-list mailing list