def test_astral_dusk_correctness(location, dusk): location = Location(**location) date = datetime.date(*dusk[:3]) calculated_dusk = round_datetime(location.dusk(date)) assert calculated_dusk == datetime.datetime(*dusk, tzinfo=calculated_dusk.tzinfo)
def test_astral_sunset_correctness(location, sunset): location = Location(**location) date = datetime.date(*sunset[:3]) calculated_sunset = round_datetime(location.sunset(date)) assert calculated_sunset == datetime.datetime(*sunset, tzinfo=calculated_sunset.tzinfo)
def test_is_light(location, datetime, is_dark): datetime = LightAwareDatetime(pd.to_datetime(datetime), Location(**location)) assert datetime.is_dark() == is_dark
def test_geocoding(): locations = Location.geolocate("Durham") assert len(locations) == 6 assert Location(latitude=35.9940329, longitude=-78.898619) in locations
def test_elevation(): location = Location(name="Durham, NC", latitude=35.9940329, longitude=-78.898619) assert location.elevation == 120
def test_timezone(): location = Location(name="Durham, NC", latitude=35.9940329, longitude=-78.898619) assert location.timezone == "America/New_York"