示例#1
0
def test_index_project_files_no_plugins():
    remove_db()
    time.sleep(1)
    with db.DbHelper():
        pass
    th = SubprocessTaskHandle()
    backend.index_project_files(th, [PATH], [], [])
    with db.DbHelper() as dbh:
        assert len(list(dbh.get_files())) == 3
        assert len(list(dbh.get_symbols())) == 0
示例#2
0
def test_index_project_files_with_plugins():
    remove_db()
    time.sleep(1)
    with db.DbHelper():
        pass
    th = SubprocessTaskHandle()
    backend.index_project_files(th, [PATH], [], [FakeParserPlugin()])
    with db.DbHelper() as dbh:
        for row in dbh.get_files():
            print(row[db.COL_FILE_PATH])
        assert len(list(dbh.get_files())) == 3
        assert len(list(dbh.get_symbols())) == 3
示例#3
0
def test_rename_files():
    remove_db()
    time.sleep(1)
    with db.DbHelper():
        pass
    # create a new temporary file that will get renamed
    with open(NEW_FILE, 'w'):
        pass
    th = SubprocessTaskHandle()
    backend.index_project_files(th, [PATH], [], [FakeParserPlugin()])
    with db.DbHelper() as dbh:
        assert len(list(dbh.get_files())) == 4
    os.rename(NEW_FILE, RENAMED_FILE)

    backend.rename_files(th, [(NEW_FILE, RENAMED_FILE)])

    with db.DbHelper() as dbh:
        assert len(list(dbh.get_files())) == 4
示例#4
0
def test_update_file():
    remove_db()
    time.sleep(1)
    with db.DbHelper():
        pass
    th = SubprocessTaskHandle()
    backend.index_project_files(th, [PATH], [], [FakeParserPlugin()])

    with db.DbHelper() as dbh:
        fid = dbh.get_file_by_path(SETUP_PY)
    backend.update_file(th, SETUP_PY, fid, PATH, 1,
                        [FakeParserPlugin()])
    # update file time stamp
    with open(SETUP_PY, 'r') as fin:
        with open(SETUP_PY, 'w') as fout:
            fout.write(fin.read())
    backend.update_file(th, SETUP_PY, fid, PATH, 1,
                        [FakeParserPlugin()])
示例#5
0
def test_cleanup():
    remove_db()
    time.sleep(1)
    with db.DbHelper():
        pass
    # create a new temporary file that will get renamed
    with open(NEW_FILE, 'w'):
        pass
    th = SubprocessTaskHandle()
    backend.index_project_files(th, [PATH], [], [FakeParserPlugin()])
    with db.DbHelper() as dbh:
        nb_files = len(list(dbh.get_files()))
    os.remove(NEW_FILE)

    # reindexing should remove the deleted file
    backend.index_project_files(th, [PATH], [], [FakeParserPlugin()])
    with db.DbHelper() as dbh:
        assert len(list(dbh.get_files())) == nb_files - 1