[Openstack] [nova-testing] Efforts for Essex

Sandy Walsh sandy.walsh at RACKSPACE.COM
Wed Nov 23 21:30:52 UTC 2011


:) yeah, you're completely misunderstanding me.

So, you've made a much better StubOutWithMock() and slightly better stubs.Set() by (essentially) ignoring the method parameter checks and just focusing on the return type. 

Using your example:

def test_something(self):
    def fake_instance_get(context, instance_uuid):
        return {'name': 'this or that',
                'instance_type_id': 42}

    self.stubs.Set(nova.db, 'instance_get_by_uuid', fake_instance_get)

    exercise_the_routine_that_will_eventually_do_an_instance_get()
    verify_that_the_system_is_now_in_the_desired_state()

Could your library be expanded to allow:

def test_something(self):
    self.sorens_mox.Set(nova.db, 'instance_get_by_uuid', {'name': 'this or that',
                'instance_type_id': 42})
    self.sorens_mox.Set(nova.my_module, 'get_list_of_things', range(10))

    exercise_the_routine_that_will_eventually_do_an_instance_get_and_get_list()
    verify_that_the_system_is_now_in_the_desired_state()

See what I mean?

Side note: 
I don't view tests that permit 
exercise_the_routine_that_will_eventually_do_an_instance_get()
calls to be unit tests ... they're integration tests and the source of all this headache in the first place.

A unit test should be
exercise_the_routine_that_will_directly_call_instance_get()

Hopefully we're saying the same thing on this last point?

-S
________________________________________
From: Soren Hansen [soren at linux2go.dk]

Am I completely misunderstanding you?




More information about the Openstack mailing list