Exemplo n.º 1
0
    def test_destroy_routers(self):
        self.useFixture(mockpatch.PatchObject(javelin, "client_for_user", return_value=self.fake_client))

        # this function is used on 2 different occasions in the code
        def _fake_get_resource_by_name(*args):
            if args[1] == "routers":
                return {"id": self.fake_object["router_id"]}
            elif args[1] == "subnets":
                return {"id": self.fake_object["subnet_id"]}

        javelin._get_resource_by_name = _fake_get_resource_by_name

        javelin.destroy_routers([self.fake_object])

        mocked_function = self.fake_client.networks.delete_router
        mocked_function.assert_called_once_with(self.fake_object["router_id"])
Exemplo n.º 2
0
    def test_destroy_routers(self):
        self.useFixture(mockpatch.PatchObject(javelin, "client_for_user",
                                              return_value=self.fake_client))

        # this function is used on 2 different occasions in the code
        def _fake_get_resource_by_name(*args):
            if args[1] == "routers":
                return {"id": self.fake_object['router_id']}
            elif args[1] == "subnets":
                return {"id": self.fake_object['subnet_id']}
        javelin._get_resource_by_name = _fake_get_resource_by_name

        javelin.destroy_routers([self.fake_object])

        mocked_function = self.fake_client.networks.delete_router
        mocked_function.assert_called_once_with(
            self.fake_object['router_id'])