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)
        result = test_awa_server_define.server_define(self.config, *params)
        self.assertEqual(0, result.code)
        
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "--create /1001/0")
        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 /1001/1: AwaLWM2MError_MethodNotAllowed\n"
        expectedCode = 1

        result = server_write(self.config, "--create /1001/1")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode,   result.code)
    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)
    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)
        result = test_awa_server_define.server_define(self.config, *params)
        self.assertEqual(0, result.code)

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = server_write(self.config, "--create /1001/0")
        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 /1001/1: AwaLWM2MError_MethodNotAllowed\n"
        expectedCode = 1

        result = server_write(self.config, "--create /1001/1")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemple #4
0
    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", "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 = 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)
    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)
    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)
    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)
    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)