From 611f6f2829baf5fff571c10ad3364d635187080a Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Fri, 31 May 2019 13:53:46 +0200 Subject: [PATCH] Don't follow requests itself (#1106) * Don't follow requests itself * Fix black lint --- azure-pipelines.yml | 2 +- hassio/api/ingress.py | 7 ++++- setup.py | 55 +++++++++++++++++++++---------------- tests/__init__.py | 2 +- tests/addons/__init__.py | 2 +- tests/addons/test_config.py | 31 +++++++++++---------- 6 files changed, 56 insertions(+), 43 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index baf6806a4..3cdb69003 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,7 +50,7 @@ jobs: versionSpec: '3.7' - script: pip install black displayName: 'Install black' - - script: black --check hassio + - script: black --check hassio tests displayName: 'Run Black' diff --git a/hassio/api/ingress.py b/hassio/api/ingress.py index ef249483d..a5546b30c 100644 --- a/hassio/api/ingress.py +++ b/hassio/api/ingress.py @@ -158,7 +158,12 @@ class APIIngress(CoreSysAttributes): source_header = _init_header(request, addon) async with self.sys_websession.request( - request.method, url, headers=source_header, params=request.query, data=data + request.method, + url, + headers=source_header, + params=request.query, + allow_redirects=False, + data=data, ) as result: headers = _response_header(result) diff --git a/setup.py b/setup.py index ff4fa9a8d..458b65eaf 100644 --- a/setup.py +++ b/setup.py @@ -3,33 +3,40 @@ from setuptools import setup from hassio.const import HASSIO_VERSION setup( - name='HassIO', + name="HassIO", version=HASSIO_VERSION, - license='BSD License', - author='The Home Assistant Authors', - author_email='hello@home-assistant.io', - url='https://home-assistant.io/', - description=('Open-source private cloud os for Home-Assistant' - ' based on HassOS'), - long_description=('A maintainless private cloud operator system that' - 'setup a Home-Assistant instance. Based on HassOS'), + license="BSD License", + author="The Home Assistant Authors", + author_email="hello@home-assistant.io", + url="https://home-assistant.io/", + description=("Open-source private cloud os for Home-Assistant" " based on HassOS"), + long_description=( + "A maintainless private cloud operator system that" + "setup a Home-Assistant instance. Based on HassOS" + ), classifiers=[ - 'Intended Audience :: End Users/Desktop', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Topic :: Home Automation' - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Scientific/Engineering :: Atmospheric Science', - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Programming Language :: Python :: 3.6', + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Topic :: Home Automation" + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Scientific/Engineering :: Atmospheric Science", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Programming Language :: Python :: 3.6", ], - keywords=['docker', 'home-assistant', 'api'], + keywords=["docker", "home-assistant", "api"], zip_safe=False, - platforms='any', + platforms="any", packages=[ - 'hassio', 'hassio.docker', 'hassio.addons', 'hassio.api', 'hassio.misc', - 'hassio.utils', 'hassio.snapshots' + "hassio", + "hassio.docker", + "hassio.addons", + "hassio.api", + "hassio.misc", + "hassio.utils", + "hassio.snapshots", ], - include_package_data=True) + include_package_data=True, +) diff --git a/tests/__init__.py b/tests/__init__.py index 7a37e62ba..4a9f81fe8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -"""Hass.io Testframework.""" \ No newline at end of file +"""Hass.io Testframework.""" diff --git a/tests/addons/__init__.py b/tests/addons/__init__.py index 5221b9624..1cdeb3f77 100644 --- a/tests/addons/__init__.py +++ b/tests/addons/__init__.py @@ -1 +1 @@ -"""Add-ons tests.""" \ No newline at end of file +"""Add-ons tests.""" diff --git a/tests/addons/test_config.py b/tests/addons/test_config.py index 25b7ad563..f47ebc187 100644 --- a/tests/addons/test_config.py +++ b/tests/addons/test_config.py @@ -14,34 +14,35 @@ def test_basic_config(): valid_config = vd.SCHEMA_ADDON_CONFIG(config) - assert valid_config['name'] == "Test Add-on" - assert valid_config['image'] == "test/{arch}-my-custom-addon" + assert valid_config["name"] == "Test Add-on" + assert valid_config["image"] == "test/{arch}-my-custom-addon" # Check defaults - assert not valid_config['host_network'] - assert not valid_config['host_ipc'] - assert not valid_config['host_dbus'] - assert not valid_config['host_pid'] + assert not valid_config["host_network"] + assert not valid_config["host_ipc"] + assert not valid_config["host_dbus"] + assert not valid_config["host_pid"] - assert not valid_config['hassio_api'] - assert not valid_config['homeassistant_api'] - assert not valid_config['docker_api'] + assert not valid_config["hassio_api"] + assert not valid_config["homeassistant_api"] + assert not valid_config["docker_api"] def test_invalid_repository(): """Validate basic config with invalid repositories.""" config = load_json_fixture("basic-addon-config.json") - config['image'] = "something" + config["image"] = "something" with pytest.raises(vol.Invalid): vd.SCHEMA_ADDON_CONFIG(config) - config['image'] = "homeassistant/no-valid-repo:no-tag-allow" + config["image"] = "homeassistant/no-valid-repo:no-tag-allow" with pytest.raises(vol.Invalid): vd.SCHEMA_ADDON_CONFIG(config) config[ - 'image'] = "registry.gitlab.com/company/add-ons/test-example/text-example:no-tag-allow" + "image" + ] = "registry.gitlab.com/company/add-ons/test-example/text-example:no-tag-allow" with pytest.raises(vol.Invalid): vd.SCHEMA_ADDON_CONFIG(config) @@ -51,16 +52,16 @@ def test_valid_repository(): config = load_json_fixture("basic-addon-config.json") custom_registry = "registry.gitlab.com/company/add-ons/core/test-example" - config['image'] = custom_registry + config["image"] = custom_registry valid_config = vd.SCHEMA_ADDON_CONFIG(config) - assert valid_config['image'] == custom_registry + assert valid_config["image"] == custom_registry def test_valid_map(): """Validate basic config with different valid maps""" config = load_json_fixture("basic-addon-config.json") - config['map'] = ['backup:rw', 'ssl:ro', 'config'] + config["map"] = ["backup:rw", "ssl:ro", "config"] vd.SCHEMA_ADDON_CONFIG(config)