Beispiel #1
0
    def test_recv_task_resp(self):
        # ProgramTask
        self.power_supply.send_task(ProgramTask(name=TaskName.END))
        self.assertEqual(
            self.power_supply.recv_task_resp(),
            TaskResponse(status=Status.ERROR,
                         value={'error': 'Not Implemented'}))

        # SystemTask
        self.power_supply.send_task(SystemTask(name=TaskName.ACTIVE))
        self.assertEqual(self.power_supply.recv_task_resp(),
                         TaskResponse(status=Status.OK, value=None))

        # EntityTask
        self.power_supply.send_task(Task(name=TaskName.GET_INFO))
        self.assertEqual(
            self.power_supply.recv_task_resp(),
            TaskResponse(status=Status.OK,
                         value={
                             'info': {
                                 'uuid': str(self.power_supply.uuid),
                                 'identifier':
                                 type(self.power_supply).identifier,
                                 'type': {
                                     'actuator': ['POWER'],
                                     'sensor': [],
                                     'accessor': []
                                 },
                             }
                         }))
Beispiel #2
0
    def test_send_task(self):
        # ProgramTask
        self.power_supply.send_task(ProgramTask(name=TaskName.END))

        # SystemTask
        self.power_supply.send_task(SystemTask(name=TaskName.ACTIVE))

        # EntityTask
        self.power_supply.send_task(Task(name=TaskName.GET_INFO))
Beispiel #3
0
    def test_send_task(self):
        # SystemTask
        self.assertRaises(
            FunctionUnsupportedError,
            lambda: self.light.send_task(SystemTask(name=TaskName.ACTIVE)))

        # EntityTask
        self.assertRaises(
            FunctionUnsupportedError,
            lambda: self.light.send_task(Task(name=TaskName.GET_INFO)))

        # ProgramTask
        self.assertRaises(
            FunctionUnsupportedError,
            lambda: self.light.send_task(ProgramTask(name=TaskName.END)))
Beispiel #4
0
    def test_recv_task_resp(self):
        self.assertRaises(
            FunctionUnsupportedError, lambda: self.light.send_task(
                SystemTask(name=TaskName.SET_POWER,
                           value={'power': ElectricPower(110)})))
        self.assertRaises(FunctionUnsupportedError,
                          lambda: self.light.recv_task_resp())

        # SystemTask
        self.assertRaises(
            FunctionUnsupportedError,
            lambda: self.light.send_task(SystemTask(name=TaskName.ACTIVE)))
        self.assertRaises(FunctionUnsupportedError,
                          lambda: self.light.recv_task_resp())

        # EntityTask
        self.assertRaises(
            FunctionUnsupportedError,
            lambda: self.light.send_task(Task(name=TaskName.GET_INFO)))
        self.assertRaises(FunctionUnsupportedError,
                          lambda: self.light.recv_task_resp())
Beispiel #5
0
    def test_recv_task_resp(self):
        self.light.send_task(
            SystemTask(name=TaskName.SET_POWER,
                       value={'power': ElectricPower(110)}))
        self.assertEqual(TaskResponse(Status.OK), self.light.recv_task_resp())

        self.light.send_task(SystemTask(name=TaskName.ACTIVE))
        self.assertEqual(TaskResponse(Status.OK), self.light.recv_task_resp())

        self.light.send_task(Task(name=TaskName.GET_INFO))
        self.assertEqual(
            TaskResponse(status=Status.OK,
                         value={
                             'info': {
                                 'uuid': str(self.light.uuid),
                                 'identifier': type(self.light).identifier,
                                 'type': {
                                     'actuator': ['POWER'],
                                     'sensor': [],
                                     'accessor': []
                                 },
                             }
                         }), self.light.recv_task_resp())
Beispiel #6
0
    def test_send_task(self):
        # SystemTask
        self.light.send_task(SystemTask(name=TaskName.ACTIVE))

        # EntityTask
        self.light.send_task(Task(name=TaskName.GET_INFO))
Beispiel #7
0
    def test_active_deactivate(self):
        self.light.send_task(
            SystemTask(name=TaskName.SET_POWER,
                       value={'power': ElectricPower(110)}))
        self.assertEqual(self.light.recv_task_resp(),
                         TaskResponse(status=Status.OK, value=None))

        self.light.send_task(SystemTask(name=TaskName.DEACTIVATE))
        self.assertEqual(self.light.recv_task_resp(),
                         TaskResponse(status=Status.OK, value=None))

        self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO))
        self.assertFalse(
            self.light.recv_task_resp().value['system_info']['active'])

        self.light.send_task(SystemTask(name=TaskName.ACTIVE))
        self.assertEqual(self.light.recv_task_resp(),
                         TaskResponse(status=Status.OK, value=None))

        self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO))
        self.assertTrue(
            self.light.recv_task_resp().value['system_info']['active'])

        self.light.send_task(SystemTask(name=TaskName.DEACTIVATE))
        self.assertEqual(self.light.recv_task_resp(),
                         TaskResponse(status=Status.OK, value=None))
        self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO))
        self.assertFalse(
            self.light.recv_task_resp().value['system_info']['active'])

        self.light.send_task(Task(name=TaskName.GET_INFO))
        self.assertEqual(
            self.light.recv_task_resp(),
            TaskResponse(status=Status.OK,
                         value={
                             'info': {
                                 'uuid': str(self.light.uuid),
                                 'identifier': type(self.light).identifier,
                                 'type': {
                                     'actuator': ['POWER'],
                                     'sensor': [],
                                     'accessor': []
                                 },
                             }
                         }))

        self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO))
        self.assertFalse(
            self.light.recv_task_resp().value['system_info']['active'])

        self.light.send_task(SystemTask(name=TaskName.DEACTIVATE))
        self.assertEqual(self.light.recv_task_resp(),
                         TaskResponse(status=Status.OK, value=None))

        self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO))
        self.assertFalse(
            self.light.recv_task_resp().value['system_info']['active'])

        self.light.send_task(SystemTask(name=TaskName.ACTIVE))
        self.assertEqual(self.light.recv_task_resp(),
                         TaskResponse(status=Status.OK, value=None))

        self.light.send_task(SystemTask(name=TaskName.GET_SYSTEM_INFO))
        self.assertTrue(
            self.light.recv_task_resp().value['system_info']['active'])

        self.light.send_task(Task(name=TaskName.GET_INFO))
        self.assertEqual(
            self.light.recv_task_resp(),
            TaskResponse(status=Status.OK,
                         value={
                             'info': {
                                 'uuid': str(self.light.uuid),
                                 'identifier': type(self.light).identifier,
                                 'type': {
                                     'actuator': ['POWER'],
                                     'sensor': [],
                                     'accessor': []
                                 },
                             }
                         }))