예제 #1
0
    def test_list(self, mock_resource_manager__manager):
        network = [mock.Mock(label="a"), mock.Mock(label="rally_novanet_a"),
                   mock.Mock(label="rally_novanet_b")]

        mock_resource_manager__manager.return_value.list.return_value = network
        self.assertEqual(network[1:], resources.NovaNetworks().list())
        mock_resource_manager__manager().list.assert_called_once_with()
예제 #2
0
    def test_list(self, mock_name_matches_object,
                  mock_resource_manager__manager):
        network = [
            mock.Mock(label="a"),
            mock.Mock(label="rally_novanet_a"),
            mock.Mock(label="rally_novanet_b")
        ]

        mock_name_matches_object.side_effect = (
            lambda n, o: n.startswith("rally"))

        mock_resource_manager__manager.return_value.list.return_value = network
        self.assertEqual(network[1:], resources.NovaNetworks().list())
        mock_resource_manager__manager().list.assert_called_once_with()
예제 #3
0
    def test_list(self, mock_itersubclasses):
        nova_nets = resources.NovaNetworks()

        networks = [mock.Mock(label="rally_abcdefgh_12345678"),
                    mock.Mock(label="rally_12345678_abcdefgh"),
                    mock.Mock(label="foobar")]
        nova_nets._manager = mock.Mock()
        nova_nets._manager.return_value.list.return_value = networks

        mock_itersubclasses.return_value = iter(
            [utils.RandomNameGeneratorMixin])

        self.assertEqual(networks[:2], nova_nets.list())
        nova_nets._manager.return_value.list.assert_called_once_with()
        mock_itersubclasses.assert_called_once_with(
            utils.RandomNameGeneratorMixin)