Exemplo n.º 1
0
    def test_set_get_invalid_value(self):
        # set MemoryFree (int) as string value. Currently will set the value to 0
        expectedStdout = "Device[/3/0]:\n    MemoryFree[/3/0/10]: 15\n"
        expectedStderr = ""
        expectedCode = 0

        result = client_get(self.config, "/3/0/10")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

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

        expectedStdout = "Device[/3/0]:\n    MemoryFree[/3/0/10]: 0\n"
        expectedStderr = ""
        expectedCode = 0

        result = client_get(self.config, "/3/0/10")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 2
0
 def test_set_get_invalid_value(self):
     # set MemoryFree (int) as string value. Currently will set the value to 0
     expectedStdout = "Device[/3/0]:\n    MemoryFree[/3/0/10]: 15\n"
     expectedStderr = ""
     expectedCode = 0
     
     result = client_get(self.config, "/3/0/10")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
     
     expectedStdout = ""
     expectedStderr = ""
     expectedCode = 0
     
     result = client_set(self.config, "/3/0/10=abc")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
     
     expectedStdout = "Device[/3/0]:\n    MemoryFree[/3/0/10]: 0\n"
     expectedStderr = ""
     expectedCode = 0
     
     result = client_get(self.config, "/3/0/10")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    def test_get_single_resource_none_executable(self):
        # test that a single none resource (executable) cannot be retrieved
        expectedStdout = "Object1000[/1000/0]:\n    Resource107[/1000/0/107]: [Executable]\n"
        expectedStderr = ""
        expectedCode = 0

        result = client_get(self.config, "/1000/0/107")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 7
0
 def test_get_single_resource_none_executable(self):
     # test that a single none resource (executable) cannot be retrieved
     expectedStdout = "Object1000[/1000/0]:\n    Resource107[/1000/0/107]: [Executable]\n"
     expectedStderr = ""
     expectedCode = 0
     
     result = client_get(self.config, "/1000/0/107")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
Exemplo n.º 8
0
    def test_set_get_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 = client_set(self.config, "/1000/0/100=\"%s\"" % (manufacturer,))
        self.assertEqual(expectedCode, 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)
Exemplo n.º 9
0
    def test_set_get_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 = client_set(self.config, "/1000/0/104=%d" % (value,))
        self.assertEqual(expectedCode, result.code)
        
        result = client_get(self.config, "/1000/0/104")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 10
0
    def test_set_get_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]: %g\n" % (value,)
        expectedStderr = ""
        expectedCode = 0

        result = client_set(self.config, "/1000/0/102=%f" % (value,))
        self.assertEqual(expectedCode, result.code)
        
        result = client_get(self.config, "/1000/0/102")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 11
0
    def test_set_get_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 = client_set(self.config, "--verbose /1000/0/101=%i" % (value,))
        self.assertEqual(expectedCode, result.code)
        
        result = client_get(self.config, "/1000/0/101")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 12
0
 def test_set_get_delete_get(self):
     # test that we can no longer get the value of a resource after it has been deleted
     expectedStdout = ""
     expectedStderr = ""
     expectedCode = 0
     
     result = client_set(self.config, "/1000/0/100=abc")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
     
     expectedStdout = "Object1000[/1000/0]:\n    Resource100[/1000/0/100]: abc\n"
     expectedStderr = ""
     expectedCode = 0
     
     result = client_get(self.config, "/1000/0/100")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
     
     expectedStdout = ""
     expectedStderr = ""
     expectedCode = 0
     
     result = client_delete(self.config, "/1000/0/100")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
     
     expectedStdout = ""
     expectedStderr = "AwaClientGetOperation_Perform failed\nFailed to retrieve /1000/0/100: AwaError_PathNotFound\n"
     expectedCode = 1
     
     result = client_get(self.config, "/1000/0/100")
     self.assertEqual(expectedStdout, result.stdout)
     self.assertEqual(expectedStderr, result.stderr)
     self.assertEqual(expectedCode, result.code)
Exemplo n.º 13
0
    def test_set_get_delete_get(self):
        # test that we can no longer get the value of a resource after it has been deleted
        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

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

        expectedStdout = "Object1000[/1000/0]:\n    Resource100[/1000/0/100]: abc\n"
        expectedStderr = ""
        expectedCode = 0

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

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

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

        expectedStdout = ""
        expectedStderr = "AwaClientGetOperation_Perform failed\nFailed to retrieve /1000/0/100: AwaError_PathNotFound\n"
        expectedCode = 1

        result = client_get(self.config, "/1000/0/100")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 14
0
    def test_set_get_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 = client_set(self.config, "/1000/0/104=%d" % (value, ))
        self.assertEqual(expectedCode, result.code)

        result = client_get(self.config, "/1000/0/104")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 15
