コード例 #1
0
def test_remove_pipeline(client, client_application, pipeline, workflow,
                         workflow_pipeline):
    db.session.commit()
    result = client.delete(
        f"/v1/pipelines/{pipeline.uuid}",
        content_type="application/json",
        headers={ROLES_KEY: client_application.api_key},
    )
    assert result.status_code == 400
    assert find_pipeline(pipeline.uuid) == pipeline

    p1 = Pipeline(
        name="pipeline 1",
        description="a description",
        docker_image_url="",
        repository_ssh_url="",
        repository_branch="",
    )
    db.session.add(p1)
    db.session.commit()
    result = client.delete(
        f"/v1/pipelines/{p1.uuid}",
        content_type="application/json",
        headers={ROLES_KEY: client_application.api_key},
    )
    assert result.status_code == 200
    assert find_pipeline(p1.uuid) is None
コード例 #2
0
def test_find_pipelines(app, pipeline):
    p2 = Pipeline(
        name="pipeline 2",
        description="description 2",
    )
    deleted_p = Pipeline(
        name="a pipeline", description="a description", is_deleted=True
    )
    db.session.add(p2)
    db.session.add(deleted_p)
    db.session.commit()

    assert set(find_pipelines()) == set([pipeline, p2])
    assert set(find_pipelines({"uuids": [p2.uuid, deleted_p.uuid]})) == set([p2])
    assert set(find_pipelines({"uuids": [p2.uuid, pipeline.uuid]})) == set(
        [pipeline, p2]
    )
コード例 #3
0
def test_find_pipeline(app):
    pipeline = Pipeline(
        name="a pipeline",
        description="a description",
    )
    db.session.add(pipeline)
    db.session.commit()

    assert find_pipeline(pipeline.uuid) == pipeline
コード例 #4
0
def test_create_pipeline(app):
    """ A new pipeline model does save to the database. """
    pipeline = Pipeline(
        name="a pipeline",
        description="a description",
    )
    db.session.add(pipeline)
    db.session.commit()

    assert set(Pipeline.query.all()) == set([pipeline])
    assert len(pipeline.uuid) > 0
    assert not pipeline.is_deleted
コード例 #5
0
def pipeline(app):
    pipeline = Pipeline(
        name="a pipeline",
        description="a description",
        docker_image_url="",
        repository_ssh_url="",
        repository_branch="",
    )
    db.session.add(pipeline)
    db.session.commit()

    return pipeline
コード例 #6
0
def test_list_pipelines(client, client_application):
    db.session.commit()
    result = client.get(
        "/v1/pipelines",
        content_type="application/json",
        headers={ROLES_KEY: client_application.api_key},
    )
    assert result.status_code == 200
    assert len(result.json) == 0

    p1 = Pipeline(
        name="pipeline 1",
        description="a description",
        docker_image_url="",
        repository_ssh_url="",
        repository_branch="",
    )
    db.session.add(p1)
    p2 = Pipeline(
        name="pipeline 2",
        description="a description",
        docker_image_url="",
        repository_ssh_url="",
        repository_branch="",
    )
    db.session.add(p2)
    db.session.commit()

    result = client.get(
        "/v1/pipelines",
        content_type="application/json",
        headers={ROLES_KEY: client_application.api_key},
    )
    assert result.status_code == 200
    assert len(result.json) == 2
    assert result.json[0]["name"] == p1.name
    assert result.json[1]["name"] == p2.name
コード例 #7
0
def test_pipeline_has_workflow_pipeline(app, workflow, pipeline,
                                        workflow_pipeline):
    assert queries.pipeline_has_workflow_pipeline(pipeline.id)

    p1 = Pipeline(
        name="pipeline 1",
        description="a description",
        docker_image_url="",
        repository_ssh_url="",
        repository_branch="",
    )
    db.session.add(p1)
    db.session.commit()

    assert not queries.pipeline_has_workflow_pipeline(p1.id)
コード例 #8
0
def test_find_pipeline_is_deleted(app):
    pipeline = Pipeline(name="a pipeline", description="a description", is_deleted=True)
    db.session.add(pipeline)
    db.session.commit()

    assert find_pipeline(pipeline.uuid) is None