Skip to content

Commit

Permalink
Merge remote-tracking branch 'blueprint/dev' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	hacs.json
#	setup.cfg
  • Loading branch information
Limych committed Feb 8, 2023
2 parents 48bde38 + 19b8857 commit d56dbef
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand All @@ -61,7 +61,7 @@ jobs:
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v3
- uses: dessant/lock-threads@v4
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: 30
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ repos:
language: script
files: ^(custom_components/.+/const\.py|requirements\.txt)$
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [ --py37-plus ]
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
args:
- --safe
- --quiet
files: ^(custom_components|bin|tests)/.+\.py$
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1
- repo: https://github.com/pycqa/flake8.git
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings==1.5.0
- pydocstyle==5.0.2
files: ^(custom_components|bin|tests)/.+\.py$
- repo: https://github.com/PyCQA/bandit
rev: 1.7.0
rev: 1.7.4
hooks:
- id: bandit
args:
Expand All @@ -37,11 +37,11 @@ repos:
- --configfile=tests/bandit.yaml
files: ^(custom_components|bin|tests)/.+\.py$
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.6.4
rev: v5.10.1
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v4.4.0
hooks:
- id: check-executables-have-shebangs
stages: [manual]
Expand Down
4 changes: 3 additions & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ source ./bin/_common

if [ ! -d "venv" ]; then
log.info "Initializing the virtual environment..."
${python} -m venv venv
# For error 'executable `python` not found' run
# rm -Rf ~/.local/share/virtualenv
${python} -m venv ./venv
source ./venv/bin/activate
python="${ROOT}/venv/bin/python3"
fi
Expand Down
3 changes: 2 additions & 1 deletion bin/update_requirements
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def get_package(requre: str) -> str:

harequire = ["homeassistant"]
request = requests.get(
"https://raw.githubusercontent.com/home-assistant/core/dev/requirements.txt"
"https://raw.githubusercontent.com/home-assistant/core/dev/requirements.txt",
timeout=10
)
request = request.text.split("\n")
for req in request:
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Average Sensor",
"hacs": "1.6.0",
"homeassistant": "2022.7.0"
"homeassistant": "2022.10.0"
}
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
black==22.10.0
packaging==21.3
pre-commit~=2.20
PyGithub~=1.55
pyupgrade~=3.0
PyGithub~=1.57
pyupgrade~=3.3
yamllint~=1.28
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
asynctest~=0.13
flake8~=5.0
flake8-docstrings~=1.6
mypy==0.982
mypy==1.0.0
pylint~=2.15
pylint-strict-informational==0.1
pytest~=7.1
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ known_first_party = custom_components,tests
forced_separate = tests

[mypy]
python_version = 3.9
ignore_errors = true
follow_imports = silent
ignore_missing_imports = true
Expand Down
35 changes: 8 additions & 27 deletions tests/test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

import logging
from datetime import timedelta
from unittest.mock import patch

from homeassistant.components import recorder
from homeassistant.components.input_boolean import DOMAIN
from homeassistant.components.recorder.db_schema import StateAttributes, States
from homeassistant.components.recorder.util import session_scope
from homeassistant.const import ATTR_EDITABLE
from homeassistant.core import HomeAssistant, State
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
from pytest_homeassistant_custom_component.common import async_fire_time_changed
from pytest_homeassistant_custom_component.common import (
SetupRecorderInstanceT,
async_fire_time_changed,
)
from pytest_homeassistant_custom_component.components.recorder.common import (
wait_recording_done,
)
Expand All @@ -23,38 +24,18 @@
_LOGGER = logging.getLogger(__name__)


async def async_init_recorder_component(hass, add_config=None):
"""Initialize the recorder asynchronously."""
config = dict(add_config) if add_config else {}
if recorder.CONF_DB_URL not in config:
config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB
if recorder.CONF_COMMIT_INTERVAL not in config:
config[recorder.CONF_COMMIT_INTERVAL] = 0

with patch(
"homeassistant.components.recorder.ALLOW_IN_MEMORY_DB",
True,
), patch("homeassistant.components.recorder.migration.migrate_schema"):
assert await async_setup_component(
hass, recorder.DOMAIN, {recorder.DOMAIN: config}
)
assert recorder.DOMAIN in hass.config.components
_LOGGER.info(
"Test recorder successfully started, database location: %s",
config[recorder.CONF_DB_URL],
)


async def async_wait_recording_done_without_instance(hass: HomeAssistant) -> None:
"""Block till recording is done."""
await hass.loop.run_in_executor(None, wait_recording_done, hass)


async def test_exclude_attributes(
hass: HomeAssistant, enable_custom_integrations: None
hass: HomeAssistant,
async_setup_recorder_instance: SetupRecorderInstanceT,
enable_custom_integrations: None,
):
"""Test attributes to be excluded."""
await async_init_recorder_component(hass)
await async_setup_recorder_instance(hass)
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {"test": {}}})

state = hass.states.get("input_boolean.test")
Expand Down

0 comments on commit d56dbef

Please sign in to comment.