Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Config-Variable gps_accuracy_threshold #1

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions homeassistant/components/icloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

from .account import IcloudAccount
from .const import (
CONF_GPS_ACCURACY_THRESHOLD,
CONF_MAX_INTERVAL,
CONF_WITH_FAMILY,
DEFAULT_GPS_ACCURACY_THRESHOLD,
DEFAULT_MAX_INTERVAL,
DEFAULT_WITH_FAMILY,
DOMAIN,
Expand Down Expand Up @@ -74,9 +72,6 @@
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_WITH_FAMILY, default=DEFAULT_WITH_FAMILY): cv.boolean,
vol.Optional(CONF_MAX_INTERVAL, default=DEFAULT_MAX_INTERVAL): cv.positive_int,
vol.Optional(
CONF_GPS_ACCURACY_THRESHOLD, default=DEFAULT_GPS_ACCURACY_THRESHOLD
): cv.positive_int,
}
)

Expand Down Expand Up @@ -112,7 +107,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
password = entry.data[CONF_PASSWORD]
with_family = entry.data[CONF_WITH_FAMILY]
max_interval = entry.data[CONF_MAX_INTERVAL]
gps_accuracy_threshold = entry.data[CONF_GPS_ACCURACY_THRESHOLD]

# For backwards compat
if entry.unique_id is None:
Expand All @@ -127,7 +121,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
icloud_dir,
with_family,
max_interval,
gps_accuracy_threshold,
entry,
)
await hass.async_add_executor_job(account.setup)
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/icloud/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def __init__(
icloud_dir: Store,
with_family: bool,
max_interval: int,
gps_accuracy_threshold: int,
config_entry: ConfigEntry,
) -> None:
"""Initialize an iCloud account."""
Expand All @@ -93,7 +92,6 @@ def __init__(
self._with_family = with_family
self._fetch_interval = max_interval
self._max_interval = max_interval
self._gps_accuracy_threshold = gps_accuracy_threshold

self._icloud_dir = icloud_dir

Expand Down
8 changes: 0 additions & 8 deletions homeassistant/components/icloud/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME

from .const import (
CONF_GPS_ACCURACY_THRESHOLD,
CONF_MAX_INTERVAL,
CONF_WITH_FAMILY,
DEFAULT_GPS_ACCURACY_THRESHOLD,
DEFAULT_MAX_INTERVAL,
DEFAULT_WITH_FAMILY,
DOMAIN,
Expand All @@ -44,7 +42,6 @@ def __init__(self):
self._password = None
self._with_family = None
self._max_interval = None
self._gps_accuracy_threshold = None

self._trusted_device = None
self._verification_code = None
Expand Down Expand Up @@ -99,9 +96,6 @@ async def _validate_and_create_entry(self, user_input, step_id):
self._username = extra_inputs[CONF_USERNAME]
self._with_family = extra_inputs.get(CONF_WITH_FAMILY, DEFAULT_WITH_FAMILY)
self._max_interval = extra_inputs.get(CONF_MAX_INTERVAL, DEFAULT_MAX_INTERVAL)
self._gps_accuracy_threshold = extra_inputs.get(
CONF_GPS_ACCURACY_THRESHOLD, DEFAULT_GPS_ACCURACY_THRESHOLD
)

# Check if already configured
if self.unique_id is None:
Expand Down Expand Up @@ -146,7 +140,6 @@ async def _validate_and_create_entry(self, user_input, step_id):
CONF_PASSWORD: self._password,
CONF_WITH_FAMILY: self._with_family,
CONF_MAX_INTERVAL: self._max_interval,
CONF_GPS_ACCURACY_THRESHOLD: self._gps_accuracy_threshold,
}

# If this is a password update attempt, update the entry instead of creating one
Expand Down Expand Up @@ -302,7 +295,6 @@ async def async_step_verification_code(self, user_input=None, errors=None):
CONF_PASSWORD: self._password,
CONF_WITH_FAMILY: self._with_family,
CONF_MAX_INTERVAL: self._max_interval,
CONF_GPS_ACCURACY_THRESHOLD: self._gps_accuracy_threshold,
}
)

Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/icloud/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

CONF_WITH_FAMILY = "with_family"
CONF_MAX_INTERVAL = "max_interval"
CONF_GPS_ACCURACY_THRESHOLD = "gps_accuracy_threshold"

DEFAULT_WITH_FAMILY = False
DEFAULT_MAX_INTERVAL = 30 # min
DEFAULT_GPS_ACCURACY_THRESHOLD = 500 # meters

