• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_awa_server_write.server_write函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test_awa_server_write.server_write函数的典型用法代码示例。如果您正苦于以下问题:Python server_write函数的具体用法?Python server_write怎么用?Python server_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_read_write_only_resource

    def test_read_write_only_resource(self):
        # test that we can't read from a write only resource
        customObjects = (
            CustomObject("Object1001", 1001, False, "single", (
                    CustomResource("Resource100", 100, "string",  "single", "mandatory", "w"),
            )),
        )

        #define and set the write only object
        params = tools_common.create_define_command(customObjects)
        result = client_define(self.config, *params)
        self.assertEqual(0, result.code)
        result = server_define(self.config, *params)
        self.assertEqual(0, result.code)

        result = server_write(self.config, "--create /1001/0")
        self.assertEqual("", result.stderr)
        self.assertEqual("", result.stdout)
        self.assertEqual(0, result.code)

        result = server_write(self.config, "/1001/0/100=abc")
        self.assertEqual("", result.stderr)
        self.assertEqual("", result.stdout)
        self.assertEqual(0, result.code)
        
        expectedStdout = ""
        expectedStderr = "AwaServerReadOperation_Perform failed\nFailed to read from path /1001/0/100: AwaLWM2MError_MethodNotAllowed\n"
        expectedCode = 1

        # attempt to read a write only object, should fail
        result = server_read(self.config, "/1001/0/100")
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:34,代码来源:test_awa_server.py


示例2: test_read_write_multiple_resources_same_instance

    def test_read_write_multiple_resources_same_instance(self):
        # test that multiple resources from the same instance can be set and retrieved with a single command
        timezone = "ACME Corp."
        currentTime = 123456789

        result = server_write(self.config,
                     "/3/0/15=\"%s\"" % (timezone,),
                     "/3/0/13=%d" % (currentTime,))
        
        self.assertEqual("", result.stderr)
        self.assertEqual("", result.stdout)
        self.assertEqual(0, result.code)

        expectedStdout = "Device[/3/0]:\n    Timezone[/3/0/15]: %s\n"% (timezone, )
        expectedStderr = ""
        expectedCode = 0
        #result = server_read(self.config, "/3/0/15", "/3/0/13")
        result = server_read(self.config, "/3/0/15")
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedCode, result.code)
        
        expectedStdout = "Device[/3/0]:\n    CurrentTime[/3/0/13]: %s\n"% (currentTime, )
        
        result = server_read(self.config, "/3/0/13")
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:28,代码来源:test_awa_server.py


示例3: test_client_subscribe_resource_server_write

    def test_client_subscribe_resource_server_write(self):
        # test that the client can subscribe to a resource and receive a notification
        # when that resource is changed by the server through the write function

        # open client subscribe subprocess. Only wait for a single execute of the resource
        port = self.config.clientIpcPort
        subscribeProcess = tools_common.run_non_blocking(tools_common.CLIENT_SUBSCRIBE,
                                                    "--verbose --ipcPort %i --waitCount 1 /3/0/15" % (port,))

        # wait for subscribe process to start up
        self.assertEqual(tools_common.strip_prefix(subscribeProcess.stdout.readline()), "Session IPC configured for UDP: address 127.0.0.1, port %d" % (port,))
        self.assertEqual(tools_common.strip_prefix(subscribeProcess.stdout.readline()), "Session connected")
        self.assertEqual(tools_common.strip_prefix(subscribeProcess.stdout.readline()), "Subscribe /3/0/15 Change\n")
        self.assertEqual(tools_common.strip_prefix(subscribeProcess.stdout.readline()), "Waiting for 1 notifications:\n")
        
        # do write command
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/3/0/15=abc")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)

        # read subscribe output
        expectedStdout = "Notify 1:\nChanged: /3/0/15 Resource Modified:\nDevice[/3/0]:\n    Timezone[/3/0/15]: abc\nSession disconnected\n"
        expectedStderr = ""
        expectedCode = 0

        result = tools_common.non_blocking_get_run_result(subscribeProcess)

        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:35,代码来源:test_awa_client_server_interaction.py


示例4: test_read_write_multiple_resources_different_instances

    def test_read_write_multiple_resources_different_instances(self):
        # test that multiple resources from different instances can be set and retrieved with a single command
        timezone = "ACME Corp."
        modelNumber = "1234567890"
        expectedStdout = \
"""    Timezone[3/0/15]: %s
    Resource100[1000/0/100]: %s
""" % (timezone, modelNumber)
        expectedStderr = ""
        expectedCode = 0

        server_write(self.config, "/3/0/15=\"%s\"" % (timezone,), "/1000/0/100=\"%s\"" % (modelNumber,))

        result = server_read(self.config, "/3/0/15", "/1000/0/100")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:17,代码来源:test_awa_server.py


