示例#1
0
        def test_logout(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14124)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:14124/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                MESSAGE  = 'my message'

                self.mock_server.return_values['logout'] = expected_sess_id

                wds.logout(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['logout'][0]
                    )

                self.mock_server.exceptions['logout'] = coreExc.SessionNotFoundError(MESSAGE)

                try:
                    wds.logout(expected_sess_id)
                    self.fail('exception expected')
                except ZSI.FaultException as e:
                    self.assertEquals(
                        UserProcessingRFCodes.CLIENT_SESSION_NOT_FOUND_EXCEPTION_CODE,
                        e.fault.code[1]
                    )
                    self.assertEquals(
                        MESSAGE,
                        e.fault.string
                    )
            finally:
                self.rfs.stop()
示例#2
0
        def test_send_file(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14129)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:14129/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                expected_content = 'my file'
                expected_result  = 'hello there'
                file_info        = 'program'

                self.mock_server.return_values['send_file'   ]     = Command.Command(expected_result)

                result = wds.send_file(expected_sess_id, expected_content, file_info)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['send_file'][0]
                    )
                self.assertEquals(
                        expected_content,
                        self.mock_server.arguments['send_file'][1]
                    )
                self.assertEquals(
                        expected_result,
                        result.commandstring
                    )
            finally:
                self.rfs.stop()
示例#3
0
        def test_get_reservation_status(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14128)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:14128/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                NUMBER   = 5

                expected_confirmed_reservation = Reservation.ConfirmedReservation("reservation_id", NUMBER, "{}", 'http://www.weblab.deusto.es/...', '')
                self.mock_server.return_values['get_reservation_status'] = expected_confirmed_reservation

                confirmed_reservation = wds.get_reservation_status(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['get_reservation_status'][0]
                    )
                self.assertEquals(
                        expected_confirmed_reservation.time,    
                        confirmed_reservation.time
                    )
                self.assertEquals(
                        expected_confirmed_reservation.status,
                        confirmed_reservation.status
                    )
            finally:
                self.rfs.stop()
示例#4
0
        def test_list_experiments(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14125)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:14125/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")

                expected_experiments = self._generate_experiments_allowed()
                self.mock_server.return_values['list_experiments'] = expected_experiments

                experiments = wds.list_experiments(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['list_experiments'][0]
                    )

                self.assertEquals(
                        len(expected_experiments),
                        len(experiments)
                    )

                self.assertEquals(
                        expected_experiments[0].experiment.name,
                        experiments[0].experiment.name
                    )

                self.assertEquals(
                        expected_experiments[0].experiment.category.name,
                        experiments[0].experiment.category.name
                    )
            finally:
                self.rfs.stop()
示例#5
0
        def test_finished_experiment(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14127)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:14127/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")

                self.mock_server.return_values['finished_experiment'] = None

                wds.finished_experiment(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['finished_experiment'][0]
                    )
            finally:
                self.rfs.stop()
示例#6
0
        def test_get_user_information(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14131)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://*****:*****@deusto.es',
                        Role("student")
                    )
                self.mock_server.return_values['get_user_information'] = expected_user_information

                user_information = wds.get_user_information(expected_sess_id)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['get_user_information'][0]
                    )
                self.assertEquals(
                        expected_user_information.full_name,    
                        user_information.full_name
                    )
                self.assertEquals(
                        expected_user_information.login,    
                        user_information.login
                    )
                self.assertEquals(
                        expected_user_information.email,
                        user_information.email
                    )
                self.assertEquals(
                        expected_user_information.role.name,
                        user_information.role.name
                    )
            finally:
                self.rfs.stop()
示例#7
0
        def test_reserve_experiment(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14126)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:14126/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                NUMBER   = 5

                expected_confirmed_reservation = Reservation.ConfirmedReservation("reservation_id", NUMBER, "{}", 'http://www.weblab.deusto.es/...', '')
                expected_experiment_id = self._generate_two_experiments()[0].to_experiment_id()

                self._generate_experiments_allowed()
                self.mock_server.return_values['reserve_experiment'] = expected_confirmed_reservation

                confirmed_reservation = wds.reserve_experiment(expected_sess_id, expected_experiment_id, "{}", "{}")

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['reserve_experiment'][0]
                    )
                self.assertEquals(
                        expected_experiment_id.exp_name,
                        self.mock_server.arguments['reserve_experiment'][1].exp_name
                    )
                self.assertEquals(
                        expected_experiment_id.cat_name,
                        self.mock_server.arguments['reserve_experiment'][1].cat_name
                    )
                self.assertEquals(
                        expected_confirmed_reservation.time,    
                        confirmed_reservation.time
                    )
                self.assertEquals(
                        expected_confirmed_reservation.status,
                        confirmed_reservation.status
                    )
            finally:
                self.rfs.stop()
示例#8
0
        def test_send_command(self):
            self.configurationManager._set_value(self.rfs.FACADE_ZSI_PORT, 14130)
            self.rfs.start()
            try:
                wds = UserProcessingWebLabDeustoSOAP("http://localhost:14130/weblab/soap/")

                expected_sess_id = SessionId.SessionId("whatever")
                expected_command = Command.Command('my command')

                self.mock_server.return_values['send_command'] = expected_command

                wds.send_command(expected_sess_id, expected_command)

                self.assertEquals(
                        expected_sess_id.id,
                        self.mock_server.arguments['send_command'][0]
                    )
                self.assertEquals(
                        expected_command.get_command_string(),
                        self.mock_server.arguments['send_command'][1].get_command_string()
                    )
            finally:
                self.rfs.stop()