from devicehive.user import User
from devicehive import UserError


def test_save(test):

    def handle_connect(handler):
        login = test.generate_id('c-u')
        password = test.generate_id('c-u')
        role = User.ADMINISTRATOR_ROLE
        data = {'k': 'v'}
        user = handler.api.create_user(login, password, role, data)
        role = User.CLIENT_ROLE
        status = User.DISABLED_STATUS
        data = {'k-1': 'v-1'}
        user.role = role
        user.status = status
        user.data = data
        user.save()
        user = handler.api.get_user(user.id)
        assert user.role == role
        assert user.status == status
        assert user.data == data
        user.remove()
        try:
            user.save()
            assert False
        except UserError:
            pass

    test.run(handle_connect)

@@ -59,16 +59,56 @@
 erError%0A
+from devicehive import ApiResponseError%0A
 %0A%0Adef te
@@ -876,8 +876,966 @@
 onnect)%0A
+%0A%0Adef test_remove(test):%0A%0A    def handle_connect(handler):%0A        login = test.generate_id('c-u')%0A        password = test.generate_id('c-u')%0A        role = User.ADMINISTRATOR_ROLE%0A        data = %7B'k': 'v'%7D%0A        user = handler.api.create_user(login, password, role, data)%0A        user_1 = handler.api.get_user(user.id)%0A        user.remove()%0A        assert not user.id%0A        assert not user.login%0A        assert not user.last_login%0A        assert not user.intro_reviewed%0A        assert not user.role%0A        assert not user.status%0A        assert not user.data%0A        try:%0A            user.remove()%0A            assert False%0A        except UserError:%0A            pass%0A        try:%0A            user_1.remove()%0A            assert False%0A        except ApiResponseError as api_response_error:%0A            # TODO: uncomment after server response will be fixed.%0A            # assert api_response_error.code == 404%0A            pass%0A%0A    test.run(handle_connect)%0A

Add test_remove function