0
    def test_set_get_single_resource_objlink(self):
        # test that a single object link resource can be set and retrieved
        link = "/3/0"

        result = client_set(self.config, "/1000/0/106=\"%s\"" % (link,))
        self.assertEqual(0, result.code)
        
        expectedStdout = "Object1000[/1000/0]:\n    Resource106[/1000/0/106]: ObjectLink[%s]\n" % (link.strip('/').replace('/', ':'))
        expectedStderr = ""
        expectedCode = 0
        
        result = client_get(self.config, "/1000/0/106")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 16
0
    def test_set_get_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]: %g\n" % (
            value, )
        expectedStderr = ""
        expectedCode = 0

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

        result = client_get(self.config, "/1000/0/102")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 17
0
    def test_set_get_single_resource_objlink(self):
        # test that a single object link resource can be set and retrieved
        link = "/3/0"

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

        expectedStdout = "Object1000[/1000/0]:\n    Resource106[/1000/0/106]: ObjectLink[%s]\n" % (
            link.strip('/').replace('/', ':'))
        expectedStderr = ""
        expectedCode = 0

        result = client_get(self.config, "/1000/0/106")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 18
0
    def test_set_get_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 = client_set(self.config,
                            "/1000/0/100=\"%s\"" % (manufacturer, ))
        self.assertEqual(expectedCode, 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)
Exemplo n.º 19
0
    def test_set_get_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 = client_set(self.config,
                            "--verbose /1000/0/101=%i" % (value, ))
        self.assertEqual(expectedCode, result.code)

        result = client_get(self.config, "/1000/0/101")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
    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)
Exemplo n.º 21
0
    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)
Exemplo n.º 22
0
    def test_set_get_multiple_resources_different_instances(self):
        # test that multiple resources from different instances can be set and retrieved with a single command
        manufacturer = "ACME Corp."
        modelNumber = "1234567890"
        expectedStdout = \
"""Device[/3/0]:
    Manufacturer[/3/0/0]: %s
Object1000[/1000/0]:
    Resource100[/1000/0/100]: %s
""" % (manufacturer, modelNumber)
        expectedStderr = ""
        expectedCode = 0

        client_set(self.config, "/3/0/0=\"%s\"" % (manufacturer,), "/1000/0/100=\"%s\"" % (modelNumber,))

        result = client_get(self.config, "/3/0/0", "/1000/0/100")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 23
0
 def test_set_get_single_resource_boolean_numbers(self):
     # test correct values for setting boolean resource with integers: 0,1,2 (False,True,True)
     for value in range(3):
         expectedStdout = ""
         expectedStderr = ""
         expectedCode = 0
 
         result = client_set(self.config, "/1000/0/103=%d" % (value,))
 
         self.assertEqual(expectedStdout, result.stdout)
         self.assertEqual(expectedStderr, result.stderr)
         self.assertEqual(expectedCode, result.code)
         
         expectedStdout = "Object1000[/1000/0]:\n    Resource103[/1000/0/103]: %r\n" % (bool(value),)
         #print "Boolean expectedStdout: %s" % (expectedStdout,)
         result = client_get(self.config, "/1000/0/103")
         self.assertEqual(expectedStdout, result.stdout)
         self.assertEqual(expectedStderr, result.stderr)
         self.assertEqual(expectedCode, result.code)
Exemplo n.º 24
0
    def test_set_get_single_resource_boolean_true(self):
        # test that a single boolean resource can be set and retrieved
        value = True

        expectedStdout = "Session IPC configured for UDP: address 127.0.0.1, port %d\nSession connected\nSet Boolean /1000/0/103 <- True\nSet operation completed successfully.\nSession disconnected\n" % (self.config.clientIpcPort,)
        expectedStderr = ""
        expectedCode = 0

        result = client_set(self.config, "--verbose /1000/0/103=%r" % (value,))

        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
        
        expectedStdout = "Object1000[/1000/0]:\n    Resource103[/1000/0/103]: True\n"
        
        result = client_get(self.config, "/1000/0/103")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 25
0
    def test_set_get_multiple_resources_different_instances(self):
        # test that multiple resources from different instances can be set and retrieved with a single command
        manufacturer = "ACME Corp."
        modelNumber = "1234567890"
        expectedStdout = \
"""Device[/3/0]:
    Manufacturer[/3/0/0]: %s
Object1000[/1000/0]:
    Resource100[/1000/0/100]: %s
""" % (manufacturer, modelNumber)
        expectedStderr = ""
        expectedCode = 0

        client_set(self.config, "/3/0/0=\"%s\"" % (manufacturer, ),
                   "/1000/0/100=\"%s\"" % (modelNumber, ))

        result = client_get(self.config, "/3/0/0", "/1000/0/100")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 26
