def main() -> None: """Create the aiohttp session and run the example.""" logging.basicConfig(level=logging.DEBUG) client = Client(API_KEY, LATITUDE, LONGITUDE, altitude=ALTITUDE) start = time.time() try: # Get current UV info: _LOGGER.info("CURRENT UV DATA:") _LOGGER.info(client.uv_index()) # Get forecasted UV info: _LOGGER.info("FORECASTED UV DATA:") _LOGGER.info(client.uv_forecast()) # Get UV protection window: _LOGGER.info("UV PROTECTION WINDOW:") _LOGGER.info(client.uv_protection_window()) except OpenUvError as err: _LOGGER.info(err) end = time.time() _LOGGER.info("Execution time: %s seconds", end - start)
def test_uv_index_sync(aresponses, event_loop): """Test successfully retrieving UV index info (sync).""" aresponses.add( "api.openuv.io", "/api/v1/uv", "get", aresponses.Response( text=load_fixture("uv_index_response.json"), status=200, headers={"Content-Type": "application/json"}, ), ) client = Client( TEST_API_KEY, TEST_LATITUDE, TEST_LONGITUDE, altitude=TEST_ALTITUDE, event_loop=event_loop, ) data = client.uv_index() assert data["result"]["uv"] == 8.2342