Mock in Horizon tests

asked 2016-02-19 02:16:13 -0500

sanjana gravatar image

In case of flavors, @test.create_stubs({api.keystone: ('tenant_list',), api.nova: ('flavor_list', 'flavor_create',)}) def test_create_flavor_without_projects_post(self): flavor = self.flavors.first() projects = self.tenants.list()

    # init
    api.keystone.tenant_list(IsA(http.HttpRequest)).AndReturn([projects,
                                                               False])
    api.nova.flavor_list(IsA(http.HttpRequest), None) \
        .AndReturn([])

    # handle
    params = self._flavor_create_params(flavor, id='auto')
    api.nova.flavor_create(IsA(http.HttpRequest), **params) \
        .AndReturn(flavor)

    self.mox.ReplayAll()

    workflow_data = self._get_workflow_data(flavor)

    url = reverse(constants.FLAVORS_CREATE_URL)
    res = self.client.post(url, workflow_data)

    self.assertNoFormErrors(res)
    self.assertRedirectsNoFollow(res, reverse(constants.FLAVORS_INDEX_URL))

What is the purpose of mocking the call for flavor_create? It doesnt seem to hit the api code. This test case works even when the flavor_create call is removed.

edit retag flag offensive close merge delete