当前位置: 首页>>代码示例>>Python>>正文


Python WebLabDeustoClient.get_user_information方法代码示例

本文整理汇总了Python中weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient.get_user_information方法的典型用法代码示例。如果您正苦于以下问题:Python WebLabDeustoClient.get_user_information方法的具体用法?Python WebLabDeustoClient.get_user_information怎么用?Python WebLabDeustoClient.get_user_information使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient的用法示例。


在下文中一共展示了WebLabDeustoClient.get_user_information方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: IntegrationNoConcurrencyTestCase

# 需要导入模块: from weblab.core.coordinator.clients.weblabdeusto import WebLabDeustoClient [as 别名]
# 或者: from weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient import get_user_information [as 别名]
class IntegrationNoConcurrencyTestCase(object):
    def setUp(self):
        self.global_config = load_dir(self.DEPLOYMENT_DIR)

        self.process_handlers = []
        for process in self.PROCESSES:
            process_handler = self.global_config.load_process('myhost', process)
            self.process_handlers.append(process_handler)

        self.core_server       = GLOBAL_REGISTRY[self.CORE_ADDRESS]
        self.experiment_dummy1 = GLOBAL_REGISTRY[self.EXPERIMENT_DUMMY1]
        self.experiment_dummy2 = GLOBAL_REGISTRY[self.EXPERIMENT_DUMMY2]

        self.core_config = self.core_server.config

        self.client = WebLabDeustoClient('http://localhost:%s/weblab/' % self.core_config[configuration_doc.CORE_FACADE_PORT])

    def tearDown(self):
        GLOBAL_REGISTRY.clear()

        for process_handler in self.process_handlers:
            process_handler.stop()

    def test_simple_single_uses(self):
        for _ in range(1):
            self._single_use()
        self._single_use()
        self._single_use()

    def _single_use(self, logout = True, plus_async_use = True):
        """
        Will use an experiment.
        @param logout If true, the user will be logged out after the use. Otherwise not.
        @param plus_async_use If true, after using the experiment synchronously, it will use it
        again using the asynchronous versions of the send_command and send_file requests.
        """
        self._single_sync_use(logout)
        if plus_async_use:
            self._single_async_use(logout)

    def _single_sync_use(self, logout = True):
        session_id, reservation_id = self._get_reserved()

        CONTENT = "content of the program FPGA"
        response = self.client.send_file(reservation_id, ExperimentUtil.serialize(CONTENT), 'program')
        self.assertEquals(response.commandstring, 'ack')

        response = self.client.send_command(reservation_id, Command.Command("STATE"))
        self.assertEquals(response.commandstring, 'STATE')

        response = self.client.send_command(reservation_id, Command.Command("ChangeSwitch on 0"))
        self.assertEquals(response.commandstring, "ChangeSwitch on 0")

        if logout:
            self.client.logout(session_id)

    def _get_reserved(self):
        session_id = self.client.login('intstudent1', 'password')

        user_information = self.client.get_user_information(session_id)
        self.assertEquals( 'intstudent1', user_information.login) 
        self.assertEquals( 'Name of integration test 1', user_information.full_name)
        self.assertEquals( '[email protected]', user_information.email)

        experiments = self.client.list_experiments(session_id)
        self.assertEquals( 2, len(experiments))

        dummy1_experiments = [ exp.experiment for exp in experiments if exp.experiment.name == 'dummy1' ]
        self.assertEquals( len(dummy1_experiments), 1)

        dummy1_experiment = dummy1_experiments[0]

        status = self.client.reserve_experiment(session_id, dummy1_experiment.to_experiment_id(), "{}", "{}")

        reservation_id = status.reservation_id

        # wait until it is reserved
        short_time = 0.1

        # Time extended from 9.0 to 15.0 because at times the test failed, possibly for that reason.
        times      = 15.0 / short_time

        while times > 0:
            new_status = self.client.get_reservation_status(reservation_id)
            if not isinstance(new_status, Reservation.WaitingConfirmationReservation) and not isinstance(new_status, Reservation.WaitingReservation):
                break
            times -= 1
            time.sleep(short_time)
        reservation = self.client.get_reservation_status(reservation_id)
        self.assertTrue(
                isinstance(reservation, Reservation.ConfirmedReservation),
                "Reservation %s is not Confirmed, as expected by this time" % reservation
            )
        return session_id, reservation_id

    def _single_async_use(self, logout = True):
        session_id, reservation_id = self._get_reserved()

        # send the program again, but asynchronously. Though this should work, it is not really very customary
        # to send_file more than once in the same session. In fact, it is a feature which might get removed in
#.........这里部分代码省略.........
开发者ID:zstars,项目名称:weblabdeusto,代码行数:103,代码来源:test_no_concurrency.py


注:本文中的weblab.core.coordinator.clients.weblabdeusto.WebLabDeustoClient.get_user_information方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。