core/tests/components/geo_location/test_init.py

25 lines
742 B
Python
Raw Normal View History

"""The tests for the geolocation component."""
import pytest
Geo Location component (#15953) * initial working version of a geo location component and georss platform * ensure that custom attributes don't override built-in ones * bugfixes and tests * fixing tests because of introduction of new component using same fixture * improving test cases * removing potentially unavailable attribute from debug message output * completing test suite * cleaning up debug messages; sorting entries in group view by distance * ability to define the desired state attribute and corresponding unit of measurement; sort devices in group by configured state; find centroid for map if event is defined by polygon; updated tests * sort entries in group; code clean-ups * fixing indentation * added requirements of new component and platform * fixed various lint issues * fixed more lint issues * introducing demo geo location platform; refactored geo location component and geo rss platform to fit * removing geo rss events platform; added unit tests for geo location platform and demo platform * reverting change in debug message for feedreader to avoid confusion with new geo location component * updated requirements after removing georss platform * removed unused imports * fixing a lint issue and a test case * simplifying component code; moving code into demo platform; fixing tests * removed grouping from demo platform; small refactorings * automating the entity id generation (the use of an entity namespace achieves the same thing) * undoing changes made for the georss platform * simplified test cases * small tweaks to test case * rounding all state attribute values * fixing lint; removing distance from state attributes * fixed test * renamed add_devices to add_entities; tweaked test to gain more control over the timed update in the demo platform * reusing utcnow variable instead of patched method * fixed test by avoiding to make assumptions about order of list of entity ids * adding test for the geo location event class
2018-08-30 11:58:23 +00:00
from homeassistant.components import geo_location
from homeassistant.components.geo_location import GeolocationEvent
Geo Location component (#15953) * initial working version of a geo location component and georss platform * ensure that custom attributes don't override built-in ones * bugfixes and tests * fixing tests because of introduction of new component using same fixture * improving test cases * removing potentially unavailable attribute from debug message output * completing test suite * cleaning up debug messages; sorting entries in group view by distance * ability to define the desired state attribute and corresponding unit of measurement; sort devices in group by configured state; find centroid for map if event is defined by polygon; updated tests * sort entries in group; code clean-ups * fixing indentation * added requirements of new component and platform * fixed various lint issues * fixed more lint issues * introducing demo geo location platform; refactored geo location component and geo rss platform to fit * removing geo rss events platform; added unit tests for geo location platform and demo platform * reverting change in debug message for feedreader to avoid confusion with new geo location component * updated requirements after removing georss platform * removed unused imports * fixing a lint issue and a test case * simplifying component code; moving code into demo platform; fixing tests * removed grouping from demo platform; small refactorings * automating the entity id generation (the use of an entity namespace achieves the same thing) * undoing changes made for the georss platform * simplified test cases * small tweaks to test case * rounding all state attribute values * fixing lint; removing distance from state attributes * fixed test * renamed add_devices to add_entities; tweaked test to gain more control over the timed update in the demo platform * reusing utcnow variable instead of patched method * fixed test by avoiding to make assumptions about order of list of entity ids * adding test for the geo location event class
2018-08-30 11:58:23 +00:00
from homeassistant.setup import async_setup_component
async def test_setup_component(hass):
"""Simple test setup of component."""
result = await async_setup_component(hass, geo_location.DOMAIN, {})
Geo Location component (#15953) * initial working version of a geo location component and georss platform * ensure that custom attributes don't override built-in ones * bugfixes and tests * fixing tests because of introduction of new component using same fixture * improving test cases * removing potentially unavailable attribute from debug message output * completing test suite * cleaning up debug messages; sorting entries in group view by distance * ability to define the desired state attribute and corresponding unit of measurement; sort devices in group by configured state; find centroid for map if event is defined by polygon; updated tests * sort entries in group; code clean-ups * fixing indentation * added requirements of new component and platform * fixed various lint issues * fixed more lint issues * introducing demo geo location platform; refactored geo location component and geo rss platform to fit * removing geo rss events platform; added unit tests for geo location platform and demo platform * reverting change in debug message for feedreader to avoid confusion with new geo location component * updated requirements after removing georss platform * removed unused imports * fixing a lint issue and a test case * simplifying component code; moving code into demo platform; fixing tests * removed grouping from demo platform; small refactorings * automating the entity id generation (the use of an entity namespace achieves the same thing) * undoing changes made for the georss platform * simplified test cases * small tweaks to test case * rounding all state attribute values * fixing lint; removing distance from state attributes * fixed test * renamed add_devices to add_entities; tweaked test to gain more control over the timed update in the demo platform * reusing utcnow variable instead of patched method * fixed test by avoiding to make assumptions about order of list of entity ids * adding test for the geo location event class
2018-08-30 11:58:23 +00:00
assert result
async def test_event(hass):
"""Simple test of the geolocation event class."""
entity = GeolocationEvent()
Geo Location component (#15953) * initial working version of a geo location component and georss platform * ensure that custom attributes don't override built-in ones * bugfixes and tests * fixing tests because of introduction of new component using same fixture * improving test cases * removing potentially unavailable attribute from debug message output * completing test suite * cleaning up debug messages; sorting entries in group view by distance * ability to define the desired state attribute and corresponding unit of measurement; sort devices in group by configured state; find centroid for map if event is defined by polygon; updated tests * sort entries in group; code clean-ups * fixing indentation * added requirements of new component and platform * fixed various lint issues * fixed more lint issues * introducing demo geo location platform; refactored geo location component and geo rss platform to fit * removing geo rss events platform; added unit tests for geo location platform and demo platform * reverting change in debug message for feedreader to avoid confusion with new geo location component * updated requirements after removing georss platform * removed unused imports * fixing a lint issue and a test case * simplifying component code; moving code into demo platform; fixing tests * removed grouping from demo platform; small refactorings * automating the entity id generation (the use of an entity namespace achieves the same thing) * undoing changes made for the georss platform * simplified test cases * small tweaks to test case * rounding all state attribute values * fixing lint; removing distance from state attributes * fixed test * renamed add_devices to add_entities; tweaked test to gain more control over the timed update in the demo platform * reusing utcnow variable instead of patched method * fixed test by avoiding to make assumptions about order of list of entity ids * adding test for the geo location event class
2018-08-30 11:58:23 +00:00
assert entity.state is None
assert entity.distance is None
assert entity.latitude is None
assert entity.longitude is None
with pytest.raises(NotImplementedError):
assert entity.source is None