# to store the cookie
STORAGE_KEY = DOMAIN
Expand Down
12 changes: 0 additions & 12 deletions tests/components/icloud/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
CONF_VERIFICATION_CODE,
)
from homeassistant.components.icloud.const import (
CONF_GPS_ACCURACY_THRESHOLD,
CONF_MAX_INTERVAL,
CONF_WITH_FAMILY,
DEFAULT_GPS_ACCURACY_THRESHOLD,
DEFAULT_MAX_INTERVAL,
DEFAULT_WITH_FAMILY,
DOMAIN,
Expand All @@ -30,14 +28,12 @@
PASSWORD_2 = "second_password"
WITH_FAMILY = True
MAX_INTERVAL = 15
GPS_ACCURACY_THRESHOLD = 250

MOCK_CONFIG = {
CONF_USERNAME: USERNAME,
CONF_PASSWORD: PASSWORD,
CONF_WITH_FAMILY: DEFAULT_WITH_FAMILY,
CONF_MAX_INTERVAL: DEFAULT_MAX_INTERVAL,
CONF_GPS_ACCURACY_THRESHOLD: DEFAULT_GPS_ACCURACY_THRESHOLD,
}

TRUSTED_DEVICES = [
Expand Down Expand Up @@ -194,7 +190,6 @@ async def test_user_with_cookie(hass: HomeAssistant, service_authenticated: Magi
assert result["data"][CONF_PASSWORD] == PASSWORD
assert result["data"][CONF_WITH_FAMILY] == WITH_FAMILY
assert result["data"][CONF_MAX_INTERVAL] == DEFAULT_MAX_INTERVAL
assert result["data"][CONF_GPS_ACCURACY_THRESHOLD] == DEFAULT_GPS_ACCURACY_THRESHOLD


async def test_import(hass: HomeAssistant, service: MagicMock):
Expand All @@ -217,7 +212,6 @@ async def test_import(hass: HomeAssistant, service: MagicMock):
CONF_PASSWORD: PASSWORD,
CONF_WITH_FAMILY: WITH_FAMILY,
CONF_MAX_INTERVAL: MAX_INTERVAL,
CONF_GPS_ACCURACY_THRESHOLD: GPS_ACCURACY_THRESHOLD,
},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
Expand All @@ -241,7 +235,6 @@ async def test_import_with_cookie(
assert result["data"][CONF_PASSWORD] == PASSWORD
assert result["data"][CONF_WITH_FAMILY] == DEFAULT_WITH_FAMILY
assert result["data"][CONF_MAX_INTERVAL] == DEFAULT_MAX_INTERVAL
assert result["data"][CONF_GPS_ACCURACY_THRESHOLD] == DEFAULT_GPS_ACCURACY_THRESHOLD

# import with all
result = await hass.config_entries.flow.async_init(
Expand All @@ -252,7 +245,6 @@ async def test_import_with_cookie(
CONF_PASSWORD: PASSWORD,
CONF_WITH_FAMILY: WITH_FAMILY,
CONF_MAX_INTERVAL: MAX_INTERVAL,
CONF_GPS_ACCURACY_THRESHOLD: GPS_ACCURACY_THRESHOLD,
},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
Expand All @@ -262,7 +254,6 @@ async def test_import_with_cookie(
assert result["data"][CONF_PASSWORD] == PASSWORD
assert result["data"][CONF_WITH_FAMILY] == WITH_FAMILY
assert result["data"][CONF_MAX_INTERVAL] == MAX_INTERVAL
assert result["data"][CONF_GPS_ACCURACY_THRESHOLD] == GPS_ACCURACY_THRESHOLD


async def test_two_accounts_setup(
Expand All @@ -288,7 +279,6 @@ async def test_two_accounts_setup(
assert result["data"][CONF_PASSWORD] == PASSWORD
assert result["data"][CONF_WITH_FAMILY] == DEFAULT_WITH_FAMILY
assert result["data"][CONF_MAX_INTERVAL] == DEFAULT_MAX_INTERVAL
assert result["data"][CONF_GPS_ACCURACY_THRESHOLD] == DEFAULT_GPS_ACCURACY_THRESHOLD


async def test_already_setup(hass: HomeAssistant):
Expand Down Expand Up @@ -430,7 +420,6 @@ async def test_verification_code_success(hass: HomeAssistant, service: MagicMock
assert result["data"][CONF_PASSWORD] == PASSWORD
assert result["data"][CONF_WITH_FAMILY] == DEFAULT_WITH_FAMILY
assert result["data"][CONF_MAX_INTERVAL] == DEFAULT_MAX_INTERVAL
assert result["data"][CONF_GPS_ACCURACY_THRESHOLD] == DEFAULT_GPS_ACCURACY_THRESHOLD


async def test_validate_verification_code_failed(
Expand Down Expand Up @@ -475,7 +464,6 @@ async def test_2fa_code_success(hass: HomeAssistant, service_2fa: MagicMock):
assert result["data"][CONF_PASSWORD] == PASSWORD
assert result["data"][CONF_WITH_FAMILY] == DEFAULT_WITH_FAMILY
assert result["data"][CONF_MAX_INTERVAL] == DEFAULT_MAX_INTERVAL
assert result["data"][CONF_GPS_ACCURACY_THRESHOLD] == DEFAULT_GPS_ACCURACY_THRESHOLD


async def test_validate_2fa_code_failed(
Expand Down