Exemple #1
0
 def test_close(self):
     _id = 1
     name = "test"
     brand = "mock"
     _type = "door"
     ip = "0.0.0.0"
     ml = MockListener()
     i = Openable(_id, name, brand, _type, ip, ml)
     i.close = MethCallLogger(i.close)
     i.close()
     assert (i.close.was_called)
Exemple #2
0
 def test_close(self):
     _id = 1
     name = "test"
     brand = "mock"
     _type = "door"
     ip = "0.0.0.0"
     ml = MockListener()
     i = Openable(_id, name, brand, _type, ip, ml)
     i.close = MethCallLogger(i.close)
     i.close()
     assert(i.close.was_called)
Exemple #3
0
 def test_setOpen(self):
     _id = 1
     name = "test"
     brand = "mock"
     _type = "door"
     ip = "0.0.0.0"
     ml = MockListener()
     percentage = 10
     i = Openable(_id, name, brand, _type, ip, ml)
     i.setOpen = MethCallLogger(i.setOpen, [percentage])
     i.setOpen(percentage)
     assert (i.setOpen.was_called)
Exemple #4
0
 def test_setOpen(self):
     _id = 1
     name = "test"
     brand = "mock"
     _type = "door"
     ip = "0.0.0.0"
     ml = MockListener()
     percentage = 10
     i = Openable(_id, name, brand, _type, ip, ml)
     i.setOpen = MethCallLogger(i.setOpen, [percentage])
     i.setOpen(percentage)
     assert(i.setOpen.was_called)
Exemple #5
0
    def test_stateChangesTriggered(self):
        db = MockDB()
        house = House(db)
        item = Openable(1, "item1", "mock", "door", "192.168.0.100", house.listenerManager)
        item.stateChanged = MethCallLogger(item.stateChanged)
        room = MockRoom(1, "lounge")
        room.items = {1: item}
        house.rooms = {1: room}

        item.close()

        # Sleep for 3 seconds to give the thread a chance to call checkForStateChange()
        time.sleep(3)

        self.assertTrue(item.stateChanged.was_called)
Exemple #6
0
 def test_setOpen_noarg(self):
     _id = 1
     name = "test"
     brand = "mock"
     _type = "door"
     ip = "0.0.0.0"
     ml = MockListener()
     i = Openable(_id, name, brand, _type, ip, ml)
     self.assertRaises(TypeError, i.setOpen)
Exemple #7
0
 def test_Openable_init_ordered(self):
     _id = 1
     name = "test"
     brand = "mock"
     _type = "door"
     ip = "0.0.0.0"
     ml = MockListener()
     i = Openable(_id, name, brand, _type, ip, ml)
     self.assertEqual(_id, i._id)
     self.assertEqual(name, i.name)
     self.assertEqual(brand, i.brand)
     self.assertEqual(_type, i._type)
     self.assertEqual(ip, i.ip)
     self.assertEqual(ml, i.listener)