async def exposeserver(self, request: Request): expose = BoolValidator.strToBool(request.query.get("expose", False)) if expose: update = {Setting.EXPOSE_EXTRA_SERVER: True} else: update = { Setting.EXPOSE_EXTRA_SERVER: False, Setting.USE_SSL: False, Setting.REQUIRE_LOGIN: False } validated = self.config.validateUpdate(update) await self._updateConfiguration(validated) File.touch(self.config.get(Setting.INGRESS_TOKEN_FILE_PATH)) await self._ha_source.init() redirect = "" try: if request.url.port != self.config.get(Setting.INGRESS_PORT): redirect = self._ha_source.getFullAddonUrl() except: # noqa: E722 # eat the error pass return web.json_response({ 'message': 'Configuration updated', 'redirect': redirect })
async def test_getstatus(reader, config: Config, ha, server, ports: Ports): File.touch(config.get(Setting.INGRESS_TOKEN_FILE_PATH)) await ha.init() data = await reader.getjson("getstatus") assert data['ask_error_reports'] is True assert data['cred_version'] == 0 assert data['firstSync'] is True assert data['folder_id'] is None assert data['last_error'] is None assert data['last_snapshot_text'] == "Never" assert data['next_snapshot_text'] == "right now" assert data['snapshot_name_template'] == config.get(Setting.SNAPSHOT_NAME) assert data['warn_ingress_upgrade'] is False assert len(data['snapshots']) == 0 assert data['sources'][SOURCE_GOOGLE_DRIVE] == { 'deletable': 0, 'name': SOURCE_GOOGLE_DRIVE, 'retained': 0, 'snapshots': 0, 'latest': None, 'size': '0.0 B', 'enabled': True, 'max': config.get(Setting.MAX_SNAPSHOTS_IN_GOOGLE_DRIVE), 'title': "Google Drive", 'icon': 'google-drive', 'ignored': 0, 'ignored_size': '0.0 B', } assert data['sources'][SOURCE_HA] == { 'deletable': 0, 'name': SOURCE_HA, 'retained': 0, 'snapshots': 0, 'latest': None, 'size': '0.0 B', 'enabled': True, 'max': config.get(Setting.MAX_SNAPSHOTS_IN_HASSIO), 'title': "Home Assistant", 'free_space': "0.0 B", 'icon': 'home-assistant', 'ignored': 0, 'ignored_size': '0.0 B', } assert len(data['sources']) == 2
async def test_getstatus(reader, config: Config, ha, server, ports: Ports): File.touch(config.get(Setting.INGRESS_TOKEN_FILE_PATH)) await ha.init() data = await reader.getjson("getstatus") assert data['ask_error_reports'] is True assert data['cred_version'] == 0 assert data['drive_enabled'] is True assert data['firstSync'] is True assert data['folder_id'] is None assert data['last_error'] is None assert data['last_snapshot_text'] == "Never" assert data['maxSnapshotsInDrive'] == config.get( Setting.MAX_SNAPSHOTS_IN_GOOGLE_DRIVE) assert data['maxSnapshotsInHasssio'] == config.get( Setting.MAX_SNAPSHOTS_IN_HASSIO) assert data['next_snapshot_text'] == "right now" assert data['restore_link'] == "https://{0}:{1}/hassio/snapshots".format( "{host}", ports.server) assert data['snapshot_name_template'] == config.get(Setting.SNAPSHOT_NAME) assert data['warn_ingress_upgrade'] is False assert len(data['snapshots']) == 0 assert data['sources'][SOURCE_GOOGLE_DRIVE] == { 'deletable': 0, 'name': SOURCE_GOOGLE_DRIVE, 'retained': 0, 'snapshots': 0, 'latest': None, 'size': '0.0 B' } assert data['sources'][SOURCE_HA] == { 'deletable': 0, 'name': SOURCE_HA, 'retained': 0, 'snapshots': 0, 'latest': None, 'size': '0.0 B' } assert len(data['sources']) == 2