from tests import string


def test_send(test):

    def handle_connect(handler):
        device_id = test.generate_id('send-command')
        command_name = test.generate_id('send-command')
        device = handler.api.put_device(device_id)
        command = device.send_command(command_name)
        assert command.device_id() == device_id
        assert isinstance(command.id(), int)
        assert isinstance(command.user_id(), int)
        assert command.command() == command_name
        assert not command.parameters()
        assert not command.lifetime()
        assert isinstance(command.timestamp(), string)
        assert not command.status
        assert not command.result
        command_name = test.generate_id('send-command')
        parameters = 'parameters'
        lifetime = 10
        status = 'status'
        result = {'key': 'value'}
        command = device.send_command(command_name, parameters=parameters,
                                      lifetime=lifetime, status=status,
                                      result=result)
        assert command.device_id() == device_id
        assert isinstance(command.id(), int)
        assert isinstance(command.user_id(), int)
        assert command.command() == command_name
        assert command.parameters() == parameters
        assert command.lifetime() == lifetime
        assert isinstance(command.timestamp(), string)
        assert command.status == status
        assert command.result == result
        device.remove()

    test.run(handle_connect)

@@ -18,16 +18,60 @@
  string%0A
+from devicehive import ApiResponseException%0A
 %0A%0Adef te
@@ -1573,8 +1573,681 @@
 onnect)%0A
+%0A%0Adef test_save(test):%0A%0A    def handle_connect(handler):%0A        device_id = test.generate_id('save-command')%0A        command_name = test.generate_id('save-command')%0A        device = handler.api.put_device(device_id)%0A        command = device.send_command(command_name)%0A        status = 'status'%0A        result = %7B'key': 'value'%7D%0A        command.status = status%0A        command.result = result%0A        command.save()%0A        device.remove()%0A        try:%0A            command.save()%0A            assert False%0A        except ApiResponseException as api_response_exception:%0A            # assert api_response_exception.code() == 404%0A            pass%0A%0A    test.run(handle_connect)%0A

Add test_save function