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

Python tools_common.create_define_command函数代码示例

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

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



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

示例1: test_create_multiple_object_instances_for_single_instance_object

    def test_create_multiple_object_instances_for_single_instance_object(self):
        # test that the set tool cannot create an object instance with a non-zero ID on a single-instance
        
        customObjects = (
            tools_common.CustomObject("Object1001", 1001, False, "single", (
                    tools_common.CustomResource("Resource100", 100, "string",  "single", "optional", "rw"),
            )),
        )
        params = tools_common.create_define_command(customObjects)
        result = test_awa_client_define.client_define(self.config, *params)
        self.assertEqual(0, result.code)

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = client_set(self.config, "--create /1001/0")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)

        expectedStdout = ""
        expectedStderr = "AwaClientSetOperation_Perform failed\nFailed to set on path /1001/1: AwaError_CannotCreate\n"
        expectedCode = 1

        result = client_set(self.config, "--create /1001/1")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:29,代码来源:test_awa_client_set.py


示例2: test_create_optional_resource

    def test_create_optional_resource(self):
        # test that the set tool can create an object instance without specifying an ID
        #expectedStdout = "Create /1000/0"
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0
        
        customObjects = (
            tools_common.CustomObject("Object1001", 1001, False, "single", (
                    tools_common.CustomResource("Resource100", 100, "string",  "single", "optional", "rw"),
            )),
        )
        params = tools_common.create_define_command(customObjects)
        result = test_awa_client_define.client_define(self.config, *params)
        self.assertEqual(0, result.code)

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


示例3: 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


示例4: test_redefine_existing_object

    def test_redefine_existing_object(self):
        # test that we can't define an object if the ID is already used
        customObjects = (
            CustomObject(
                "Object1001",
                1001,
                False,
                "single",
                (CustomResource("Resource100", 100, "string", "single", "optional", "rw"),),
            ),
        )
        params = tools_common.create_define_command(customObjects)

        # define our custom object
        result = client_define(self.config, *params)
        self.assertEqual(0, result.code)

        expectedStdout = ""
        expectedStderr = "AwaError_AlreadyDefined: Failed to add object definition\nDefine operation failed\n"
        expectedCode = 1

        # attempt to redefine custom objects (should fail)
        result = client_define(self.config, *params)
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:thetoster,项目名称:AwaLWM2M,代码行数:26,代码来源:test_awa_client_define.py


示例5: test_define_object_verbose

    def test_define_object_verbose(self):
        # test that we can define a custom object
        customObjects = (
            CustomObject(
                "Object1001",
                1001,
                False,
                "single",
                (CustomResource("Resource100", 100, "string", "single", "optional", "rw"),),
            ),
        )
        params = ["--verbose"] + tools_common.create_define_command(customObjects)

        expectedStdout = (
            "Session IPC configured for UDP: address 127.0.0.1, port %d\nSession connected\nObjectID 1001 defined successfully\nSession disconnected\n"
            % (self.config.clientIpcPort,)
        )
        expectedStderr = ""
        expectedCode = 0

        # define our custom object
        result = client_define(self.config, *params)
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
开发者ID:thetoster,项目名称:AwaLWM2M,代码行数:25,代码来源:test_awa_client_define.py


示例6: test_define_multiple_resources_same_ID

    def test_define_multiple_resources_same_ID(self):
        # test that we can't define multiple resources with the same ID in a single object
        customObjects = (
            CustomObject(
                "Object1001",
                1001,
                False,
                "single",
                (
                    CustomResource("Resource100", 100, "string", "single", "optional", "rw"),
                    CustomResource("Resource100", 100, "string", "single", "optional", "rw"),
                ),
            ),
        )

        params = tools_common.create_define_command(customObjects)
        result = client_define(self.config, *params)

        expectedStdout = ""
        expectedStderr = "AwaError_AlreadyDefined: \nCould not add resource definition (resource [100] Resource100) to object definition\nFailed to create object definition\n"
        expectedCode = 1

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


示例7: test_set_read_only_resource

 def test_set_read_only_resource(self):
     # test that we should still be able to set a read only resource (client should have permission to do anything)
     customObjects = (
         CustomObject("Object1001", 1001, False, "single", (
                 CustomResource("Resource100", 100, "string",  "single", "optional", "r"),
         )),
     )
     params = tools_common.create_define_command(customObjects)
     result = client_define(self.config, *params)
     self.assertEqual(0, result.code)
     
     expectedStdout = ""
     expectedStderr = ""
     expectedCode = 0
     
     # set a read only object
     result = client_set(self.config, "--create /1001/0 --create /1001/0/100 /1001/0/100=abc")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
     
     expectedStdout = "Object1001[/1001/0]:\n    Resource100[/1001/0/100]: abc\n"
     expectedStderr = ""
     expectedCode = 0
     
     # check that the value was set correctly
     result = client_get(self.config, "/1001/0/100")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:30,代码来源:test_awa_client.py


示例8: test_define_no_resources

 def test_define_no_resources(self):
     # test that we can define an object without resources
     customObjects = (
         CustomObject("Object1234", 1234, False, "single", ()),
     )
     params = ["--verbose"] + tools_common.create_define_command(customObjects)
     
     expectedStdout = "Session IPC configured for UDP: address 127.0.0.1, port %d\nSession connected\nObjectID 1234 defined successfully\nSession disconnected\n" % (self.config.serverIpcPort, )
     expectedStderr = ""
     expectedCode = 0
     
     # define our custom object
     result = server_define(self.config, *params)
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:16,代码来源:test_awa_server_define.py


