def test_delete_route_no_binding(self, LoadBalancer): lb = LoadBalancer.find.return_value lb.hosts = [mock.Mock(), mock.Mock()] manager = Manager(self.config) with self.assertRaises(storage.InstanceNotFoundError): manager.delete_route("inst", "/zahadum") LoadBalancer.find.assert_called_with("inst")
def test_delete_route_no_binding(self, LoadBalancer, nginx): lb = LoadBalancer.find.return_value lb.hosts = [mock.Mock(), mock.Mock()] manager = Manager(self.config) with self.assertRaises(storage.InstanceNotFoundError): manager.delete_route('inst', '/zahadum') LoadBalancer.find.assert_called_with('inst') self.assertEqual(len(nginx.NginxDAV.return_value.mock_calls), 0)
def test_delete_route_error_no_route(self, LoadBalancer): self.storage.store_binding("inst", "app.host.com") lb = LoadBalancer.find.return_value lb.hosts = [mock.Mock(), mock.Mock()] manager = Manager(self.config) with self.assertRaises(storage.InstanceNotFoundError): manager.delete_route("inst", "/somewhere") LoadBalancer.find.assert_called_with("inst")
def test_delete_route(self, LoadBalancer): self.storage.store_binding("inst", "app.host.com") self.storage.replace_binding_path("inst", "/arrakis", "dune.com") lb = LoadBalancer.find.return_value lb.hosts = [mock.Mock(), mock.Mock()] manager = Manager(self.config) manager.consul_manager = mock.Mock() manager.delete_route("inst", "/arrakis") LoadBalancer.find.assert_called_with("inst") binding_data = self.storage.find_binding("inst") self.assertDictEqual(binding_data, { "_id": "inst", "app_host": "app.host.com", "paths": [{"path": "/", "destination": "app.host.com"}] }) manager.consul_manager.remove_location.assert_called_with("inst", "/arrakis")
def test_delete_route(self, LoadBalancer, nginx): self.storage.store_binding('inst', 'app.host.com') self.storage.replace_binding_path('inst', '/arrakis', 'dune.com') lb = LoadBalancer.find.return_value lb.hosts = [mock.Mock(), mock.Mock()] manager = Manager(self.config) manager.delete_route('inst', '/arrakis') LoadBalancer.find.assert_called_with('inst') binding_data = self.storage.find_binding('inst') self.assertDictEqual(binding_data, { '_id': 'inst', 'app_host': 'app.host.com', 'paths': [{'path': '/', 'destination': 'app.host.com'}] }) nginx_manager = nginx.NginxDAV.return_value nginx_manager.delete_binding.assert_any_call(lb.hosts[0].dns_name, '/arrakis') nginx_manager.delete_binding.assert_any_call(lb.hosts[1].dns_name, '/arrakis')
def test_delete_route(self, LoadBalancer, nginx): self.storage.store_binding("inst", "app.host.com") self.storage.replace_binding_path("inst", "/arrakis", "dune.com") lb = LoadBalancer.find.return_value lb.hosts = [mock.Mock(), mock.Mock()] manager = Manager(self.config) manager.delete_route("inst", "/arrakis") LoadBalancer.find.assert_called_with("inst") binding_data = self.storage.find_binding("inst") self.assertDictEqual(binding_data, { "_id": "inst", "app_host": "app.host.com", "paths": [{"path": "/", "destination": "app.host.com"}] }) nginx_manager = nginx.NginxDAV.return_value nginx_manager.delete_binding.assert_any_call(lb.hosts[0].dns_name, "/arrakis") nginx_manager.delete_binding.assert_any_call(lb.hosts[1].dns_name, "/arrakis")
def test_delete_route(self, LoadBalancer): self.storage.store_binding("inst", "app.host.com") self.storage.replace_binding_path("inst", "/arrakis", "dune.com") lb = LoadBalancer.find.return_value lb.hosts = [mock.Mock(), mock.Mock()] manager = Manager(self.config) manager.consul_manager = mock.Mock() manager.delete_route("inst", "/arrakis") LoadBalancer.find.assert_called_with("inst") binding_data = self.storage.find_binding("inst") self.assertDictEqual( binding_data, { "_id": "inst", "app_host": "app.host.com", "paths": [{ "path": "/", "destination": "app.host.com" }] }) manager.consul_manager.remove_location.assert_called_with( "inst", "/arrakis")
def test_delete_route_error_task_running(self): self.storage.store_task("inst") manager = Manager(self.config) with self.assertRaises(rpaas.tasks.NotReadyError): manager.delete_route("inst", "/arrakis")
def test_delete_route_error_task_running(self): self.storage.store_task('inst') manager = Manager(self.config) with self.assertRaises(rpaas.manager.NotReadyError): manager.delete_route('inst', '/arrakis')