Generally speaking, testing agent methods that interact with the system heavily with unit tests provide very little, and arguably negative value to the project. Mocking internal methods and asserting that they were called is a clear anti-pattern to my mind. In Neutron-land we prefer to test agent code with functional tests. Since 'functional tests' is a very over-loaded term, what I mean by that is specifically running the actual unmocked code on the system and asserting the expected behavior.
Check out: neutron/tests/functional/agent/test_ovs_lib neutron/tests/functional/agent/test_l2_ovs_agent On Mon, Sep 28, 2015 at 3:45 PM, Sławek Kapłoński <[email protected]> wrote: > Hello, > > I'm new developer who want to start contributing to neutron. I have some > small experience with neutron already but I didn't do anything which I > could push to upstream for now. So I searched for some bug on launchpad > and I found such bug which I took: > https://bugs.launchpad.net/neutron/+bug/1285893 and I started to > checking how I can write new tests (I think that it is quite easy job to > do for the beginning but maybe I'm wrong). > Now I have some questions to You: > 1. From test-coverage I can see that for example there is missing > coverage like in lines 349-350 in method _restore_local_vlan_map(self) - > should > I create new test and call that metod to check if proper exception will > be raised? or maybe it is not neccessary at all and such "one lines" > missing coverage is not really needed to be checked? Or maybe it should > be done in some different way? > > 2. What about tests for methods like: "_local_vlan_for_flat" which is > not checked at all? should be created new test for such method? or maybe > it should be covered by some different test? > > Thanks in advance for any advice and tips how to write such unit tests > properly :) > > -- > Best regards / Pozdrawiam > Sławek Kapłoński > [email protected] > > > __________________________________________________________________________ > OpenStack Development Mailing List (not for usage questions) > Unsubscribe: [email protected]?subject:unsubscribe > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev > >
__________________________________________________________________________ OpenStack Development Mailing List (not for usage questions) Unsubscribe: [email protected]?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
