Пример #1
0
class TestProbeManager(unittest2.TestCase):
    def setUp(self):
        self.probes = ProbeManager(mock.Mock())
        self.probe = mock.Mock(id='fakeid')
        self.lb = mock.Mock(id='lbfakeid')

    @mock.patch('balancerclient.common.base.Manager._get', autospec=True)
    def test_get(self, mock_get):
        mock_get.return_value = mock_probe = mock.Mock()
        probe = self.probes.get(self.lb, self.probe)
        expected = mock.call(self.probes,
                             '/loadbalancers/lbfakeid/healthMonitoring/fakeid',
                             'healthMonitoring')
        self.assertTrue(mock_get.called)
        self.assertEqual(mock_get.mock_calls, [expected])
        self.assertEqual(probe, mock_probe)

    @mock.patch('balancerclient.common.base.Manager._create', autospec=True)
    def test_create(self, mock_create):
        self.probes.create(self.lb, 'probe1', 'ICMP')
        body = {'healthMonitoring': {'name': 'probe1',
                                     'type': 'ICMP'}}
        expected = mock.call(self.probes,
                             '/loadbalancers/lbfakeid/healthMonitoring', body,
                             'healthMonitoring')
        self.assertTrue(mock_create.called)
        self.assertEqual(mock_create.mock_calls, [expected])

    @mock.patch('balancerclient.common.base.Manager._delete', autospec=True)
    def test_delete(self, mock_delete):
        self.probes.delete(self.lb, self.probe)
        expected = mock.call(self.probes,
                             '/loadbalancers/lbfakeid/healthMonitoring/fakeid')
        self.assertTrue(mock_delete.called)
        self.assertEqual(mock_delete.mock_calls, [expected])

    @mock.patch('balancerclient.common.base.Manager._list', autospec=True)
    def test_probes_list(self, mock_list):
        self.probes.list(self.lb)
        expected = mock.call(self.probes,
                             '/loadbalancers/lbfakeid/healthMonitoring',
                             'healthMonitoring')
        self.assertTrue(mock_list.called)
        self.assertEqual(mock_list.mock_calls, [expected])
Пример #2
0
class TestProbeManager(unittest2.TestCase):
    def setUp(self):
        self.probes = ProbeManager(mock.Mock())
        self.probe = mock.Mock(id='fakeid')
        self.lb = mock.Mock(id='lbfakeid')

    @mock.patch('balancerclient.common.base.Manager._get', autospec=True)
    def test_get(self, mock_get):
        mock_get.return_value = mock_probe = mock.Mock()
        probe = self.probes.get(self.lb, self.probe)
        expected = mock.call(
            self.probes, '/loadbalancers/lbfakeid/healthMonitoring/fakeid',
            'healthMonitoring')
        self.assertTrue(mock_get.called)
        self.assertEqual(mock_get.mock_calls, [expected])
        self.assertEqual(probe, mock_probe)

    @mock.patch('balancerclient.common.base.Manager._create', autospec=True)
    def test_create(self, mock_create):
        self.probes.create(self.lb, 'probe1', 'ICMP')
        body = {'healthMonitoring': {'name': 'probe1', 'type': 'ICMP'}}
        expected = mock.call(self.probes,
                             '/loadbalancers/lbfakeid/healthMonitoring', body,
                             'healthMonitoring')
        self.assertTrue(mock_create.called)
        self.assertEqual(mock_create.mock_calls, [expected])

    @mock.patch('balancerclient.common.base.Manager._delete', autospec=True)
    def test_delete(self, mock_delete):
        self.probes.delete(self.lb, self.probe)
        expected = mock.call(
            self.probes, '/loadbalancers/lbfakeid/healthMonitoring/fakeid')
        self.assertTrue(mock_delete.called)
        self.assertEqual(mock_delete.mock_calls, [expected])

    @mock.patch('balancerclient.common.base.Manager._list', autospec=True)
    def test_probes_list(self, mock_list):
        self.probes.list(self.lb)
        expected = mock.call(self.probes,
                             '/loadbalancers/lbfakeid/healthMonitoring',
                             'healthMonitoring')
        self.assertTrue(mock_list.called)
        self.assertEqual(mock_list.mock_calls, [expected])
Пример #3
0
 def setUp(self):
     self.probes = ProbeManager(mock.Mock())
     self.probe = mock.Mock(id='fakeid')
     self.lb = mock.Mock(id='lbfakeid')
Пример #4
0
 def setUp(self):
     self.probes = ProbeManager(mock.Mock())
     self.probe = mock.Mock(id='fakeid')
     self.lb = mock.Mock(id='lbfakeid')