0
    def test_set_get_single_resource_boolean_false(self):
        # test that a single boolean resource can be set and retrieved
        value = False

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = client_set(self.config, "/1000/0/103=%r" % (value,))

        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
        
        expectedStdout = "Object1000[/1000/0]:\n    Resource103[/1000/0/103]: %r\n" % (value,)
        
        result = client_get(self.config, "/1000/0/103")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 27
0
    def test_set_get_single_resource_boolean_numbers(self):
        # test correct values for setting boolean resource with integers: 0,1,2 (False,True,True)
        for value in range(3):
            expectedStdout = ""
            expectedStderr = ""
            expectedCode = 0

            result = client_set(self.config, "/1000/0/103=%d" % (value, ))

            self.assertEqual(expectedStdout, result.stdout)
            self.assertEqual(expectedStderr, result.stderr)
            self.assertEqual(expectedCode, result.code)

            expectedStdout = "Object1000[/1000/0]:\n    Resource103[/1000/0/103]: %r\n" % (
                bool(value), )
            #print "Boolean expectedStdout: %s" % (expectedStdout,)
            result = client_get(self.config, "/1000/0/103")
            self.assertEqual(expectedStdout, result.stdout)
            self.assertEqual(expectedStderr, result.stderr)
            self.assertEqual(expectedCode, result.code)
Exemplo n.º 28
0
    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)
Exemplo n.º 29
0
    def test_set_get_single_resource_boolean_false(self):
        # test that a single boolean resource can be set and retrieved
        value = False

        expectedStdout = ""
        expectedStderr = ""
        expectedCode = 0

        result = client_set(self.config, "/1000/0/103=%r" % (value, ))

        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)

        expectedStdout = "Object1000[/1000/0]:\n    Resource103[/1000/0/103]: %r\n" % (
            value, )

        result = client_get(self.config, "/1000/0/103")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
    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)
    def test_server_write_client_get_multiple_resources_different_instances_single_write(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,), "/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)
Exemplo n.º 32
0
    def test_set_get_multiple_resources_same_instance(self):
        # test that multiple resources from the same instance can be set and retrieved with a single command
        manufacturer = "ACME Corp."
        modelNumber = "1234567890"
        memoryFree = 55
        expectedStdout = \
"""Device[/3/0]:
    Manufacturer[/3/0/0]: %s
    ModelNumber[/3/0/1]: %s
    MemoryFree[/3/0/10]: %d
""" % (manufacturer, modelNumber, memoryFree)
        expectedStderr = ""
        expectedCode = 0

        client_set(self.config, "/3/0/0=\"%s\"" % (manufacturer,))
        client_set(self.config, "/3/0/1=\"%s\"" % (modelNumber,))
        client_set(self.config, "/3/0/10=%d" % (memoryFree,))

        result = client_get(self.config, "/3/0/0", "/3/0/1", "/3/0/10")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 33
0
    def test_set_get_single_resource_boolean_true(self):
        # test that a single boolean resource can be set and retrieved
        value = True

        expectedStdout = "Session IPC configured for UDP: address 127.0.0.1, port %d\nSession connected\nSet Boolean /1000/0/103 <- True\nSet operation completed successfully.\nSession disconnected\n" % (
            self.config.clientIpcPort, )
        expectedStderr = ""
        expectedCode = 0

        result = client_set(self.config,
                            "--verbose /1000/0/103=%r" % (value, ))

        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)

        expectedStdout = "Object1000[/1000/0]:\n    Resource103[/1000/0/103]: True\n"

        result = client_get(self.config, "/1000/0/103")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 34
0
    def test_set_get_multiple_resources_same_instance(self):
        # test that multiple resources from the same instance can be set and retrieved with a single command
        manufacturer = "ACME Corp."
        modelNumber = "1234567890"
        memoryFree = 55
        expectedStdout = \
"""Device[/3/0]:
    Manufacturer[/3/0/0]: %s
    ModelNumber[/3/0/1]: %s
    MemoryFree[/3/0/10]: %d
""" % (manufacturer, modelNumber, memoryFree)
        expectedStderr = ""
        expectedCode = 0

        client_set(self.config, "/3/0/0=\"%s\"" % (manufacturer, ))
        client_set(self.config, "/3/0/1=\"%s\"" % (modelNumber, ))
        client_set(self.config, "/3/0/10=%d" % (memoryFree, ))

        result = client_get(self.config, "/3/0/0", "/3/0/1", "/3/0/10")
        self.assertEqual(expectedStdout, result.stdout)
        self.assertEqual(expectedStderr, result.stderr)
        self.assertEqual(expectedCode, result.code)
Exemplo n.º 35
0
 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)
Exemplo n.º 36
0
    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)