Ejemplo n.º 1
0
def test_patch_project(
    db: DBInterface,
    db_session: sqlalchemy.orm.Session,
):
    project_name = "project-name"
    project_description = "some description"
    project_created = datetime.datetime.utcnow()
    db.create_project(
        db_session,
        mlrun.api.schemas.Project(
            metadata=mlrun.api.schemas.ProjectMetadata(name=project_name),
            spec=mlrun.api.schemas.ProjectSpec(
                description=project_description),
        ),
    )

    patched_project_description = "some description 2"
    patched_project_labels = {
        "some-label": "some-label-value",
    }
    db.patch_project(
        db_session,
        project_name,
        {
            "metadata": {
                "created": project_created,
                "labels": patched_project_labels
            },
            "spec": {
                "description": patched_project_description
            },
        },
    )
    project_output = db.get_project(db_session, project_name)
    assert project_output.metadata.name == project_name
    assert project_output.spec.description == patched_project_description
    # Created in request body should be ignored and set by the DB layer
    assert project_output.metadata.created != project_created
    assert (deepdiff.DeepDiff(
        patched_project_labels,
        project_output.metadata.labels,
        ignore_order=True,
    ) == {})
Ejemplo n.º 2
0
def test_patch_project(
    db: DBInterface,
    db_session: sqlalchemy.orm.Session,
):
    project_name = "project-name"
    project_description = "some description"
    db.create_project(
        db_session,
        mlrun.api.schemas.Project(name=project_name,
                                  description=project_description),
    )

    updated_project_description = "some description 2"
    db.patch_project(
        db_session,
        project_name,
        mlrun.api.schemas.ProjectPatch(
            description=updated_project_description),
    )
    project_output = db.get_project(db_session, project_name)
    assert project_output.name == project_name
    assert project_output.description == updated_project_description