Ejemplo n.º 1
0
def import_plain(prj_id):
    params = ImportReq(source_path=str(PLAIN_DIR), skip_existing_objects=True)
    with FileImport(prj_id, params) as sce:
        rsp: ImportRsp = sce.run(ADMIN_USER_ID)
    job = wait_for_stable(rsp.job_id)

    assert job.state == DBJobStateEnum.Asking
    assert job.question == {
        "missing_users": ["admin4test", "elizandro rodriguez"],
        "missing_taxa": ["other", "ozzeur"]
    }

    reply = {
        "users": {
            'admin4test': 1,
            'elizandro rodriguez': 1
        },  # Map to admin
        "taxa": {
            'other': 99999,  # 'other<dead'
            'ozzeur': 85011  # 'other<living'
        }
    }
    with JobCRUDService() as sce:
        sce.reply(ADMIN_USER_ID, rsp.job_id, reply)
    job = wait_for_stable(rsp.job_id)
    check_job_ok(job)
Ejemplo n.º 2
0
def do_import(prj_id: int, source_path: str, user_id: int):
    """ Import helper for tests """
    # Do preparation, preparation
    params = ImportReq(source_path=str(source_path))
    with FileImport(prj_id, params) as sce:
        rsp: ImportRsp = sce.run(user_id)
    job = wait_for_stable(rsp.job_id)
    job = fill_in_if_missing(job)
    check_job_ok(job)
    return prj_id
Ejemplo n.º 3
0
def test_import_uvp6(config, database, caplog, title):
    caplog.set_level(logging.DEBUG)
    prj_id = create_project(ADMIN_USER_ID, title)
    params = ImportReq(source_path=str(V6_FILE))
    with FileImport(prj_id, params) as sce:
        rsp: ImportRsp = sce.run(ADMIN_USER_ID)
    job = wait_for_stable(rsp.job_id)
    check_job_ok(job)
    # Check that all went fine
    for a_msg in caplog.records:
        assert a_msg.levelno != logging.ERROR, a_msg.getMessage()
    return prj_id
Ejemplo n.º 4
0
def test_import_uvp6_zip_in_dir(config, database, caplog):
    """
        An *Images.zip inside a directory.
    """
    caplog.set_level(logging.DEBUG)
    prj_id = create_project(ADMIN_USER_ID, "Test LS 8")

    params = ImportReq(source_path=str(V6_DIR))
    with FileImport(prj_id, params) as sce:
        rsp: ImportRsp = sce.run(ADMIN_USER_ID)
    job = wait_for_stable(rsp.job_id)
    check_job_ok(job)
    # Check that all went fine
    for a_msg in caplog.records:
        assert a_msg.levelno != logging.ERROR, a_msg.getMessage()
Ejemplo n.º 5
0
def test_import_a_bit_more_skipping(config, database, caplog, title):
    """ Re-import similar files into same project, with an extra one.
        The extra one has missing values in the TSV.
        CANNOT RUN BY ITSELF """
    caplog.set_level(logging.DEBUG)
    srch = search_unique_project(ADMIN_USER_ID, title)
    prj_id = srch.projid  # <- need the project from first test
    # Do preparation
    params = ImportReq(source_path=str(PLUS_DIR),
                       skip_loaded_files=True,
                       skip_existing_objects=True)
    with FileImport(prj_id, params) as sce:
        rsp: ImportRsp = sce.run(ADMIN_USER_ID)
    job = wait_for_stable(rsp.job_id)
    job = fill_in_if_missing(job)
    check_job_ok(job)
Ejemplo n.º 6
0
def do_import_update(prj_id, caplog, classif, source=None):
    if source is None:
        source = str(UPDATE_DIR)
    params = ImportReq(skip_existing_objects=True,
                       update_mode=classif,
                       source_path=source)
    with FileImport(prj_id, params) as sce:
        rsp: ImportRsp = sce.run(ADMIN_USER_ID)
    job = wait_for_stable(rsp.job_id)

    assert job.state == DBJobStateEnum.Asking
    assert job.question == {
        "missing_users": ["admin4test", "elizandro rodriguez"],
        "missing_taxa": ["other", "ozzeur"]
    }

    reply = {
        "users": {
            'admin4test': 1,
            'elizandro rodriguez': 1
        },  # Map to admin
        "taxa": {
            'other': 99999,  # 'other<dead'
            'ozzeur': 85011  # 'other<living'
        }
    }
    caplog.clear()
    with JobCRUDService() as sce:
        sce.reply(ADMIN_USER_ID, rsp.job_id, reply)
    job = wait_for_stable(rsp.job_id)
    check_job_ok(job)
    # Check that all went fine
    for a_msg in caplog.records:
        assert a_msg.levelno != logging.ERROR, a_msg.getMessage()
    # #498: No extra parent should be created
    for a_msg in caplog.records:
        assert "++ ID" not in a_msg.getMessage()