示例9: test_define_unsupported_resource_type

 def test_define_unsupported_resource_type(self):
     # test that we can't use 'byte' as a resource type without crashing
     customObjects = (
         CustomObject("Object1000", 1000, False, "single", (
                 CustomResource("Resource100", 100, "byte",  "single", "optional", "rw"),
         )),
     )
     params = tools_common.create_define_command(customObjects)
     
     expectedStdout = ""
     expectedStderr = tools_common.SERVER_DEFINE + ": invalid argument, \"byte\", for option `--resourceType\' (`-t\')\n"
     expectedCode = 1
     
     # define our custom object
     result = server_define(self.config, *params)
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:18,代码来源:test_awa_server_define.py


示例10: test_define_multiple_instance_executable_resource

 def test_define_multiple_instance_executable_resource(self):
     # test that executable resources can only be single instance
     customObjects = (
         CustomObject("Object1000", 1000, False, "single", (
                 CustomResource("Resource100", 100, "string",  "multiple", "optional", "e"),
         )),
     )
     params = tools_common.create_define_command(customObjects)
     
     expectedStdout = ""
     expectedStderr = "AwaError_DefinitionInvalid: \nCould not add resource definition (resource [100] Resource100) to object definition\nFailed to create object definition\n"
     expectedCode = 1
     
     # define our custom object
     result = server_define(self.config, *params)
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:18,代码来源:test_awa_server_define.py


示例11: test_define_object

 def test_define_object(self):
     # test that we can define a custom object 
     customObjects = (
         CustomObject("Object1234", 1234, False, "single", (
                 CustomResource("Resource100", 100, "string",  "single", "optional", "rw"),
         )),
     )
     params = tools_common.create_define_command(customObjects)
     
     expectedStdout = ""
     expectedStderr = ""
     expectedCode = 0
     
     # define our custom object
     result = server_define(self.config, *params)
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:18,代码来源:test_awa_server_define.py


示例12: test_define_read_write_execute

 def test_define_read_write_execute(self):
     # test that we can't create a resource that supports read, write and execute together (only r, w, rw or e)
     customObjects = (
         CustomObject("Object1000", 1000, False, "single", (
                 CustomResource("Resource100", 100, "string",  "single", "optional", "rwe"),
         )),
     )
     params = tools_common.create_define_command(customObjects)
     
     expectedStdout = ""
     expectedStderr = tools_common.SERVER_DEFINE + ": invalid argument, \"rwe\", for option `--resourceOperations\' (`-k\')\n"
     expectedCode = 1
     
     # define our custom object
     result = server_define(self.config, *params)
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:18,代码来源:test_awa_server_define.py


示例13: test_new_object_no_instance

    def test_new_object_no_instance(self):
        # test a get on a new object with no instances created

        customObjects = (
            CustomObject("Object1001", 1001, False, "single", (
                CustomResource("Resource100", 100, "string",  "single", "optional", "rw"),
            )),
        )
        params = tools_common.create_define_command(customObjects)
        client_define(self.config, *params)

        expectedStdout = "Object1001[/1001]: No instances\n"
        expectedStderr = ""
        expectedCode = 0
        result = client_get(self.config, "/1001")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)
开发者ID:DavidAntliff,项目名称:AwaLWM2M,代码行数:18,代码来源:test_awa_client_get.py


示例14: test_create_object_instance_with_non_zero_id

    def test_create_object_instance_with_non_zero_id(self):
        # test that the set tool can create an object instance with a specified ID
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0
        
        customObjects = (
            tools_common.CustomObject("Object1001", 1001, False, "single", (
                    tools_common.CustomResource("Resource100", 100, "string",  "single", "optional", "rw"),
            )),
        )
        params = tools_common.create_define_command(customObjects)
        result = test_awa_client_define.client_define(self.config, *params)
        self.assertEqual(0, result.code)
        result = test_awa_server_define.server_define(self.config, *params)
        self.assertEqual(0, result.code)

        result = server_write(self.config, "--create /1001/1")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)
开发者ID:rahul-daga-imgtec,项目名称:AwaLWM2M,代码行数:21,代码来源:test_awa_server_write.py


示例15: test_write_read_only_resource

    def test_write_read_only_resource(self):
        # test that we can't write to a read only resource
        customObjects = (
            CustomObject("Object1001", 1001, False, "single", (
                    CustomResource("Resource100", 100, "string",  "single", "optional", "r"),
            )),
        )
        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)

        # FlowDeviceMgmtServer_Write failed : (-11) The requested operation is not permitted\n
        expectedStdout = ""
        expectedStderr = "AwaServerWriteOperation_Perform failed\nFailed to write to path /1001/0/100: AwaLWM2MError_MethodNotAllowed\n"
        expectedCode = 1

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


示例16: test_get_write_only_resource

 def test_get_write_only_resource(self):
     # test that we can read from a write only resource - client should have power to do anything
     customObjects = (
         CustomObject("Object1001", 1001, False, "single", (
                 CustomResource("Resource100", 100, "string",  "single", "optional", "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 = client_set(self.config, "--create /1001/0 --create /1001/0/100 /1001/0/100=abc")
     self.assertEqual(0, result.code)
     
     expectedStdout = "Object1001[/1001/0]:\n    Resource100[/1001/0/100]: abc\n"
     expectedStderr = ""
     expectedCode = 0
     
     # attempt to get a write only object, should not fail on the client only.
     result = client_get(self.config, "/1001/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.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python io.fire函数代码示例发布时间:2022-05-27
下一篇:
Python wpt.main函数代码示例发布时间: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