def test_setup(self, mock_network_wrap, mock_clients): networks = [mock.Mock(), mock.Mock(), mock.Mock()] net_wrappers = { "tenant1": mock.Mock( **{"list_networks.return_value": networks[0:2]}), "tenant2": mock.Mock( **{"list_networks.return_value": networks[2:]}) } mock_network_wrap.side_effect = [net_wrappers["tenant1"], net_wrappers["tenant2"]] context = existing_network.ExistingNetwork(self.context) context.setup() mock_clients.assert_has_calls([ mock.call(u["credential"]) for u in self.context["users"]]) mock_network_wrap.assert_has_calls([ mock.call(mock_clients.return_value, context, config=self.config), mock.call(mock_clients.return_value, context, config=self.config)]) for net_wrapper in net_wrappers.values(): net_wrapper.list_networks.assert_called_once_with() self.assertEqual( self.context["tenants"], { "tenant1": {"networks": networks[0:2]}, "tenant2": {"networks": networks[2:]}, } )
def test_cleanup(self): # NOTE(stpierre): Test that cleanup is not abstract existing_network.ExistingNetwork({"task": mock.MagicMock()}).cleanup()