Пример #1
0
Файл: test.py Проект: rogpal/paj
def test_lamp() :
    tz = tzlocal.get_localzone()
    place = Place(nkpCoord())
    place.findSunTimes()

    scheme = murklanScheme(place)
    lamp = Lamp(1)

    lamp.update(datetime.time(12, 10, 5, 0, tz), scheme[1])
    test_wait("Lamp expected to be OFF. Press enter to continue.")
    
    lamp.update(datetime.time(5, 50, 5, 0, tz), scheme[1])
    test_wait("Lamp expected to be OFF. Press enter to continue.")
    
    lamp.update(datetime.time(6, 30, 5, 0, tz), scheme[1])
    test_wait("Lamp expected to be ON. Press enter to continue.")
    
    lamp.update(datetime.time(8, 30, 5, 0, tz), scheme[1])
    test_wait("Lamp expected to be ON. Press enter to continue.")
    
    lamp.update(datetime.time(9, 10, 5, 0, tz), scheme[1])
    test_wait("Lamp expected to be OFF. Press enter to continue.")
    
    lamp.update(datetime.time(18, 40, 5, 0, tz), scheme[1])         # after sunset but within offset
    test_wait("Lamp expected to be OFF. Press enter to continue.")
    
    lamp.update(datetime.time(18, 59, 5, 0, tz), scheme[1])
    test_wait("Lamp expected to be ON. Press enter to continue.")
    
    lamp.update(datetime.time(22, 29, 5, 0, tz), scheme[1])
    test_wait("Lamp expected to be ON. Press enter to continue.")
    
    lamp.update(datetime.time(22, 30, 5, 0, tz), scheme[1])
    test_wait("Lamp expected to be OFF. Press enter to continue.")
Пример #2
0
Файл: test.py Проект: rogpal/paj
def test_interval() :
    tz = tzlocal.get_localzone()
    place = Place(nkpCoord())
    place.findSunTimes()
    interval = TimeInterval(SunriseTimepoint(datetime.timedelta(hours = 1), place),
                            AbsoluteTimepoint(datetime.time(13, 10, 5, 0, tz)))
    print str(interval.within(datetime.time(12, 10, 5, 0, tz))) + ' expected true.'
    print str(interval.within(datetime.time(13, 10, 6, 0, tz))) + ' expected false.'
    print str(interval.within(datetime.time(5, 10, 5, 0, tz))) + ' expected false.'
    print str(interval.within(datetime.time(8, 10, 5, 0, tz))) + ' expected true.'
Пример #3
0
import os
import lamp
import scheme
import place

nkp = place.Place(place.nkpCoord())
nkp.findSunTimes()
myscheme = scheme.murklanScheme(nkp)
lamp.update(myscheme)