|
33 | 33 | ) |
34 | 34 | from homeassistant.core import HomeAssistant |
35 | 35 | from homeassistant.exceptions import TemplateError |
36 | | -from homeassistant.helpers import ( |
37 | | - entity, |
38 | | - entity_registry as er, |
39 | | - issue_registry as ir, |
40 | | - template, |
41 | | - translation, |
42 | | -) |
| 36 | +from homeassistant.helpers import entity, entity_registry as er, template, translation |
43 | 37 | from homeassistant.helpers.entity_platform import EntityPlatform |
44 | 38 | from homeassistant.helpers.json import json_dumps |
45 | 39 | from homeassistant.helpers.template.render_info import ( |
@@ -1762,116 +1756,6 @@ async def test_config_entry_attr(hass: HomeAssistant) -> None: |
1762 | 1756 | ) |
1763 | 1757 |
|
1764 | 1758 |
|
1765 | | -async def test_issues(hass: HomeAssistant, issue_registry: ir.IssueRegistry) -> None: |
1766 | | - """Test issues function.""" |
1767 | | - # Test no issues |
1768 | | - info = render_to_info(hass, "{{ issues() }}") |
1769 | | - assert_result_info(info, {}) |
1770 | | - assert info.rate_limit is None |
1771 | | - |
1772 | | - # Test persistent issue |
1773 | | - ir.async_create_issue( |
1774 | | - hass, |
1775 | | - "test", |
1776 | | - "issue 1", |
1777 | | - breaks_in_ha_version="2023.7", |
1778 | | - is_fixable=True, |
1779 | | - is_persistent=True, |
1780 | | - learn_more_url="https://theuselessweb.com", |
1781 | | - severity="error", |
1782 | | - translation_key="abc_1234", |
1783 | | - translation_placeholders={"abc": "123"}, |
1784 | | - ) |
1785 | | - await hass.async_block_till_done() |
1786 | | - created_issue = issue_registry.async_get_issue("test", "issue 1") |
1787 | | - info = render_to_info(hass, "{{ issues()['test', 'issue 1'] }}") |
1788 | | - assert_result_info(info, created_issue.to_json()) |
1789 | | - assert info.rate_limit is None |
1790 | | - |
1791 | | - # Test fixed issue |
1792 | | - ir.async_delete_issue(hass, "test", "issue 1") |
1793 | | - await hass.async_block_till_done() |
1794 | | - info = render_to_info(hass, "{{ issues() }}") |
1795 | | - assert_result_info(info, {}) |
1796 | | - assert info.rate_limit is None |
1797 | | - |
1798 | | - issue = ir.IssueEntry( |
1799 | | - active=False, |
1800 | | - breaks_in_ha_version="2025.12", |
1801 | | - created=dt_util.utcnow(), |
1802 | | - data=None, |
1803 | | - dismissed_version=None, |
1804 | | - domain="test", |
1805 | | - is_fixable=False, |
1806 | | - is_persistent=False, |
1807 | | - issue_domain="test", |
1808 | | - issue_id="issue 2", |
1809 | | - learn_more_url=None, |
1810 | | - severity="warning", |
1811 | | - translation_key="abc_1234", |
1812 | | - translation_placeholders={"abc": "123"}, |
1813 | | - ) |
1814 | | - # Add non active issue |
1815 | | - issue_registry.issues[("test", "issue 2")] = issue |
1816 | | - # Test non active issue is omitted |
1817 | | - issue_entry = issue_registry.async_get_issue("test", "issue 2") |
1818 | | - assert issue_entry |
1819 | | - issue_2_created = issue_entry.created |
1820 | | - assert issue_entry and not issue_entry.active |
1821 | | - info = render_to_info(hass, "{{ issues() }}") |
1822 | | - assert_result_info(info, {}) |
1823 | | - assert info.rate_limit is None |
1824 | | - |
1825 | | - # Load and activate the issue |
1826 | | - ir.async_create_issue( |
1827 | | - hass=hass, |
1828 | | - breaks_in_ha_version="2025.12", |
1829 | | - data=None, |
1830 | | - domain="test", |
1831 | | - is_fixable=False, |
1832 | | - is_persistent=False, |
1833 | | - issue_domain="test", |
1834 | | - issue_id="issue 2", |
1835 | | - learn_more_url=None, |
1836 | | - severity="warning", |
1837 | | - translation_key="abc_1234", |
1838 | | - translation_placeholders={"abc": "123"}, |
1839 | | - ) |
1840 | | - activated_issue_entry = issue_registry.async_get_issue("test", "issue 2") |
1841 | | - assert activated_issue_entry and activated_issue_entry.active |
1842 | | - assert issue_2_created == activated_issue_entry.created |
1843 | | - info = render_to_info(hass, "{{ issues()['test', 'issue 2'] }}") |
1844 | | - assert_result_info(info, activated_issue_entry.to_json()) |
1845 | | - assert info.rate_limit is None |
1846 | | - |
1847 | | - |
1848 | | -async def test_issue(hass: HomeAssistant, issue_registry: ir.IssueRegistry) -> None: |
1849 | | - """Test issue function.""" |
1850 | | - # Test non existent issue |
1851 | | - info = render_to_info(hass, "{{ issue('non_existent', 'issue') }}") |
1852 | | - assert_result_info(info, None) |
1853 | | - assert info.rate_limit is None |
1854 | | - |
1855 | | - # Test existing issue |
1856 | | - ir.async_create_issue( |
1857 | | - hass, |
1858 | | - "test", |
1859 | | - "issue 1", |
1860 | | - breaks_in_ha_version="2023.7", |
1861 | | - is_fixable=True, |
1862 | | - is_persistent=True, |
1863 | | - learn_more_url="https://theuselessweb.com", |
1864 | | - severity="error", |
1865 | | - translation_key="abc_1234", |
1866 | | - translation_placeholders={"abc": "123"}, |
1867 | | - ) |
1868 | | - await hass.async_block_till_done() |
1869 | | - created_issue = issue_registry.async_get_issue("test", "issue 1") |
1870 | | - info = render_to_info(hass, "{{ issue('test', 'issue 1') }}") |
1871 | | - assert_result_info(info, created_issue.to_json()) |
1872 | | - assert info.rate_limit is None |
1873 | | - |
1874 | | - |
1875 | 1759 | def test_closest_function_to_coord(hass: HomeAssistant) -> None: |
1876 | 1760 | """Test closest function to coord.""" |
1877 | 1761 | hass.states.async_set( |
|
0 commit comments