예제 #1
0
파일: motion.py 프로젝트: E3Dev/pytomation
 def test_motion_delay_from_interface(self):
     i = Mock()
     m = Motion(devices=i,
                delay={
                       Attribute.COMMAND: Command.STILL,
                       Attribute.SECS: 2,
                       })
     m.command(command=Command.MOTION, source=i)
     self.assertEqual(m.state, State.MOTION)
     m.command(command=Command.STILL, source=i)
     self.assertEqual(m.state, State.MOTION)
     time.sleep(3)
     self.assertEqual(m.state, State.STILL)
예제 #2
0
파일: motion.py 프로젝트: ver007/pytomation
 def test_motion_delay_from_interface(self):
     i = Mock()
     m = Motion(devices=i,
                delay={
                    Attribute.COMMAND: Command.STILL,
                    Attribute.SECS: 2,
                })
     m.command(command=Command.MOTION, source=i)
     self.assertEqual(m.state, State.MOTION)
     m.command(command=Command.STILL, source=i)
     self.assertEqual(m.state, State.MOTION)
     time.sleep(3)
     self.assertEqual(m.state, State.STILL)
예제 #3
0
 def test_light_scenario1(self):
     m = Motion()
     l = Light(
             address=(49, 6), 
             devices=m,
             mapped={
                     Attribute.COMMAND: Command.MOTION,
                     Attribute.SECS: 30*60
                     },
             ignore=({
                     Attribute.COMMAND: Command.STILL
                     },
                     {
                     Attribute.COMMAND: Command.DARK
                     },
                 ),
             name='Lamp',
             )
     self.assertEqual(l.state, State.UNKNOWN)
     m.command(command=State.ON, source=None)
     self.assertEqual(l.state, State.UNKNOWN)
예제 #4
0
파일: light.py 프로젝트: ver007/pytomation
 def test_light_scenario1(self):
     m = Motion()
     l = Light(
         address=(49, 6),
         devices=m,
         mapped={
             Attribute.COMMAND: Command.MOTION,
             Attribute.SECS: 30 * 60
         },
         ignore=(
             {
                 Attribute.COMMAND: Command.STILL
             },
             {
                 Attribute.COMMAND: Command.DARK
             },
         ),
         name='Lamp',
     )
     self.assertEqual(l.state, State.UNKNOWN)
     m.command(command=State.ON, source=None)
     self.assertEqual(l.state, State.UNKNOWN)
예제 #5
0
class MotionTests(TestCase):
    
    def setUp(self):
        self.interface = Mock()
        self.interface.state = State.UNKNOWN
        self.device = Motion('D1', self.interface)

    def test_instantiation(self):
        self.assertIsNotNone(self.device,
                             'Motion Device could not be instantiated')

    def test_motion_motion(self):
        self.assertEqual(self.device.state, State.UNKNOWN)
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.ON)
        self.assertEqual(self.device.state, State.MOTION)
#        self.device._on_command('D1', State.OFF)
        self.device.command(Command.STILL, source=self.interface)
        self.assertEqual(self.device.state, State.STILL)

    def test_motion_ignore(self):
        self.device = Motion('D1', devices=(self.interface), ignore={
                                                                      'command': Command.STILL,
                                                                      },
                              )
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.ON, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.OFF, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        
    def test_motion_on(self):
        m = Motion()
        m.command(command=Command.ON, source=None)
        self.assertEqual(m.state, State.MOTION)        
예제 #6
0
파일: motion.py 프로젝트: E3Dev/pytomation
 def test_motion_retrigger(self):
     i = Mock()
     m = Motion(devices=i,
                retrigger_delay={
                                 Attribute.SECS: 2,
                                 },
                )
     s = Light(devices=m)
     s.off()
     self.assertEqual(s.state, State.OFF)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.ON)
     s.off()
     self.assertEqual(s.state, State.OFF)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.OFF)
     time.sleep(3)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.ON)
예제 #7
0
파일: motion.py 프로젝트: ver007/pytomation
 def test_motion_retrigger(self):
     i = Mock()
     m = Motion(
         devices=i,
         retrigger_delay={
             Attribute.SECS: 2,
         },
     )
     s = Light(devices=m)
     s.off()
     self.assertEqual(s.state, State.OFF)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.ON)
     s.off()
     self.assertEqual(s.state, State.OFF)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.OFF)
     time.sleep(3)
     m.command(command=Command.ON, source=i)
     self.assertEqual(s.state, State.ON)
예제 #8
0
 def test_motion_on(self):
     m = Motion()
     m.command(command=Command.ON, source=None)
     self.assertEqual(m.state, State.MOTION)        
