Exemplo n.º 1
0
def test_TimeAtElevation_BadElevation(london):
    d = datetime.date(2016, 1, 4)
    with pytest.raises(ValueError):
        sun.time_at_elevation(london.observer, 20, d, SunDirection.RISING)
Exemplo n.º 2
0
def test_ElevationEqualsTimeAtElevation(elevation, london):
    o = london.observer
    td = today()
    et = sun.time_at_elevation(o, elevation, td)
    assert sun.elevation(o, et) == pytest.approx(elevation, abs=0.05)
Exemplo n.º 3
0
def test_TimeAtElevation_SunRisingBelowHorizon(london):
    d = datetime.date(2016, 1, 4)
    dt = sun.time_at_elevation(london.observer, -18, d, SunDirection.RISING)
    cdt = datetime.datetime(2016, 1, 4, 6, 0, 0, tzinfo=pytz.utc)
    assert datetime_almost_equal(dt, cdt, 300)
Exemplo n.º 4
0
def test_TimeAtElevation_GreaterThan180(london):
    d = datetime.date(2015, 12, 1)
    dt = sun.time_at_elevation(london.observer, 186, d, SunDirection.RISING)
    cdt = datetime.datetime(2015, 12, 1, 16, 34, tzinfo=pytz.utc)
    assert datetime_almost_equal(dt, cdt, 300)
Exemplo n.º 5
0
def test_TimeAtElevation_GreaterThan90(london):
    d = datetime.date(2016, 1, 4)
    dt = sun.time_at_elevation(london.observer, 166, d, SunDirection.RISING)
    cdt = datetime.datetime(2016, 1, 4, 13, 20, 0, tzinfo=pytz.utc)
    assert datetime_almost_equal(dt, cdt, 300)
Exemplo n.º 6
0
def test_TimeAtElevation_SunSetting(london):
    d = datetime.date(2016, 1, 4)
    dt = sun.time_at_elevation(london.observer, 14, d, SunDirection.SETTING)
    cdt = datetime.datetime(2016, 1, 4, 13, 20, 0, tzinfo=pytz.utc)
    assert datetime_almost_equal(dt, cdt, 300)
Exemplo n.º 7
0
def test_TimeAtElevation_NoDate(london):
    dt = sun.time_at_elevation(london.observer, 6, direction=SunDirection.RISING)
    cdt = datetime.datetime(2016, 1, 4, 9, 5, 0, tzinfo=pytz.utc)
    # Use error of 5 minutes as website has a rather coarse accuracy
    assert datetime_almost_equal(dt, cdt, 300)