示例5: temp_create_resource

 def temp_create_resource(self, path, value):
     # because defaults aren't currently supported, do a write to create the resource.
     expectedStdout = ""
     expectedStderr = ""
     expectedCode = 0
     result = server_write(self.config, "%s=%s" % (path, value))
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
开发者ID:thetoster,项目名称:AwaLWM2M,代码行数:9,代码来源:test_awa_server_observe.py


示例6: test_set_multiple_instances_on_single_instance_object

    def test_set_multiple_instances_on_single_instance_object(self):
        #test that we can't create multiple object instances on a single instance object
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/100=abc")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)

        expectedStdout = ""
        expectedStderr = "AwaServerWriteOperation_Perform failed\nFailed to write to path /1000/1/100: AwaLWM2MError_MethodNotAllowed\n"
        expectedCode = 1

        result = server_write(self.config, "/1000/1/100=abc")
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:19,代码来源:test_awa_server.py


示例7: test_set_multiple_instances_on_single_instance_resource

    def test_set_multiple_instances_on_single_instance_resource(self):
        #test that we can't set multiple resource instances on a single instance resource
        expectedStdout = ""
        expectedStderr = "Error: resource /1000/0/100 is not an array; do not specify a resource instance ID\n"
        expectedCode = 1

        result = server_write(self.config, "/1000/0/100/0=abc")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:10,代码来源:test_awa_server.py


示例8: observe_resource

    def observe_resource(self, path, currentValuesOutput, value, expectedResponse):
        # test that we can observe to a single change of value on a specified resource
        # open client observe subprocess. Only wait for a single change to the resource
        resourcePath = "/".join(path.split("/")[0:4])

        port = self.config.serverIpcPort
        observeProcess = tools_common.run_non_blocking(
            SERVER_OBSERVE,
            "--verbose --ipcPort %i --waitCount 1 --waitTime 555 %s --clientID %s"
            % (port, resourcePath, self.config.clientEndpointName),
        )

        # wait for observe process to start up
        self.assertEqual(
            tools_common.strip_prefix(observeProcess.stdout.readline()),
            "Session IPC configured for UDP: address 127.0.0.1, port %d" % (port,),
        )
        self.assertEqual(tools_common.strip_prefix(observeProcess.stdout.readline()), "Session connected")
        self.assertEqual(tools_common.strip_prefix(observeProcess.stdout.readline()), "Observe %s\n" % (resourcePath,))
        self.assertEqual(
            tools_common.strip_prefix(observeProcess.stdout.readline()),
            "Waiting for 1 notifications over 555 seconds:\n",
        )
        self.assertEqual(
            tools_common.strip_prefix(observeProcess.stdout.readline()), "Notify 0 from clientID TestClient:\n"
        )
        self.assertEqual(
            tools_common.strip_prefix(observeProcess.stdout.readline()),
            "Changed: %s Resource Modified:\n" % (resourcePath,),
        )

        for line in currentValuesOutput:
            self.assertEqual(tools_common.strip_prefix(observeProcess.stdout.readline()), line)

        # do write command
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "%s=%s" % (path, value))
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)

        # Notify 1:\n    Manufacturer[3/0/0]: abc\nUnobserve /3/0/0\n
        # read observe output
        expectedStdout = expectedResponse
        expectedStderr = ""
        expectedCode = 0

        result = tools_common.non_blocking_get_run_result(observeProcess)

        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:thetoster,项目名称:AwaLWM2M,代码行数:55,代码来源:test_awa_server_observe.py


示例9: test_write_single_resource_none

    def test_write_single_resource_none(self):
        # test that a single none resource (executable) cannot be set
        value = 12345
        expectedStdout = ""
        expectedStderr = "Resource /1000/0/107 is of type None and cannot be set\n"
        expectedCode = 1

        result = server_write(self.config, "/1000/0/107=%d" % (value,))
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:11,代码来源:test_awa_server.py


示例10: test_server_write_client_get_multiple_resources_same_instance

    def test_server_write_client_get_multiple_resources_same_instance(self):
        # test that multiple resources from the same instance can be set on
        # the server and retrieved on the client with single commands
        timezone = "ACME Corp."
        currentTime = 123456789
        expectedStdout = \
"""Device[/3/0]:
    Timezone[/3/0/15]: %s
    CurrentTime[/3/0/13]: %d
""" % (timezone, currentTime)
        expectedStderr = ""
        expectedCode = 0

        server_write(self.config,
                     "/3/0/15=\"%s\"" % (timezone,),
                     "/3/0/13=%d" % (currentTime,))

        result = client_get(self.config, "/3/0/15", "/3/0/13")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:21,代码来源:test_awa_client_server_interaction.py


示例11: test_read_write_invalid_value

    def test_read_write_invalid_value(self):
        # first set an initial value for an integer resource.
        # Then set the integer resource with a string value. Currently will set the value to 0

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/101=12345")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)

        expectedStdout = "Object1000[/1000/0]:\n    Resource101[/1000/0/101]: 12345\n"
        expectedStderr = ""
        expectedCode = 0

        result = server_read(self.config, "/1000/0/101")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/101=abc")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)

        expectedStdout = "Object1000[/1000/0]:\n    Resource101[/1000/0/101]: 0\n"
        expectedStderr = ""
        expectedCode = 0

        result = server_read(self.config, "/1000/0/101")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:39,代码来源:test_awa_server.py


