diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml index 38c0eb6..73be941 100644 --- a/.devcontainer/configuration.yaml +++ b/.devcontainer/configuration.yaml @@ -3,7 +3,7 @@ default_config: logger: default: info logs: - custom_components.integration_blueprint: debug + custom_components.octopusenergy: debug # If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/) # debugpy: diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index d895c86..0b1f9ea 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -49,7 +49,7 @@ jobs: --timeout=9 \ --durations=10 \ -n auto \ - --cov custom_components.integration_blueprint \ + --cov custom_components.octopusenergy \ -o console_output_style=count \ -p no:sugar \ tests diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index d0ff7bf..409b3f4 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -52,7 +52,7 @@ jobs: --timeout=9 \ --durations=10 \ -n auto \ - --cov custom_components.integration_blueprint \ + --cov custom_components.octopusenergy \ -o console_output_style=count \ -p no:sugar \ tests \ No newline at end of file diff --git a/README.md b/README.md index 18b8a6f..e15f3d3 100644 --- a/README.md +++ b/README.md @@ -24,21 +24,21 @@ File | Purpose `.github/ISSUE_TEMPLATE/feature_request.md` | Template for Feature Requests `.github/ISSUE_TEMPLATE/issue.md` | Template for issues `.vscode/tasks.json` | Tasks for the devcontainer. -`custom_components/integration_blueprint/translations/*` | [Translation files.](https://developers.home-assistant.io/docs/internationalization/custom_integration) -`custom_components/integration_blueprint/__init__.py` | The component file for the integration. -`custom_components/integration_blueprint/api.py` | This is a sample API client. -`custom_components/integration_blueprint/binary_sensor.py` | Binary sensor platform for the integration. -`custom_components/integration_blueprint/config_flow.py` | Config flow file, this adds the UI configuration possibilities. -`custom_components/integration_blueprint/const.py` | A file to hold shared variables/constants for the entire integration. -`custom_components/integration_blueprint/manifest.json` | A [manifest file](https://developers.home-assistant.io/docs/en/creating_integration_manifest.html) for Home Assistant. -`custom_components/integration_blueprint/sensor.py` | Sensor platform for the integration. -`custom_components/integration_blueprint/switch.py` | Switch sensor platform for the integration. +`custom_components/octopusenergy/translations/*` | [Translation files.](https://developers.home-assistant.io/docs/internationalization/custom_integration) +`custom_components/octopusenergy/__init__.py` | The component file for the integration. +`custom_components/octopusenergy/api.py` | This is a sample API client. +`custom_components/octopusenergy/binary_sensor.py` | Binary sensor platform for the integration. +`custom_components/octopusenergy/config_flow.py` | Config flow file, this adds the UI configuration possibilities. +`custom_components/octopusenergy/const.py` | A file to hold shared variables/constants for the entire integration. +`custom_components/octopusenergy/manifest.json` | A [manifest file](https://developers.home-assistant.io/docs/en/creating_integration_manifest.html) for Home Assistant. +`custom_components/octopusenergy/sensor.py` | Sensor platform for the integration. +`custom_components/octopusenergy/switch.py` | Switch sensor platform for the integration. `tests/__init__.py` | Makes the `tests` folder a module. `tests/conftest.py` | Global [fixtures](https://docs.pytest.org/en/stable/fixture.html) used in tests to [patch](https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch) functions. -`tests/test_api.py` | Tests for `custom_components/integration_blueprint/api.py`. -`tests/test_config_flow.py` | Tests for `custom_components/integration_blueprint/config_flow.py`. -`tests/test_init.py` | Tests for `custom_components/integration_blueprint/__init__.py`. -`tests/test_switch.py` | Tests for `custom_components/integration_blueprint/switch.py`. +`tests/test_api.py` | Tests for `custom_components/octopusenergy/api.py`. +`tests/test_config_flow.py` | Tests for `custom_components/octopusenergy/config_flow.py`. +`tests/test_init.py` | Tests for `custom_components/octopusenergy/__init__.py`. +`tests/test_switch.py` | Tests for `custom_components/octopusenergy/switch.py`. `CONTRIBUTING.md` | Guidelines on how to contribute. `example.png` | Screenshot that demonstrate how it might look in the UI. `info.md` | An example on a info file (used by [hacs][hacs]). @@ -72,7 +72,7 @@ to ensure Home Assistant update the code of the python library. (example `"requi README content if this was a published component: *** -# integration_blueprint +# octopusenergy [![GitHub Release][releases-shield]][releases] [![GitHub Activity][commits-shield]][commits] @@ -85,7 +85,7 @@ README content if this was a published component: [![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum] -_Component to integrate with [integration_blueprint][integration_blueprint]._ +_Component to integrate with [octopusenergy][octopusenergy]._ **This component will set up the following platforms.** @@ -101,8 +101,8 @@ Platform | Description 1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`). 2. If you do not have a `custom_components` directory (folder) there, you need to create it. -3. In the `custom_components` directory (folder) create a new folder called `integration_blueprint`. -4. Download _all_ the files from the `custom_components/integration_blueprint/` directory (folder) in this repository. +3. In the `custom_components` directory (folder) create a new folder called `octopusenergy`. +4. Download _all_ the files from the `custom_components/octopusenergy/` directory (folder) in this repository. 5. Place the files you downloaded in the new directory (folder) you created. 6. Restart Home Assistant 7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Integration blueprint" @@ -110,17 +110,17 @@ Platform | Description Using your HA configuration directory (folder) as a starting point you should now also have this: ```text -custom_components/integration_blueprint/translations/en.json -custom_components/integration_blueprint/translations/nb.json -custom_components/integration_blueprint/translations/sensor.nb.json -custom_components/integration_blueprint/__init__.py -custom_components/integration_blueprint/api.py -custom_components/integration_blueprint/binary_sensor.py -custom_components/integration_blueprint/config_flow.py -custom_components/integration_blueprint/const.py -custom_components/integration_blueprint/manifest.json -custom_components/integration_blueprint/sensor.py -custom_components/integration_blueprint/switch.py +custom_components/octopusenergy/translations/en.json +custom_components/octopusenergy/translations/nb.json +custom_components/octopusenergy/translations/sensor.nb.json +custom_components/octopusenergy/__init__.py +custom_components/octopusenergy/api.py +custom_components/octopusenergy/binary_sensor.py +custom_components/octopusenergy/config_flow.py +custom_components/octopusenergy/const.py +custom_components/octopusenergy/manifest.json +custom_components/octopusenergy/sensor.py +custom_components/octopusenergy/switch.py ``` ## Configuration is done in the UI @@ -133,11 +133,11 @@ If you want to contribute to this please read the [Contribution guidelines](CONT *** -[integration_blueprint]: https://github.com/custom-components/integration_blueprint +[octopusenergy]: https://github.com/custom-components/octopusenergy [buymecoffee]: https://www.buymeacoffee.com/ludeeus [buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge [commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge -[commits]: https://github.com/custom-components/integration_blueprint/commits/master +[commits]: https://github.com/custom-components/octopusenergy/commits/master [hacs]: https://github.com/custom-components/hacs [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge [discord]: https://discord.gg/Qa5fW2R @@ -148,4 +148,4 @@ If you want to contribute to this please read the [Contribution guidelines](CONT [license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge [maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge [releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge -[releases]: https://github.com/custom-components/integration_blueprint/releases +[releases]: https://github.com/custom-components/octopusenergy/releases diff --git a/custom_components/integration_blueprint/manifest.json b/custom_components/integration_blueprint/manifest.json deleted file mode 100644 index 138b1e7..0000000 --- a/custom_components/integration_blueprint/manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "domain": "integration_blueprint", - "name": "Integration blueprint", - "documentation": "https://github.com/custom-components/integration_blueprint", - "iot_class": "cloud_polling", - "issue_tracker": "https://github.com/custom-components/integration_blueprint/issues", - "version": "0.0.0", - "config_flow": true, - "codeowners": [ - "@ludeeus" - ] -} \ No newline at end of file diff --git a/custom_components/integration_blueprint/__init__.py b/custom_components/octopusenergy/__init__.py similarity index 90% rename from custom_components/integration_blueprint/__init__.py rename to custom_components/octopusenergy/__init__.py index b8e31db..ae6e071 100644 --- a/custom_components/integration_blueprint/__init__.py +++ b/custom_components/octopusenergy/__init__.py @@ -1,8 +1,8 @@ """ -Custom integration to integrate integration_blueprint with Home Assistant. +Custom integration to integrate octopusenergy with Home Assistant. For more details about this integration, please refer to -https://github.com/custom-components/integration_blueprint +https://github.com/custom-components/octopusenergy """ import asyncio from datetime import timedelta @@ -14,7 +14,7 @@ from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed -from .api import IntegrationBlueprintApiClient +from .api import OctopusEnergyApiClient from .const import ( CONF_PASSWORD, @@ -44,7 +44,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): password = entry.data.get(CONF_PASSWORD) session = async_get_clientsession(hass) - client = IntegrationBlueprintApiClient(username, password, session) + client = OctopusEnergyApiClient(username, password, session) coordinator = BlueprintDataUpdateCoordinator(hass, client=client) await coordinator.async_refresh() @@ -69,7 +69,7 @@ class BlueprintDataUpdateCoordinator(DataUpdateCoordinator): """Class to manage fetching data from the API.""" def __init__( - self, hass: HomeAssistant, client: IntegrationBlueprintApiClient + self, hass: HomeAssistant, client: OctopusEnergyApiClient ) -> None: """Initialize.""" self.api = client diff --git a/custom_components/integration_blueprint/api.py b/custom_components/octopusenergy/api.py similarity index 98% rename from custom_components/integration_blueprint/api.py rename to custom_components/octopusenergy/api.py index 5414e23..33cc2e7 100644 --- a/custom_components/integration_blueprint/api.py +++ b/custom_components/octopusenergy/api.py @@ -14,7 +14,7 @@ _LOGGER: logging.Logger = logging.getLogger(__package__) HEADERS = {"Content-type": "application/json; charset=UTF-8"} -class IntegrationBlueprintApiClient: +class OctopusEnergyApiClient: def __init__( self, username: str, password: str, session: aiohttp.ClientSession ) -> None: diff --git a/custom_components/integration_blueprint/binary_sensor.py b/custom_components/octopusenergy/binary_sensor.py similarity index 70% rename from custom_components/integration_blueprint/binary_sensor.py rename to custom_components/octopusenergy/binary_sensor.py index 6b92f30..c4a0618 100644 --- a/custom_components/integration_blueprint/binary_sensor.py +++ b/custom_components/octopusenergy/binary_sensor.py @@ -1,4 +1,4 @@ -"""Binary sensor platform for integration_blueprint.""" +"""Binary sensor platform for octopusenergy.""" from homeassistant.components.binary_sensor import BinarySensorEntity from .const import ( @@ -7,17 +7,17 @@ from .const import ( DEFAULT_NAME, DOMAIN, ) -from .entity import IntegrationBlueprintEntity +from .entity import OctopusEnergyEntity async def async_setup_entry(hass, entry, async_add_devices): """Setup binary_sensor platform.""" coordinator = hass.data[DOMAIN][entry.entry_id] - async_add_devices([IntegrationBlueprintBinarySensor(coordinator, entry)]) + async_add_devices([OctopusEnergyBinarySensor(coordinator, entry)]) -class IntegrationBlueprintBinarySensor(IntegrationBlueprintEntity, BinarySensorEntity): - """integration_blueprint binary_sensor class.""" +class OctopusEnergyBinarySensor(OctopusEnergyEntity, BinarySensorEntity): + """octopusenergy binary_sensor class.""" @property def name(self): diff --git a/custom_components/integration_blueprint/config_flow.py b/custom_components/octopusenergy/config_flow.py similarity index 96% rename from custom_components/integration_blueprint/config_flow.py rename to custom_components/octopusenergy/config_flow.py index 26f06a0..0cbc614 100644 --- a/custom_components/integration_blueprint/config_flow.py +++ b/custom_components/octopusenergy/config_flow.py @@ -4,7 +4,7 @@ from homeassistant.core import callback from homeassistant.helpers.aiohttp_client import async_create_clientsession import voluptuous as vol -from .api import IntegrationBlueprintApiClient +from .api import OctopusEnergyApiClient from .const import ( CONF_PASSWORD, CONF_USERNAME, @@ -73,7 +73,7 @@ class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Return true if credentials is valid.""" try: session = async_create_clientsession(self.hass) - client = IntegrationBlueprintApiClient(username, password, session) + client = OctopusEnergyApiClient(username, password, session) await client.async_get_data() return True except Exception: # pylint: disable=broad-except diff --git a/custom_components/integration_blueprint/const.py b/custom_components/octopusenergy/const.py similarity index 84% rename from custom_components/integration_blueprint/const.py rename to custom_components/octopusenergy/const.py index c9fa745..bc4c229 100644 --- a/custom_components/integration_blueprint/const.py +++ b/custom_components/octopusenergy/const.py @@ -1,11 +1,11 @@ -"""Constants for integration_blueprint.""" +"""Constants for octopusenergy.""" # Base component constants NAME = "Integration blueprint" -DOMAIN = "integration_blueprint" +DOMAIN = "octopusenergy" DOMAIN_DATA = f"{DOMAIN}_data" VERSION = "0.0.1" ATTRIBUTION = "Data provided by http://jsonplaceholder.typicode.com/" -ISSUE_URL = "https://github.com/custom-components/integration_blueprint/issues" +ISSUE_URL = "https://github.com/custom-components/octopusenergy/issues" # Icons ICON = "mdi:format-quote-close" diff --git a/custom_components/integration_blueprint/entity.py b/custom_components/octopusenergy/entity.py similarity index 94% rename from custom_components/integration_blueprint/entity.py rename to custom_components/octopusenergy/entity.py index 0ab5eff..eecb396 100644 --- a/custom_components/integration_blueprint/entity.py +++ b/custom_components/octopusenergy/entity.py @@ -4,7 +4,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import DOMAIN, NAME, VERSION, ATTRIBUTION -class IntegrationBlueprintEntity(CoordinatorEntity): +class OctopusEnergyEntity(CoordinatorEntity): def __init__(self, coordinator, config_entry): super().__init__(coordinator) self.config_entry = config_entry diff --git a/custom_components/octopusenergy/manifest.json b/custom_components/octopusenergy/manifest.json new file mode 100644 index 0000000..9983885 --- /dev/null +++ b/custom_components/octopusenergy/manifest.json @@ -0,0 +1,12 @@ +{ + "domain": "octopusenergy", + "name": "Integration blueprint", + "documentation": "https://github.com/custom-components/octopusenergy", + "iot_class": "cloud_polling", + "issue_tracker": "https://github.com/custom-components/octopusenergy/issues", + "version": "0.0.0", + "config_flow": true, + "codeowners": [ + "@ludeeus" + ] +} \ No newline at end of file diff --git a/custom_components/integration_blueprint/sensor.py b/custom_components/octopusenergy/sensor.py similarity index 66% rename from custom_components/integration_blueprint/sensor.py rename to custom_components/octopusenergy/sensor.py index e5152da..8618ab9 100644 --- a/custom_components/integration_blueprint/sensor.py +++ b/custom_components/octopusenergy/sensor.py @@ -1,16 +1,16 @@ -"""Sensor platform for integration_blueprint.""" +"""Sensor platform for octopusenergy.""" from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR -from .entity import IntegrationBlueprintEntity +from .entity import OctopusEnergyEntity async def async_setup_entry(hass, entry, async_add_devices): """Setup sensor platform.""" coordinator = hass.data[DOMAIN][entry.entry_id] - async_add_devices([IntegrationBlueprintSensor(coordinator, entry)]) + async_add_devices([OctopusEnergySensor(coordinator, entry)]) -class IntegrationBlueprintSensor(IntegrationBlueprintEntity): - """integration_blueprint Sensor class.""" +class OctopusEnergySensor(OctopusEnergyEntity): + """octopusenergy Sensor class.""" @property def name(self): diff --git a/custom_components/integration_blueprint/switch.py b/custom_components/octopusenergy/switch.py similarity index 78% rename from custom_components/integration_blueprint/switch.py rename to custom_components/octopusenergy/switch.py index 8381e6f..b39cfc5 100644 --- a/custom_components/integration_blueprint/switch.py +++ b/custom_components/octopusenergy/switch.py @@ -1,18 +1,18 @@ -"""Switch platform for integration_blueprint.""" +"""Switch platform for octopusenergy.""" from homeassistant.components.switch import SwitchEntity from .const import DEFAULT_NAME, DOMAIN, ICON, SWITCH -from .entity import IntegrationBlueprintEntity +from .entity import OctopusEnergyEntity async def async_setup_entry(hass, entry, async_add_devices): """Setup sensor platform.""" coordinator = hass.data[DOMAIN][entry.entry_id] - async_add_devices([IntegrationBlueprintBinarySwitch(coordinator, entry)]) + async_add_devices([OctopusEnergyBinarySwitch(coordinator, entry)]) -class IntegrationBlueprintBinarySwitch(IntegrationBlueprintEntity, SwitchEntity): - """integration_blueprint switch class.""" +class OctopusEnergyBinarySwitch(OctopusEnergyEntity, SwitchEntity): + """octopusenergy switch class.""" async def async_turn_on(self, **kwargs): # pylint: disable=unused-argument """Turn on the switch.""" diff --git a/custom_components/integration_blueprint/translations/en.json b/custom_components/octopusenergy/translations/en.json similarity index 90% rename from custom_components/integration_blueprint/translations/en.json rename to custom_components/octopusenergy/translations/en.json index ecf368a..1e2ab4e 100644 --- a/custom_components/integration_blueprint/translations/en.json +++ b/custom_components/octopusenergy/translations/en.json @@ -3,7 +3,7 @@ "step": { "user": { "title": "Blueprint", - "description": "If you need help with the configuration have a look here: https://github.com/custom-components/integration_blueprint", + "description": "If you need help with the configuration have a look here: https://github.com/custom-components/octopusenergy", "data": { "username": "Username", "password": "Password" diff --git a/custom_components/integration_blueprint/translations/fr.json b/custom_components/octopusenergy/translations/fr.json similarity index 96% rename from custom_components/integration_blueprint/translations/fr.json rename to custom_components/octopusenergy/translations/fr.json index 842caa7..5e4eaa1 100644 --- a/custom_components/integration_blueprint/translations/fr.json +++ b/custom_components/octopusenergy/translations/fr.json @@ -3,7 +3,7 @@ "step": { "user": { "title": "Blueprint", - "description": "Si vous avez besoin d'aide pour la configuration, regardez ici: https://github.com/custom-components/integration_blueprint", + "description": "Si vous avez besoin d'aide pour la configuration, regardez ici: https://github.com/custom-components/octopusenergy", "data": { "username": "Identifiant", "password": "Mot de Passe" diff --git a/custom_components/integration_blueprint/translations/nb.json b/custom_components/octopusenergy/translations/nb.json similarity index 90% rename from custom_components/integration_blueprint/translations/nb.json rename to custom_components/octopusenergy/translations/nb.json index e3ef188..ac669e4 100644 --- a/custom_components/integration_blueprint/translations/nb.json +++ b/custom_components/octopusenergy/translations/nb.json @@ -3,7 +3,7 @@ "step": { "user": { "title": "Blueprint", - "description": "Hvis du trenger hjep til konfigurasjon ta en titt her: https://github.com/custom-components/integration_blueprint", + "description": "Hvis du trenger hjep til konfigurasjon ta en titt her: https://github.com/custom-components/octopusenergy", "data": { "username": "Brukernavn", "password": "Passord" diff --git a/info.md b/info.md index 714b9e5..65cb000 100644 --- a/info.md +++ b/info.md @@ -9,7 +9,7 @@ [![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum] -_Component to integrate with [integration_blueprint][integration_blueprint]._ +_Component to integrate with [octopusenergy][octopusenergy]._ **This component will set up the following platforms.** @@ -36,11 +36,11 @@ Platform | Description *** -[integration_blueprint]: https://github.com/custom-components/integration_blueprint +[octopusenergy]: https://github.com/custom-components/octopusenergy [buymecoffee]: https://www.buymeacoffee.com/ludeeus [buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge -[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/integration_blueprint.svg?style=for-the-badge -[commits]: https://github.com/custom-components/integration_blueprint/commits/master +[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/octopusenergy.svg?style=for-the-badge +[commits]: https://github.com/custom-components/octopusenergy/commits/master [hacs]: https://hacs.xyz [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge [discord]: https://discord.gg/Qa5fW2R @@ -48,9 +48,9 @@ Platform | Description [exampleimg]: example.png [forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge [forum]: https://community.home-assistant.io/ -[license]: https://github.com/custom-components/integration_blueprint/blob/main/LICENSE -[license-shield]: https://img.shields.io/github/license/custom-components/integration_blueprint.svg?style=for-the-badge +[license]: https://github.com/custom-components/octopusenergy/blob/main/LICENSE +[license-shield]: https://img.shields.io/github/license/custom-components/octopusenergy.svg?style=for-the-badge [maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge -[releases-shield]: https://img.shields.io/github/release/custom-components/integration_blueprint.svg?style=for-the-badge -[releases]: https://github.com/custom-components/integration_blueprint/releases +[releases-shield]: https://img.shields.io/github/release/custom-components/octopusenergy.svg?style=for-the-badge +[releases]: https://github.com/custom-components/octopusenergy/releases [user_profile]: https://github.com/ludeeus diff --git a/setup.cfg b/setup.cfg index 4ee3655..4bab3d2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,5 +31,5 @@ not_skip = __init__.py force_sort_within_sections = true sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER default_section = THIRDPARTY -known_first_party = custom_components.integration_blueprint, tests +known_first_party = custom_components.octopusenergy, tests combine_as_imports = true diff --git a/tests/README.md b/tests/README.md index 90017d4..53322bc 100644 --- a/tests/README.md +++ b/tests/README.md @@ -20,5 +20,5 @@ This will install `homeassistant`, `pytest`, and `pytest-homeassistant-custom-co Command | Description ------- | ----------- `pytest tests/` | This will run all tests in `tests/` and tell you how many passed/failed -`pytest --durations=10 --cov-report term-missing --cov=custom_components.integration_blueprint tests` | This tells `pytest` that your target module to test is `custom_components.integration_blueprint` so that it can give you a [code coverage](https://en.wikipedia.org/wiki/Code_coverage) summary, including % of code that was executed and the line numbers of missed executions. +`pytest --durations=10 --cov-report term-missing --cov=custom_components.octopusenergy tests` | This tells `pytest` that your target module to test is `custom_components.octopusenergy` so that it can give you a [code coverage](https://en.wikipedia.org/wiki/Code_coverage) summary, including % of code that was executed and the line numbers of missed executions. `pytest tests/test_init.py -k test_setup_unload_and_reload_entry` | Runs the `test_setup_unload_and_reload_entry` test function located in `tests/test_init.py` diff --git a/tests/__init__.py b/tests/__init__.py index 0ba5e33..c241543 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -"""Tests for integration_blueprint integration.""" +"""Tests for octopusenergy integration.""" diff --git a/tests/conftest.py b/tests/conftest.py index f7835f6..656cc9c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,4 @@ -"""Global fixtures for integration_blueprint integration.""" +"""Global fixtures for octopusenergy integration.""" # Fixtures allow you to replace functions with a Mock object. You can perform # many options via the Mock to reflect a particular behavior from the original # function that you want to see without going through the function's actual logic. @@ -46,7 +46,7 @@ def skip_notifications_fixture(): def bypass_get_data_fixture(): """Skip calls to get data from API.""" with patch( - "custom_components.integration_blueprint.IntegrationBlueprintApiClient.async_get_data" + "custom_components.octopusenergy.OctopusEnergyApiClient.async_get_data" ): yield @@ -57,7 +57,7 @@ def bypass_get_data_fixture(): def error_get_data_fixture(): """Simulate error when retrieving data from API.""" with patch( - "custom_components.integration_blueprint.IntegrationBlueprintApiClient.async_get_data", + "custom_components.octopusenergy.OctopusEnergyApiClient.async_get_data", side_effect=Exception, ): yield diff --git a/tests/const.py b/tests/const.py index 83c523f..2288c31 100644 --- a/tests/const.py +++ b/tests/const.py @@ -1,5 +1,5 @@ -"""Constants for integration_blueprint tests.""" -from custom_components.integration_blueprint.const import CONF_PASSWORD, CONF_USERNAME +"""Constants for octopusenergy tests.""" +from custom_components.octopusenergy.const import CONF_PASSWORD, CONF_USERNAME # Mock config data to be used across multiple tests MOCK_CONFIG = {CONF_USERNAME: "test_username", CONF_PASSWORD: "test_password"} diff --git a/tests/test_api.py b/tests/test_api.py index 65ab7f3..9f3877e 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,17 +1,17 @@ -"""Tests for integration_blueprint api.""" +"""Tests for octopusenergy api.""" import asyncio import aiohttp from homeassistant.helpers.aiohttp_client import async_get_clientsession -from custom_components.integration_blueprint.api import IntegrationBlueprintApiClient +from custom_components.octopusenergy.api import OctopusEnergyApiClient async def test_api(hass, aioclient_mock, caplog): """Test API calls.""" # To test the api submodule, we first create an instance of our API client - api = IntegrationBlueprintApiClient("test", "test", async_get_clientsession(hass)) + api = OctopusEnergyApiClient("test", "test", async_get_clientsession(hass)) # Use aioclient_mock which is provided by `pytest_homeassistant_custom_components` # to mock responses to aiohttp requests. In this case we are telling the mock to diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 326eb16..954f6ec 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1,11 +1,11 @@ -"""Test integration_blueprint config flow.""" +"""Test octopusenergy config flow.""" from unittest.mock import patch from homeassistant import config_entries, data_entry_flow import pytest from pytest_homeassistant_custom_component.common import MockConfigEntry -from custom_components.integration_blueprint.const import ( +from custom_components.octopusenergy.const import ( BINARY_SENSOR, DOMAIN, PLATFORMS, @@ -23,10 +23,10 @@ from .const import MOCK_CONFIG def bypass_setup_fixture(): """Prevent setup.""" with patch( - "custom_components.integration_blueprint.async_setup", + "custom_components.octopusenergy.async_setup", return_value=True, ), patch( - "custom_components.integration_blueprint.async_setup_entry", + "custom_components.octopusenergy.async_setup_entry", return_value=True, ): yield diff --git a/tests/test_init.py b/tests/test_init.py index 4d46ec4..b8a2254 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -1,15 +1,15 @@ -"""Test integration_blueprint setup process.""" +"""Test octopusenergy setup process.""" from homeassistant.exceptions import ConfigEntryNotReady import pytest from pytest_homeassistant_custom_component.common import MockConfigEntry -from custom_components.integration_blueprint import ( +from custom_components.octopusenergy import ( BlueprintDataUpdateCoordinator, async_reload_entry, async_setup_entry, async_unload_entry, ) -from custom_components.integration_blueprint.const import DOMAIN +from custom_components.octopusenergy.const import DOMAIN from .const import MOCK_CONFIG @@ -26,7 +26,7 @@ async def test_setup_unload_and_reload_entry(hass, bypass_get_data): # Set up the entry and assert that the values set during setup are where we expect # them to be. Because we have patched the BlueprintDataUpdateCoordinator.async_get_data - # call, no code from custom_components/integration_blueprint/api.py actually runs. + # call, no code from custom_components/octopusenergy/api.py actually runs. assert await async_setup_entry(hass, config_entry) assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN] assert ( diff --git a/tests/test_switch.py b/tests/test_switch.py index a48d58e..ddc2c31 100644 --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -1,12 +1,12 @@ -"""Test integration_blueprint switch.""" +"""Test octopusenergy switch.""" from unittest.mock import call, patch from homeassistant.components.switch import SERVICE_TURN_OFF, SERVICE_TURN_ON from homeassistant.const import ATTR_ENTITY_ID from pytest_homeassistant_custom_component.common import MockConfigEntry -from custom_components.integration_blueprint import async_setup_entry -from custom_components.integration_blueprint.const import DEFAULT_NAME, DOMAIN, SWITCH +from custom_components.octopusenergy import async_setup_entry +from custom_components.octopusenergy.const import DEFAULT_NAME, DOMAIN, SWITCH from .const import MOCK_CONFIG @@ -21,7 +21,7 @@ async def test_switch_services(hass): # Functions/objects can be patched directly in test code as well and can be used to test # additional things, like whether a function was called or what arguments it was called with with patch( - "custom_components.integration_blueprint.IntegrationBlueprintApiClient.async_set_title" + "custom_components.octopusenergy.OctopusEnergyApiClient.async_set_title" ) as title_func: await hass.services.async_call( SWITCH,