Пример #1
0
def test_account2(client):
    test_account = client.admin.create_account(
        '{}@test.com'.format(randstring(6)), randstring(6))
    try:
        yield test_account
    finally:
        test_account.delete()
Пример #2
0
def test_user_management():
    email1 = '%s@%s.com' % (randstring(6), randstring(6))
    email2 = '%s@%s.com' % (randstring(6), randstring(6))
    passwd1 = 'randstring(6)'
    passwd2 = 'randstring(6)'

    ccnet_api.add_emailuser(email1, passwd1, 1, 1)
    ccnet_api.add_emailuser(email2, passwd2, 0, 0)

    ccnet_email1 = ccnet_api.get_emailuser(email1)
    ccnet_email2 = ccnet_api.get_emailuser(email2)
    assert ccnet_email1.is_active == True
    assert ccnet_email1.is_staff == True
    assert ccnet_email2.is_active == False
    assert ccnet_email2.is_staff == False

    assert ccnet_api.validate_emailuser(email1, passwd1) == 0
    assert ccnet_api.validate_emailuser(email2, passwd2) == 0

    users = ccnet_api.search_emailusers('DB',email1, -1, -1)
    assert len(users) == 1
    user_ccnet = users[0]
    assert user_ccnet.email == email1

    user_counts = ccnet_api.count_emailusers('DB')
    user_numbers = ccnet_api.get_emailusers('DB', -1, -1)

    ccnet_api.update_emailuser('DB', ccnet_email2.id, passwd2, 1, 1)
    email2_new = ccnet_api.get_emailuser(email2)
    assert email2_new.is_active == True
    assert email2_new.is_staff == True

    ccnet_api.remove_emailuser('DB', email1)
    ccnet_api.remove_emailuser('DB', email2)
Пример #3
0
def test_create_delete_file_dir(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls()) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    entries = parentdir.ls(force_refresh=True)
    assert len(entries) == 1

    entry = entries[0]
    assert entry.path == testfile.path
    assert entry.id == testfile.id
    assert entry.size == testfile.size

    # create a folder
    testdir = parentdir.mkdir('测试目录-%s' % randstring())
    assert len(parentdir.ls()) == 2
    assert len(testdir.ls()) == 0

    direntry = [entry for entry in parentdir.ls() if entry.isdir][0]
    assert direntry.path == testdir.path

    testfile.delete()
    assert len(parentdir.ls(force_refresh=True)) == 1
    testdir.delete()
    assert len(parentdir.ls(force_refresh=True)) == 0
