Пример #1
0
    def test_list(self):
        fips = {"floatingips": [{"tenant_id": "foo", "id": "foo"}]}

        user = mock.MagicMock()
        user.neutron.return_value.list_floatingips.return_value = fips

        self.assertEqual(fips["floatingips"], list(
            resources.NeutronFloatingIP(user=user, tenant_uuid="foo").list()))
        user.neutron.return_value.list_floatingips.assert_called_once_with(
            tenant_id="foo")
Пример #2
0
    def test_list(self):
        fips = {"floatingips": [{"tenant_id": "foo", "id": "foo"}]}

        user = mock.MagicMock()
        user.services.return_value = {}
        user.neutron.return_value.list_floatingips.return_value = fips

        self.assertEqual([],
                         resources.NeutronFloatingIP(user=user,
                                                     tenant_uuid="foo").list())
        self.assertFalse(user.neutron.return_value.list_floatingips.called)

        user.services.return_value = {
            consts.ServiceType.NETWORK: consts.Service.NEUTRON
        }
        self.assertEqual(
            fips["floatingips"],
            list(
                resources.NeutronFloatingIP(user=user,
                                            tenant_uuid="foo").list()))
        user.neutron.return_value.list_floatingips.assert_called_once_with(
            tenant_id="foo")
Пример #3
0
 def test_name(self):
     fips = resources.NeutronFloatingIP({"name": "foo"})
     self.assertIsInstance(fips.name(), resources.base.NoName)
Пример #4
0
 def test_name(self):
     fips = resources.NeutronFloatingIP({
         "name": "foo",
         "description": "OoO"
     })
     self.assertEqual(fips.name(), "OoO")