Loading src/webui/requirements.in +1 −1 Original line number Diff line number Diff line Flask==2.0.2 Flask==2.1.3 Flask-WTF==1.0.0 flask-healthz==0.0.3 flask-unittest==0.1.2 Loading src/webui/service/device/routes.py +2 −2 Original line number Diff line number Diff line Loading @@ -125,8 +125,8 @@ def delete(device_uuid): response = device_client.DeleteDevice(request) device_client.close() flash('Device "{:s}" deleted successfully!'.format(device_uuid), 'success') flash(f'Device "{device_uuid}" deleted successfully!', 'success') except Exception as e: flash('Problem deleting device "{:s}": {:s}'.format(device_uuid, str(e.details())), 'danger') flash(f'Problem deleting device "{device_uuid}": {e.details()}', 'danger') current_app.logger.exception(e) return redirect(url_for('device.home')) src/webui/service/main/routes.py +2 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ import json, logging from flask import jsonify, redirect, render_template, Blueprint, flash, session, url_for, request from common.proto.context_pb2 import Context, Device, Empty, Link, Topology from common.proto.context_pb2 import Context, Device, Empty, Link, Topology, ContextIdList from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from webui.service.main.forms import ContextForm, DescriptorForm Loading Loading @@ -66,7 +66,7 @@ def process_descriptors(descriptors): def home(): context_client.connect() device_client.connect() response = context_client.ListContextIds(Empty()) response: ContextIdList = context_client.ListContextIds(Empty()) context_form: ContextForm = ContextForm() context_form.context.choices.append(('', 'Select...')) for context in response.context_ids: Loading src/webui/tests/test_unitary.py +11 −11 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ from flask.testing import FlaskClient from flask.app import Flask from flask.helpers import url_for from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import Empty, DeviceId, DeviceList, TopologyIdList from common.proto.context_pb2 import ContextIdList, Empty, DeviceId, DeviceList, TopologyIdList # from device.client.DeviceClient import DeviceClient from webui.service import create_app Loading @@ -38,6 +38,11 @@ class TestWebUI(ClientTestCase): self.mocker_delete_device.start() self.addCleanup(self.mocker_delete_device.stop) self.mocker_list_context_ids = mock.patch('webui.service.device.routes.context_client.ListContextIds') self.mocker_list_context_ids.return_value = ContextIdList() # returns an empty list self.mocker_list_context_ids.start() self.addCleanup(self.mocker_list_context_ids.stop) self.mocker_list_devices = mock.patch('webui.service.device.routes.context_client.ListDevices') self.mocker_list_devices.return_value = DeviceList() # returns an empty list self.mocker_list_devices.start() Loading @@ -59,7 +64,7 @@ class TestWebUI(ClientTestCase): mock.patch.stopall() return super().tearDown(client) def test_routes(self, client): def test_routes(self, _) -> None: with self.app.app_context(): url_for('main.home') url_for('service.home') Loading @@ -70,7 +75,7 @@ class TestWebUI(ClientTestCase): url_for('js.topology_js') url_for('js.site_js') def test_device_add_action_success(self, client): def test_device_add_action_success(self, client) -> None: with client.session_transaction() as sess: sess['context_uuid'] = 'admin' DEVICE_EMU = { Loading @@ -93,12 +98,7 @@ class TestWebUI(ClientTestCase): # mocked_delete.assert_called() self.assertInResponse(b'success', rv) def test_service_up(self, client): pass # def test_service_up(client): # def test_service_up(self, client): # rw = client.get('/') # assert rw.status_code == 200, 'Service is not up!' Loading Loading
src/webui/requirements.in +1 −1 Original line number Diff line number Diff line Flask==2.0.2 Flask==2.1.3 Flask-WTF==1.0.0 flask-healthz==0.0.3 flask-unittest==0.1.2 Loading
src/webui/service/device/routes.py +2 −2 Original line number Diff line number Diff line Loading @@ -125,8 +125,8 @@ def delete(device_uuid): response = device_client.DeleteDevice(request) device_client.close() flash('Device "{:s}" deleted successfully!'.format(device_uuid), 'success') flash(f'Device "{device_uuid}" deleted successfully!', 'success') except Exception as e: flash('Problem deleting device "{:s}": {:s}'.format(device_uuid, str(e.details())), 'danger') flash(f'Problem deleting device "{device_uuid}": {e.details()}', 'danger') current_app.logger.exception(e) return redirect(url_for('device.home'))
src/webui/service/main/routes.py +2 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ import json, logging from flask import jsonify, redirect, render_template, Blueprint, flash, session, url_for, request from common.proto.context_pb2 import Context, Device, Empty, Link, Topology from common.proto.context_pb2 import Context, Device, Empty, Link, Topology, ContextIdList from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from webui.service.main.forms import ContextForm, DescriptorForm Loading Loading @@ -66,7 +66,7 @@ def process_descriptors(descriptors): def home(): context_client.connect() device_client.connect() response = context_client.ListContextIds(Empty()) response: ContextIdList = context_client.ListContextIds(Empty()) context_form: ContextForm = ContextForm() context_form.context.choices.append(('', 'Select...')) for context in response.context_ids: Loading
src/webui/tests/test_unitary.py +11 −11 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ from flask.testing import FlaskClient from flask.app import Flask from flask.helpers import url_for from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import Empty, DeviceId, DeviceList, TopologyIdList from common.proto.context_pb2 import ContextIdList, Empty, DeviceId, DeviceList, TopologyIdList # from device.client.DeviceClient import DeviceClient from webui.service import create_app Loading @@ -38,6 +38,11 @@ class TestWebUI(ClientTestCase): self.mocker_delete_device.start() self.addCleanup(self.mocker_delete_device.stop) self.mocker_list_context_ids = mock.patch('webui.service.device.routes.context_client.ListContextIds') self.mocker_list_context_ids.return_value = ContextIdList() # returns an empty list self.mocker_list_context_ids.start() self.addCleanup(self.mocker_list_context_ids.stop) self.mocker_list_devices = mock.patch('webui.service.device.routes.context_client.ListDevices') self.mocker_list_devices.return_value = DeviceList() # returns an empty list self.mocker_list_devices.start() Loading @@ -59,7 +64,7 @@ class TestWebUI(ClientTestCase): mock.patch.stopall() return super().tearDown(client) def test_routes(self, client): def test_routes(self, _) -> None: with self.app.app_context(): url_for('main.home') url_for('service.home') Loading @@ -70,7 +75,7 @@ class TestWebUI(ClientTestCase): url_for('js.topology_js') url_for('js.site_js') def test_device_add_action_success(self, client): def test_device_add_action_success(self, client) -> None: with client.session_transaction() as sess: sess['context_uuid'] = 'admin' DEVICE_EMU = { Loading @@ -93,12 +98,7 @@ class TestWebUI(ClientTestCase): # mocked_delete.assert_called() self.assertInResponse(b'success', rv) def test_service_up(self, client): pass # def test_service_up(client): # def test_service_up(self, client): # rw = client.get('/') # assert rw.status_code == 200, 'Service is not up!' Loading