예제 #9
0
파일: motion.py 프로젝트: E3Dev/pytomation
class MotionTests(TestCase):
    
    def setUp(self):
        self.interface = Mock()
        self.interface.state = State.UNKNOWN
        self.device = Motion('D1', self.interface)

    def test_instantiation(self):
        self.assertIsNotNone(self.device,
                             'Motion Device could not be instantiated')

    def test_motion_motion(self):
        self.assertEqual(self.device.state, State.UNKNOWN)
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.ON)
        self.assertEqual(self.device.state, State.MOTION)
#        self.device._on_command('D1', State.OFF)
        self.device.command(Command.STILL, source=self.interface)
        self.assertEqual(self.device.state, State.STILL)

    def test_motion_ignore(self):
        self.device = Motion('D1', devices=(self.interface), ignore={
                                                                      'command': Command.STILL,
                                                                      },
                              )
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.ON, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        self.device.command(Command.MOTION, source=self.interface)
#        self.device._on_command('D1', State.OFF, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        
    def test_motion_on(self):
        m = Motion()
        m.command(command=Command.ON, source=None)
        self.assertEqual(m.state, State.MOTION)        

    def test_motion_delay_from_interface(self):
        i = Mock()
        m = Motion(devices=i,
                   delay={
                          Attribute.COMMAND: Command.STILL,
                          Attribute.SECS: 2,
                          })
        m.command(command=Command.MOTION, source=i)
        self.assertEqual(m.state, State.MOTION)
        m.command(command=Command.STILL, source=i)
        self.assertEqual(m.state, State.MOTION)
        time.sleep(3)
        self.assertEqual(m.state, State.STILL)

    def test_motion_retrigger(self):
        i = Mock()
        m = Motion(devices=i,
                   retrigger_delay={
                                    Attribute.SECS: 2,
                                    },
                   )
        s = Light(devices=m)
        s.off()
        self.assertEqual(s.state, State.OFF)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.ON)
        s.off()
        self.assertEqual(s.state, State.OFF)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.OFF)
        time.sleep(3)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.ON)
예제 #10
0
파일: motion.py 프로젝트: ver007/pytomation
class MotionTests(TestCase):
    def setUp(self):
        self.interface = Mock()
        self.interface.state = State.UNKNOWN
        self.device = Motion('D1', self.interface)

    def test_instantiation(self):
        self.assertIsNotNone(self.device,
                             'Motion Device could not be instantiated')

    def test_motion_motion(self):
        self.assertEqual(self.device.state, State.UNKNOWN)
        self.device.command(Command.MOTION, source=self.interface)
        #        self.device._on_command('D1', State.ON)
        self.assertEqual(self.device.state, State.MOTION)
        #        self.device._on_command('D1', State.OFF)
        self.device.command(Command.STILL, source=self.interface)
        self.assertEqual(self.device.state, State.STILL)

    def test_motion_ignore(self):
        self.device = Motion(
            'D1',
            devices=(self.interface),
            ignore={
                'command': Command.STILL,
            },
        )
        self.device.command(Command.MOTION, source=self.interface)
        #        self.device._on_command('D1', State.ON, self.interface)
        self.assertEqual(self.device.state, State.MOTION)
        self.device.command(Command.MOTION, source=self.interface)
        #        self.device._on_command('D1', State.OFF, self.interface)
        self.assertEqual(self.device.state, State.MOTION)

    def test_motion_on(self):
        m = Motion()
        m.command(command=Command.ON, source=None)
        self.assertEqual(m.state, State.MOTION)

    def test_motion_delay_from_interface(self):
        i = Mock()
        m = Motion(devices=i,
                   delay={
                       Attribute.COMMAND: Command.STILL,
                       Attribute.SECS: 2,
                   })
        m.command(command=Command.MOTION, source=i)
        self.assertEqual(m.state, State.MOTION)
        m.command(command=Command.STILL, source=i)
        self.assertEqual(m.state, State.MOTION)
        time.sleep(3)
        self.assertEqual(m.state, State.STILL)

    def test_motion_retrigger(self):
        i = Mock()
        m = Motion(
            devices=i,
            retrigger_delay={
                Attribute.SECS: 2,
            },
        )
        s = Light(devices=m)
        s.off()
        self.assertEqual(s.state, State.OFF)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.ON)
        s.off()
        self.assertEqual(s.state, State.OFF)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.OFF)
        time.sleep(3)
        m.command(command=Command.ON, source=i)
        self.assertEqual(s.state, State.ON)
예제 #11
0
파일: motion.py 프로젝트: ver007/pytomation
 def test_motion_on(self):
     m = Motion()
     m.command(command=Command.ON, source=None)
     self.assertEqual(m.state, State.MOTION)