Пример #1
0
    def test_eligible_for_deletion_filtered_by_agent_type(self):
        ns_dhcp = "qdhcp-" + "6e322ac7-ab50-4f53-9cdc-d1d3c1164b6d"
        ns_l3 = "qrouter-" + "6e322ac7-ab50-4f53-9cdc-d1d3c1164b6d"
        conf = mock.Mock()
        conf.agent_type = "dhcp"

        with mock.patch("neutron.agent.linux.ip_lib.IPWrapper") as ip_wrap:
            ip_wrap.return_value.namespace_is_empty.return_value = True
            self.assertEqual(True, util.eligible_for_deletion(conf, ns_dhcp, False))
            self.assertEqual(False, util.eligible_for_deletion(conf, ns_l3, False))

            expected_calls = [mock.call(namespace=ns_dhcp), mock.call().namespace_is_empty()]
            ip_wrap.assert_has_calls(expected_calls)
Пример #2
0
    def test_eligible_for_deletion_filtered_by_agent_type(self):
        ns_dhcp = 'qdhcp-' + '6e322ac7-ab50-4f53-9cdc-d1d3c1164b6d'
        ns_l3 = 'qrouter-' + '6e322ac7-ab50-4f53-9cdc-d1d3c1164b6d'
        conf = mock.Mock()
        conf.agent_type = 'dhcp'

        with mock.patch('neutron.agent.linux.ip_lib.IPWrapper') as ip_wrap:
            ip_wrap.return_value.namespace_is_empty.return_value = True
            self.assertTrue(util.eligible_for_deletion(conf, ns_dhcp, False))
            self.assertFalse(util.eligible_for_deletion(conf, ns_l3, False))

            expected_calls = [mock.call(namespace=ns_dhcp),
                              mock.call().namespace_is_empty()]
            ip_wrap.assert_has_calls(expected_calls)
Пример #3
0
    def _test_eligible_for_deletion_helper(self, prefix, force, is_empty, expected):
        ns = prefix + "6e322ac7-ab50-4f53-9cdc-d1d3c1164b6d"
        conf = mock.Mock()

        with mock.patch("neutron.agent.linux.ip_lib.IPWrapper") as ip_wrap:
            ip_wrap.return_value.namespace_is_empty.return_value = is_empty
            self.assertEqual(util.eligible_for_deletion(conf, ns, force), expected)

            expected_calls = [mock.call(namespace=ns)]
            if not force:
                expected_calls.append(mock.call().namespace_is_empty())
            ip_wrap.assert_has_calls(expected_calls)
    def _test_eligible_for_deletion_helper(self, prefix, force, is_empty,
                                           expected):
        ns = prefix + '6e322ac7-ab50-4f53-9cdc-d1d3c1164b6d'
        conf = mock.Mock()

        with mock.patch('neutron.agent.linux.ip_lib.IPWrapper') as ip_wrap:
            ip_wrap.return_value.namespace_is_empty.return_value = is_empty
            self.assertEqual(util.eligible_for_deletion(conf, ns, force),
                             expected)

            expected_calls = [mock.call(namespace=ns)]
            if not force:
                expected_calls.append(mock.call().namespace_is_empty())
            ip_wrap.assert_has_calls(expected_calls)
Пример #5
0
 def test_eligible_for_deletion_ns_not_uuid(self):
     conf = mock.Mock()
     conf.agent_type = None
     ns = 'not_a_uuid'
     self.assertFalse(util.eligible_for_deletion(conf, ns))
 def test_eligible_for_deletion_ns_not_uuid(self):
     ns = 'not_a_uuid'
     self.assertFalse(util.eligible_for_deletion(mock.Mock(), ns))
Пример #7
0
 def test_eligible_for_deletion_ns_not_uuid(self):
     conf = mock.Mock()
     conf.agent_type = None
     ns = 'not_a_uuid'
     self.assertFalse(util.eligible_for_deletion(conf, ns))