示例12: test_read_write_single_resource_integer

    def test_read_write_single_resource_integer(self):
        # test that a single integer resource can be set and retrieved
        value = 3
        expectedStdout = "Object1000[/1000/0]:\n    Resource101[/1000/0/101]: %d\n" % (value,)
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "--verbose /1000/0/101=%d" % (value,))
        self.assertEqual(expectedCode, result.code)

        result = server_read(self.config, "/1000/0/101")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:14,代码来源:test_awa_server.py


示例13: test_read_write_single_resource_float

    def test_read_write_single_resource_float(self):
        # test that a single float resource can be set and retrieved
        value = 3.5
        expectedStdout = "Object1000[/1000/0]:\n    Resource102[/1000/0/102]: %.1f\n" % (value,)
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/102=%f" % (value,))
        self.assertEqual(expectedCode, result.code)

        result = server_read(self.config, "/1000/0/102")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:14,代码来源:test_awa_server.py


示例14: test_read_write_single_resource_time

    def test_read_write_single_resource_time(self):
        # test that a single time resource (64 bit integer) can be set and retrieved
        value = 1442972971
        expectedStdout = "Object1000[/1000/0]:\n    Resource104[/1000/0/104]: %d\n" % (value,)
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/104=%d" % (value,))
        self.assertEqual(expectedCode, result.code)

        result = server_read(self.config, "/1000/0/104")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:14,代码来源:test_awa_server.py


示例15: test_read_write_single_resource_string

    def test_read_write_single_resource_string(self):
        # test that a single string resource can be set and retrieved
        manufacturer = "ACME Corp."
        expectedStdout = "Object1000[/1000/0]:\n    Resource100[/1000/0/100]: %s\n" % (manufacturer,)
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/100=\"%s\"" % (manufacturer,))
        self.assertEqual(expectedCode, result.code)

        result = server_read(self.config, "/1000/0/100")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:14,代码来源:test_awa_server.py


示例16: test_read_write_single_resource_objlink

    def test_read_write_single_resource_objlink(self):
        # test that a single object link resource can be set and retrieved
        link = "/3/0"
        expectedStdout = "Object1000[/1000/0]:\n    Resource106[/1000/0/106]: ObjectLink[%s]\n" % (link.strip('/').replace('/', ':'))
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/106=\"%s\"" % (link,))
        self.assertEqual(expectedCode, result.code)

        result = server_read(self.config, "/1000/0/106")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:14,代码来源:test_awa_server.py


示例17: test_server_write_client_get_multiple_resources_different_instances

    def test_server_write_client_get_multiple_resources_different_instances(self):
        # test that multiple resources from the different instances can be set on
        # the server and retrieved on the client with single commands
        timezone = "ACME Corp."
        modelNumber = "1234567890"
        expectedStdout = \
"""Device[/3/0]:
    Timezone[/3/0/15]: %s
Object1000[/1000/0]:
    Resource100[/1000/0/100]: %s
""" % (timezone, modelNumber)
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/3/0/15=\"%s\"" % (timezone,))
        self.assertEqual(0, result.code)
        
        result = server_write(self.config, "/1000/0/100=\"%s\"" % (modelNumber,))
        self.assertEqual(0, result.code)

        result = client_get(self.config, "/3/0/15", "/1000/0/100")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:24,代码来源:test_awa_client_server_interaction.py


示例18: test_server_write_client_get_single_resource

    def test_server_write_client_get_single_resource(self):
        # test that a single resource can be written on the server and retrieved on the client
        manufacturer = "ACME Corp."
        expectedStdout = "Object1000[/1000/0]:\n    Resource100[/1000/0/100]: %s\n" % (manufacturer,)
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/100=\"%s\"" % (manufacturer,))
        self.assertEqual("", result.stderr)
        self.assertEqual("", result.stdout)
        self.assertEqual(0, result.code)

        result = client_get(self.config, "/1000/0/100")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:16,代码来源:test_awa_client_server_interaction.py


示例19: test_read_write

    def test_read_write(self):
        # test that a single resource can be set and retrieved
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/3/0/15=abc")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)

        expectedStdout = "Device[/3/0]:\n    Timezone[/3/0/15]: abc\n"
        expectedStderr = ""
        expectedCode = 0

        result = server_read(self.config, "/3/0/15")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:19,代码来源:test_awa_server.py


示例20: test_delete_custom_object_instance

    def test_delete_custom_object_instance(self):
        # test we can delete a custom object instance
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "/1000/0/100=abc")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_delete(self.config, "/1000/0")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:19,代码来源:test_awa_server.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_base.expect函数代码示例发布时间:2022-05-27
下一篇:
Python test_api_utils.get_supported_pollers函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap