def test_check_prerequisite(self): with mock.patch('shade.meta.get_and_munchify', return_value=["LB1"]): self.assertEqual( False, octavia.LoadBalancers(self.creds_manager).check_prerequisite()) with mock.patch('shade.meta.get_and_munchify', return_value=[]): self.assertEqual( True, octavia.LoadBalancers(self.creds_manager).check_prerequisite())
def test_delete(self): sg = mock.MagicMock() with mock.patch('ospurge.resources.octavia.getOctaviaClient', return_value=self.client) as m: self.assertIsNone( octavia.LoadBalancers(self.creds_manager).delete(sg)) self.client.load_balancer_delete.assert_called_once_with(sg['id'])
def test_list_with_service(self): self.cloud.has_service.return_value = True my_project = str(uuid.uuid4()) self.creds_manager.project_id = my_project self.assertIs(self.cloud.load_balancer.load_balancers.return_value, octavia.LoadBalancers(self.creds_manager).list()) self.cloud.load_balancer.load_balancers.assert_called_once_with( project_id=my_project)
def test_list(self): with mock.patch('shade.meta.get_and_munchify', return_value=[{ 'name': 'LB1' }, { 'name': 'LB2' }]): self.assertIs(shade.meta.get_and_munchify.return_value, octavia.LoadBalancers(self.creds_manager).list())
def test_to_string(self): sg = mock.MagicMock() self.assertIn("Load Balancer (", octavia.LoadBalancers(self.creds_manager).to_str(sg))
def test_to_string(self): stack = mock.MagicMock() self.assertIn("Octavia LoadBalancer", octavia.LoadBalancers(self.creds_manager).to_str(stack))
def test_disable(self): lb = mock.MagicMock() self.assertIsNone( octavia.LoadBalancers(self.creds_manager).disable(lb)) (self.cloud.load_balancer.update_load_balancer.assert_called_once_with( lb['id'], admin_state_up=False))
def test_delete(self): lb = mock.MagicMock() self.assertIsNone(octavia.LoadBalancers(self.creds_manager).delete(lb)) (self.cloud.load_balancer.delete_load_balancer.assert_called_once_with( lb['id'], cascade=True))
def test_list_without_service(self): self.cloud.has_service.return_value = False self.assertEqual(octavia.LoadBalancers(self.creds_manager).list(), []) self.cloud.load_balancer.load_balancers.assert_not_called()