def testName(): c = City() assert c.name == 'Greenwich' c.name = 'London' assert c.name == 'London' c.name = 'Köln' assert c.name == 'Köln'
def test_create_city(): lat = 43.658931 lon = -79.380341 city = City(("Toronto","Canada",lat,-lon,"US/Eastern")) date = datetime(2012,1,9) sun = city.sun(date=date,local=False) pred = sun['sunrise'].replace(tzinfo=None) true = datetime(2012,1,9,12,50) _check(pred,true) pred = sun['sunset'].replace(tzinfo=None) true = datetime(2012,1,9,21,59) _check(pred,true)
def compare_finders(): az_correction = defaultdict(list) el_correction = defaultdict(list) empirical = EmpiricalSolarFinder(jeffs_data) upland = City(("Upland", "USA", "40°28'N", "85°30'W", "US/Eastern")) astral = AstralSolarFinder(upland) delta = datetime.timedelta(minutes=DELTA_MINUTES) from_time = datetime.datetime(2012, 8, 21, 9, 0, tzinfo=upland.tz) to_time = datetime.datetime(2012, 8, 21, 17, 0, tzinfo=upland.tz) sunrise = upland.sunrise(from_time) sunset = upland.sunset(from_time) when = from_time while when <= to_time: day_night = 'DAY' if sunrise < when < sunset else 'NIGHT' empirical_az, empirical_el = empirical.find(when) astral_az, astral_el = astral.find(when) if MODE == 'Full': print "{0:%H:%M},'EMPIRICAL',{1},{2},'ASTRAL',{3},{4},'DELTA',{5},{6},'{7}'".format( when, empirical_az, empirical_el, astral_az, astral_el, empirical_az - astral_az, empirical_el - astral_el, day_night) elif MODE == 'Delta': # print "{0},{1},{2},{3}".format(astral_az, empirical_az, astral_el, empirical_el) az_correction[astral_az].append(empirical_az) el_correction[astral_el].append(empirical_el) else: raise ValueException() when += delta if MODE == 'Delta': average_value_by_key('AZ', az_correction) average_value_by_key('EL', el_correction)
def testTzError(): c = City() c.tz = 1
def testAzimuth(): c = City() c.solar_azimuth()
def testElevation(): c = City() c.solar_elevation()
def testSunset(): c = City() c.sunset()
def testDusk(): c = City() c.dusk()
def testSolarNoon(): c = City() c.solar_noon()
def testSunrise(): c = City() c.sunrise()
def testDawn(): c = City() c.dawn()
def testTimezone(): c = City() assert c.tz == pytz.timezone('Europe/London') c.timezone='Europe/Stockholm' assert c.tz == pytz.timezone('Europe/Stockholm')
def testTimezoneName(): c = City() assert c.timezone == 'Europe/London' c.name = 'Asia/Riyadh' assert c.name == 'Asia/Riyadh'
def testCountry(): c = City() assert c.country == 'England' c.country = 'Australia' assert c.country == 'Australia'