Пример #4
0
def test_create_delete_file_dir(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    entries = parentdir.ls(force_refresh=True)
    assert len(entries) == 1

    entry = entries[0]
    assert entry.path == testfile.path
    assert entry.id == testfile.id
    assert entry.size == testfile.size

    # create a folder
    testdir = parentdir.mkdir('测试目录-%s' % randstring())
    assert len(parentdir.ls(force_refresh=True)) == 2
    assert len(testdir.ls(force_refresh=True)) == 0

    direntry = [e for e in parentdir.ls(force_refresh=True) if e.isdir][0]
    assert direntry.path == testdir.path

    testfile.delete()
    assert len(parentdir.ls(force_refresh=True)) == 1
    testdir.delete()
    assert len(parentdir.ls(force_refresh=True)) == 0
Пример #5
0
def repo(client):
    repo_name = 'tmp-测试资料库-%s' % randstring()
    repo_desc = 'tmp, 一个测试资料库-%s' % randstring()
    repo = client.repos.create_repo(repo_name, repo_desc)
    try:
        yield repo
    finally:
        repo.delete()
Пример #6
0
def repo(client):
    repo_name = 'tmp-测试资料库-%s' % randstring()
    repo_desc = 'tmp, 一个测试资料库-%s' % randstring()
    repo = client.repos.create_repo(repo_name, repo_desc)
    try:
        yield repo
    finally:
        repo.delete()
Пример #7
0
    def create_tmp_repo(self):
        repos = self.client.repos
        repo_name = 'tmp-测试资料库-%s' % randstring()
        repo_desc = 'tmp, 一个测试资料库-%s' % randstring()
        repo = repos.create_repo(repo_name, repo_desc)

        try:
            yield repo
        finally:
            repo.delete()
Пример #8
0
def test_rename_move_copy(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls()) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    entries = parentdir.ls(force_refresh=True)
    assert len(entries) == 1

    entry = entries[0]
    assert entry.path == testfile.path
    assert entry.id == testfile.id
    assert entry.size == testfile.size

    # rename a file
    newfname = 'newfile.txt'
    testfile.rename(newfname)
    assert testfile.name == newfname

    # create a folder
    testdir = parentdir.mkdir('测试目录-%s' % randstring())
    assert len(parentdir.ls()) == 2
    assert len(testdir.ls()) == 0

    direntry = [entry for entry in parentdir.ls() if entry.isdir][0]
    assert direntry.path == testdir.path

    # move a file to the new folder
    testfile.moveTo(testdir.name, dst_repo=None)

    assert testfile.name == newfname
    fileentry = [entry for entry in testdir.ls() if not entry.isdir][0]
    assert fileentry.path == testfile.path

    # copy a file to the parent folder
    filenames.append(testfile)
    testfile.copyTo(filenames, parentdir.name, dst_repo=None)

    assert testfile.name == newfname
    fileentry = [entry for entry in parentdir.ls() if not entry.isdir][0]
    assert fileentry.path == testfile.path

    # clean up test directories / files
    testfile.delete()
    assert len(parentdir.ls(force_refresh=True)) == 1
    testdir.delete()
    assert len(parentdir.ls(force_refresh=True)) == 0
Пример #9
0
def _create_repo(client, password=None):
    repo_name = '测试资料库-%s' % randstring()
    repo_desc = '一个测试资料库-%s' % randstring()
    repo = client.repos.create_repo(repo_name, repo_desc, password=password)

    assert repo.name == repo_name
    assert repo.desc == repo_desc
    assert len(repo.id) == 36
    assert repo.encrypted == (password is not None)
    assert repo.owner == 'self'

    return repo
Пример #10
0
def _create_repo(client, password=None):
    repo_name = '测试资料库-%s' % randstring()
    repo_desc = '一个测试资料库-%s' % randstring()
    repo = client.repos.create_repo(repo_name, repo_desc, password=password)

    assert repo.name == repo_name
    assert repo.desc == repo_desc
    assert len(repo.id) == 36
    assert repo.encrypted == (password is not None)
    assert repo.owner == 'self'

    return repo
Пример #11
0
    def _create_repo(self, password=None):
        repos = self.client.repos
        repo_name = '测试资料库-%s' % randstring()
        repo_desc = '一个测试资料库-%s' % randstring()
        repo = repos.create_repo(repo_name, repo_desc, password=password)

        self.assertEqual(repo.name, repo_name)
        self.assertEqual(repo.desc, repo_desc)
        self.assertHasLen(repo.id, 36)
        self.assertEqual(repo.encrypted, password != None)
        self.assertEqual(repo.owner, 'self')

        return repo
Пример #12
0
def group(client):
    group_name = randstring()
    group = client.groups.add_group(group_name)
    try:
        yield group
    finally:
        group.delete()
Пример #13
0
def test_move_file_to_other_repo(client, repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    assert len(parentdir.ls(force_refresh=True)) == 1

    temp_repo = client.repos.create_repo('temp_repo')
    try:
        root_dir = temp_repo.get_dir('/')
        temp_dir = root_dir.mkdir('temp_dir')
        assert len(temp_dir.ls(force_refresh=True)) == 0
        testfile.moveTo(temp_dir.path, temp_repo.id)
        assert testfile.path == os.path.join(temp_dir.path, os.path.basename(testfile.path))
        assert len(temp_dir.ls(force_refresh=True)) == 1
        assert testfile.repo.id == temp_repo.id
    finally:
        temp_repo.delete()
Пример #14
0
def repo(client):
    repo_name = 'tmp-testLib-%s' % randstring()
    repo = client.repos.create_repo(repo_name)
    try:
        yield repo
    finally:
        repo.delete()
Пример #15
0
def test_move_folder_to_other_repo(client, repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a folder
    testfolder = parentdir.mkdir('测试文件夹-%s' % randstring())
    assert testfolder.size == 0

    assert len(parentdir.ls(force_refresh=True)) == 1

    temp_repo = client.repos.create_repo('temp_repo')
    try:
        root_folder = temp_repo.get_dir('/')
        tempfolder = root_folder.mkdir('tempfolder')

        assert len(tempfolder.ls(force_refresh=True)) == 0
        # move a folder
        testfolder.moveTo(tempfolder.path, temp_repo.id)
        assert testfolder.path == os.path.join(tempfolder.path, os.path.basename(testfolder.path))
        assert testfolder.repo.id == temp_repo.id
        assert len(tempfolder.ls(force_refresh=True)) == 1
    finally:
        temp_repo.delete()
Пример #16
0
def test_upload_string_as_file_content(repo):
    # test pass as string as file content when upload file
    rootdir = repo.get_dir('/')
    fname = u'testfile-%s' % randstring()
    fcontent = 'line 1\nline 2\n\r'
    f = rootdir.upload(fcontent, fname)
    assert f.name == fname
    assert f.get_content() == fcontent
Пример #17
0
def group():
    group = create_and_get_group('test_group_{}'.format(randstring(10)),
                                 USER,
                                 gtype=None)
    try:
        yield group
    finally:
        if ccnet_api.get_group(group.id):
            ccnet_api.remove_group(group.id)
Пример #18
0
def repo():
    repo = create_and_get_repo(
        'testrepo测试-{}'.format(randstring(10)), '', USER, passwd=None
    )
    try:
        yield repo
    finally:
        if seafile_api.get_repo(repo.id):
            # The repo may be deleted in the test case
            seafile_api.remove_repo(repo.id)
Пример #19
0
def test_copy_file(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    assert len(parentdir.ls(force_refresh=True)) == 1

    tempfolder = parentdir.mkdir('tempfolder_%s' % randstring())
    assert len(tempfolder.ls(force_refresh=True)) == 0
    testfile.copyTo(tempfolder.path)
    assert len(tempfolder.ls(force_refresh=True)) == 1
    assert os.path.basename(tempfolder.ls(force_refresh=True)[-1].path) == os.path.basename(testfile.path)
Пример #20
0
def test_move_folder(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a folder
    testfolder = parentdir.mkdir('测试文件夹-%s' % randstring())
    assert testfolder.size == 0
    tempfolder = parentdir.mkdir('temp-folder-%s' % randstring())
    assert tempfolder.size == 0

    assert len(parentdir.ls(force_refresh=True)) == 2

    # move a folder
    testfolder.moveTo(tempfolder.path)
    assert testfolder.path == os.path.join(tempfolder.path, os.path.basename(testfolder.path))
Пример #21
0
def repo():
    repo = create_and_get_repo(
        'test_repo_{}'.format(randstring(10)), '', USER, passwd=None
    )
    try:
        seafile_api.post_dir(repo.id, '/', 'dir1', USER)
        seafile_api.post_dir(repo.id, '/', 'dir2', USER)
        yield repo
    finally:
        if seafile_api.get_repo(repo.id):
            # The repo may be deleted in the test case
            seafile_api.remove_repo(repo.id)
Пример #22
0
def encrypted_repo():
    repo = create_and_get_repo(
        'test_repo_{}'.format(randstring(10)), '', USER, passwd='123'
    )
    try:
        syncwerk_api.post_dir(repo.id, '/', 'dir1', USER)
        syncwerk_api.post_dir(repo.id, '/', 'dir2', USER)
        syncwerk_api.post_dir(repo.id, '/dir1', 'subdir1', USER)
        syncwerk_api.post_dir(repo.id, '/dir2', 'subdir2', USER)
        yield repo
    finally:
        if syncwerk_api.get_repo(repo.id):
            # The repo may be deleted in the test case
            syncwerk_api.remove_repo(repo.id)
Пример #23
0
def test_rename_folder(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a folder
    testfolder = parentdir.mkdir('测试文件夹-%s' % randstring())
    assert testfolder.size == 0

    assert len(parentdir.ls(force_refresh=True)) == 1

    # rename a file
    newfname = 'newfolder'
    testfolder.rename(newfname)
    assert newfname == testfolder.name
Пример #24
0
def test_rename_file(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    assert len(parentdir.ls(force_refresh=True)) == 1

    # rename a file
    newfname = 'newfile.txt'
    testfile.rename(newfname)
    assert newfname == testfile.name
Пример #25
0
 def test_create_encrypted_repo(self):
     repo = self._create_repo(password=randstring())
     repo.delete()
     with self.assertRaises(DoesNotExist):
         self.client.repos.get_repo(repo.id)
Пример #26
0
def test_create_encrypted_repo(client):
    repo = _create_repo(client, password=randstring())
    repo.delete()
    with pytest.raises(DoesNotExist):
        client.repos.get_repo(repo.id)
#coding: UTF-8

import os
import pytest

from tests.utils import randstring, datafile, filesize


@pytest.mark.parametrize('parentpath', ['/', '/测试目录一-%s' % randstring()])
def test_create_delete_file_dir(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    entries = parentdir.ls(force_refresh=True)
    assert len(entries) == 1

    entry = entries[0]
    assert entry.path == testfile.path
    assert entry.id == testfile.id
    assert entry.size == testfile.size

    # create a folder
Пример #28
0
#coding: UTF-8

import os
import pytest

from tests.utils import randstring, datafile, filesize

@pytest.mark.parametrize('parentpath', [
    '/',
    '/testDir-%s' % randstring()
])
def test_create_delete_file_dir(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    entries = parentdir.ls(force_refresh=True)
    assert len(entries) == 1

    entry = entries[0]
    assert entry.path == testfile.path
    assert entry.id == testfile.id
    assert entry.size == testfile.size
Пример #29
0
#coding: UTF-8

import pytest

from tests.utils import randstring, datafile, filesize

@pytest.mark.parametrize('parentpath', [
    '/',
    '/测试目录一-%s' % randstring()
])
def test_create_delete_file_dir(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls()) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    entries = parentdir.ls(force_refresh=True)
    assert len(entries) == 1

    entry = entries[0]
    assert entry.path == testfile.path
    assert entry.id == testfile.id
    assert entry.size == testfile.size
Пример #30
0
import pytest

from tests.utils import randstring


def test_accounts_list(client):
    accounts = client.admin.list_accounts()
    assert len(accounts) > 0


def test_server_info(client):
    info = client.admin.server_info()
    assert 'version' in info


@pytest.mark.parametrize('password', [randstring(6)])
@pytest.mark.parametrize('name', [randstring(6)])
@pytest.mark.parametrize('email', ['{}@test.com'.format(randstring(6))])
def test_cud_account(client, email, password, Account, name):
    # create account
    test_account = client.admin.create_account(email, password)
    assert isinstance(test_account, Account)
    assert client.admin.get_account(test_account.email) == test_account

    # upadte account fields
    test_account.name = name
    test_account.is_staff = True
    test_account.is_active = True
    #test_account.update()
    assert test_account.name == name
    assert test_account in client.admin.list_accounts(start=-1, limit=-1)
Пример #31
0
#coding: UTF-8

import os
import sys
import pytest

from tests.utils import randstring, datafile, filesize

@pytest.mark.parametrize('parentpath', [
    '/',
    '/测试目录一-%s' % randstring()
])
def test_create_delete_file_dir(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls(force_refresh=True)) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    entries = parentdir.ls(force_refresh=True)
    assert len(entries) == 1

    entry = entries[0]
    assert entry.path == testfile.path
    assert entry.id == testfile.id
Пример #32
0
def test_multi_tier_groups(repo):
    id1 = ccnet_api.create_group('group1', USER, parent_group_id=-1)
    id2 = ccnet_api.create_group('group2', USER2, parent_group_id = id1)
    id3 = ccnet_api.create_group('group3', USER, parent_group_id = id1)
    id4 = ccnet_api.create_group('group4', USER2, parent_group_id = id3)
    id5 = ccnet_api.create_group('group5', USER2, parent_group_id = 0)
    assert id1 != -1 and id2 != -1 and id3 != -1 and id4 != -1

    group1 = ccnet_api.get_group(id1)
    group2 = ccnet_api.get_group(id2)
    group3 = ccnet_api.get_group(id3)
    group4 = ccnet_api.get_group(id4)
    assert group1.parent_group_id == -1
    assert group2.parent_group_id == id1
    assert group3.parent_group_id == id1
    assert group4.parent_group_id == id3

    members = ccnet_api.search_group_members (id1, 'randgroup{}'.format(randstring(6)))
    assert len(members) == 0
    members = ccnet_api.search_group_members (id1, USER)
    assert len(members) == 1
    assert members[0].user_name == USER

    ances_order = [id5, id4, id3, id2, id1]
    user2_groups_with_ancestors = ccnet_api.get_groups (USER2, return_ancestors = True)
    assert len(user2_groups_with_ancestors) == 5
    i = 0
    for g in user2_groups_with_ancestors:
        assert g.id == ances_order[i]
        i = i + 1

    order = [id5, id4, id2]
    i = 0
    user2_groups = ccnet_api.get_groups (USER2)
    assert len(user2_groups) == 3
    for g in user2_groups:
        assert g.id == order[i]
        i = i + 1

    top_groups = ccnet_api.get_top_groups(True)
    assert len(top_groups) == 1
    for g in top_groups:
        assert g.parent_group_id == -1

    child_order = [id2, id3]
    i = 0
    id1_children = ccnet_api.get_child_groups(id1)
    assert len(id1_children) == 2
    for g in id1_children:
        assert g.id == child_order[i]
        i = i + 1

    group4_order = [id1, id3, id4]
    i = 0
    group4_ancestors = ccnet_api.get_ancestor_groups(id4)
    assert len(group4_ancestors) == 3
    for g in group4_ancestors:
        assert g.id == group4_order[i]
        i = i + 1

    rm5 = ccnet_api.remove_group(id5)
    rm4 = ccnet_api.remove_group(id4)
    rm3 = ccnet_api.remove_group(id3)
    rm2 = ccnet_api.remove_group(id2)
    rm1 = ccnet_api.remove_group(id1)
    assert rm5 == 0 and rm4 == 0 and rm3 == 0 and rm2 == 0 and rm1 == 0
Пример #33
0
#coding: UTF-8

import pytest

from tests.utils import randstring, datafile, filesize

@pytest.mark.parametrize('parentpath', [
    '/',
    '/测试目录一-%s' % randstring()
])
def test_create_delete_file_dir(repo, parentpath):
    rootdir = repo.get_dir('/')
    assert len(rootdir.ls()) == 0

    if parentpath == '/':
        parentdir = rootdir
    else:
        parentdir = rootdir.mkdir(parentpath[1:])

    # create a file
    testfile = parentdir.create_empty_file('测试文件-%s.txt' % randstring())
    assert testfile.size == 0

    entries = parentdir.ls(force_refresh=True)
    assert len(entries) == 1

    entry = entries[0]
    assert entry.path == testfile.path
    assert entry.id == testfile.id
    assert entry.size == testfile.size
Пример #34
0
def test_create_encrypted_repo(client):
    repo = _create_repo(client, password=randstring())
    repo.delete()
    with pytest.raises(DoesNotExist):
        client.repos.get_repo(repo.id)
Пример #35
0
def test_user_management(repo):
    email1 = '%s@%s.com' % (randstring(6), randstring(6))
    email2 = '%s@%s.com' % (randstring(6), randstring(6))
    passwd1 = 'randstring(6)'
    passwd2 = 'randstring(6)'

    ccnet_api.add_emailuser(email1, passwd1, 1, 1)
    ccnet_api.add_emailuser(email2, passwd2, 0, 0)

    ccnet_email1 = ccnet_api.get_emailuser(email1)
    ccnet_email2 = ccnet_api.get_emailuser(email2)
    assert ccnet_email1.is_active == True
    assert ccnet_email1.is_staff == True
    assert ccnet_email2.is_active == False
    assert ccnet_email2.is_staff == False

    assert ccnet_api.validate_emailuser(email1, passwd1) == 0
    assert ccnet_api.validate_emailuser(email2, passwd2) == 0

    users = ccnet_api.search_emailusers('DB', email1, -1, -1)
    assert len(users) == 1
    user_ccnet = users[0]
    assert user_ccnet.email == email1

    user_counts = ccnet_api.count_emailusers('DB')
    user_numbers = ccnet_api.get_emailusers('DB', -1, -1)

    ccnet_api.update_emailuser('DB', ccnet_email2.id, passwd2, 1, 1)
    email2_new = ccnet_api.get_emailuser(email2)
    assert email2_new.is_active == True
    assert email2_new.is_staff == True

    #test group when update user id
    id1 = ccnet_api.create_group('group1', email1, parent_group_id=-1)
    assert id1 != -1
    group1 = ccnet_api.get_group(id1)
    assert group1.parent_group_id == -1

    # test shared repo when update user id
    api.share_repo(repo.id, USER, email1, "rw")
    assert api.repo_has_been_shared(repo.id)

    new_email1 = '%s@%s.com' % (randstring(6), randstring(6))
    assert ccnet_api.update_emailuser_id(email1, new_email1) == 0

    shared_users = api.list_repo_shared_to(USER, repo.id)
    assert len(shared_users) == 1
    assert shared_users[0].repo_id == repo.id
    assert shared_users[0].user == new_email1
    assert shared_users[0].perm == "rw"

    api.remove_share(repo.id, USER, new_email1)

    email1_groups = ccnet_api.get_groups(new_email1)
    assert len(email1_groups) == 1
    assert email1_groups[0].id == id1
    rm1 = ccnet_api.remove_group(id1)
    assert rm1 == 0

    ccnet_api.remove_emailuser('DB', new_email1)
    ccnet_api.remove_emailuser('DB', email2)