Don't follow requests itself (#1106)

* Don't follow requests itself

* Fix black lint
This commit is contained in:
Pascal Vizeli 2019-05-31 13:53:46 +02:00 committed by GitHub
parent b94df76731
commit 611f6f2829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 43 deletions

View File

@ -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'

View File

@ -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)

View File

@ -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,
)

View File

@ -1 +1 @@
"""Hass.io Testframework."""
"""Hass.io Testframework."""

View File

@ -1 +1 @@
"""Add-ons tests."""
"""Add-ons tests."""

View File

@ -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)