class TestStickyManager(unittest2.TestCase): def setUp(self): self.stickies = StickyManager(mock.Mock()) self.sticky = 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_sticky = mock.Mock() sticky = self.stickies.get(self.lb, self.sticky) expected = mock.call(self.stickies, '/loadbalancers/lbfakeid/sessionPersistence/fakeid', 'sessionPersistence') self.assertTrue(mock_get.called) self.assertEqual(mock_get.mock_calls, [expected]) self.assertEqual(sticky, mock_sticky) @mock.patch('balancerclient.common.base.Manager._create', autospec=True) def test_create(self, mock_create): self.stickies.create(self.lb, 'sticky1', 'HTTP') body = {'name': 'sticky1', 'type': 'HTTP'} expected = mock.call(self.stickies, '/loadbalancers/lbfakeid/sessionPersistence', body, 'sessionPersistence') 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.stickies.delete(self.lb, self.sticky) expected = mock.call(self.stickies, '/loadbalancers/lbfakeid/sessionPersistence/fakeid') self.assertTrue(mock_delete.called) self.assertEqual(mock_delete.mock_calls, [expected]) @mock.patch('balancerclient.common.base.Manager._list', autospec=True) def test_sticky_list(self, mock_list): self.stickies.list(self.lb) expected = mock.call(self.stickies, '/loadbalancers/lbfakeid/sessionPersistence', 'sessionPersistence') self.assertTrue(mock_list.called) self.assertEqual(mock_list.mock_calls, [expected])
class TestStickyManager(unittest2.TestCase): def setUp(self): self.stickies = StickyManager(mock.Mock()) self.sticky = 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_sticky = mock.Mock() sticky = self.stickies.get(self.lb, self.sticky) expected = mock.call( self.stickies, '/loadbalancers/lbfakeid/sessionPersistence/fakeid', 'sessionPersistence') self.assertTrue(mock_get.called) self.assertEqual(mock_get.mock_calls, [expected]) self.assertEqual(sticky, mock_sticky) @mock.patch('balancerclient.common.base.Manager._create', autospec=True) def test_create(self, mock_create): self.stickies.create(self.lb, 'sticky1', 'HTTP') body = {'name': 'sticky1', 'type': 'HTTP'} expected = mock.call(self.stickies, '/loadbalancers/lbfakeid/sessionPersistence', body, 'sessionPersistence') 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.stickies.delete(self.lb, self.sticky) expected = mock.call( self.stickies, '/loadbalancers/lbfakeid/sessionPersistence/fakeid') self.assertTrue(mock_delete.called) self.assertEqual(mock_delete.mock_calls, [expected]) @mock.patch('balancerclient.common.base.Manager._list', autospec=True) def test_sticky_list(self, mock_list): self.stickies.list(self.lb) expected = mock.call(self.stickies, '/loadbalancers/lbfakeid/sessionPersistence', 'sessionPersistence') self.assertTrue(mock_list.called) self.assertEqual(mock_list.mock_calls, [expected])
def setUp(self): self.stickies = StickyManager(mock.Mock()) self.sticky = mock.Mock(id='fakeid') self.lb = mock.Mock(id='lbfakeid')