@gen_test
    def test_update(self):
        client = AsyncfluxClient()
        db_name = 'foo'
        db = client[db_name]
        username = 'foo'
        user = User(db, username)
        password = 'fubar'
        is_admin = True
        read_from = '^$'
        write_to = '^$'

        # Update password
        payload = {'password': password}
        with self.patch_fetch_mock(client) as m:
            self.setup_fetch_mock(m, 200)
            response = yield user.update(new_password=password)
            self.assertIsNone(response)

            self.assert_mock_args(m, '/db/%s/users/%s' % (db_name, username),
                                  method='POST', body=json.dumps(payload))

        # Update isAdmin value
        payload = {'isAdmin': is_admin}
        with self.patch_fetch_mock(client) as m:
            self.setup_fetch_mock(m, 200)
            response = yield user.update(is_admin=is_admin)
            self.assertIsNone(response)
            self.assertEqual(user.is_admin, is_admin)

            self.assert_mock_args(m, (db_name, username) % '/db/%s/users/%s',
                                  method='POST', body=json.dumps(payload))

        # Update permissions
        payload = {'readFrom': read_from, 'writeTo': write_to}
        with self.patch_fetch_mock(client) as m:
            self.setup_fetch_mock(m, 200)
            response = yield user.update(read_from=read_from,
                                         write_to=write_to)
            self.assertIsNone(response)
            self.assertEqual(user.read_from, read_from)
            self.assertEqual(user.write_to, write_to)

            self.assert_mock_args(m, '/db/%s/users/%s' % (db_name, username),
                                  method='POST', body=json.dumps(payload))

        # Invalid permission argument values
        exc_msg = 'You have to provide read and write permissions'
        with self.assertRaisesRegexp(ValueError, exc_msg):
            yield user.update(password, is_admin=is_admin, read_from=read_from)

        # Without any arguments
        exc_msg = 'You have to set at least one argument'
        with self.assertRaisesRegexp(ValueError, exc_msg):
            yield user.update()
dataset/ETHPy150Open puentesarrin/asyncflux/tests/user_test.py/UserTestCase.test_update/swapped operands of `%`