Exemple #1
0
def test_put_pipeline():
    db = get_db()()
    pl = random_pipeline()
    db.add(pl)
    db.commit()
    app = make_app()
    c = Client(app, Resp)
    url = unwrap_app(app).url(
        'pipeline_detail',
        dict(
            service_name=pl.service.name,
            pipeline_name=pl.name,
        ))

    new_data = dict(
        active=False,
        retries=10,
        crontab='1 1 1 1 1',
    )
    resp = c.put(url,
                 data=json.dumps(new_data),
                 content_type='application/json')
    assert resp.status_code == 200

    api_data = resp.json()
    db.refresh(pl)
    for k, v in new_data.items():
        # Response data should show our changes.
        assert api_data[k] == v
        # Database should contain our changes.
        assert getattr(pl, k) == v

    assert pl.updated_by == DEV_USERNAME
Exemple #2
0
def test_new_crontab_pipeline():
    db = get_db()()
    svc = random_service()
    nl = random_notification_list()
    db.add(svc)
    db.add(nl)
    db.commit()
    app = make_app()
    c = Client(app, Resp)
    url = unwrap_app(app).url('pipeline_list', dict(service_name=svc.name, ))

    data = dict(
        name=svc.pipeline_names[0],
        notification_list_id=nl.id,
        retries=4,
        crontab='0 0 0 1 1',
    )
    resp = c.post(url, data=json.dumps(data), content_type='application/json')
    assert resp.status_code == 302

    url = unwrap_app(app).url(
        'pipeline_detail',
        dict(
            service_name=svc.name,
            pipeline_name=svc.pipeline_names[0],
        ))
    assert resp.headers['Location'] == 'http://localhost' + url

    content = json.loads(resp.data)
    for k, v in data.items():
        assert content[k] == v
Exemple #3
0
def test_get_pipeline():
    db = get_db()()
    pl = random_pipeline()
    db.add(pl)
    db.commit()
    app = make_app()
    c = Client(app, Resp)
    url = unwrap_app(app).url(
        'pipeline_detail',
        dict(
            service_name=pl.service.name,
            pipeline_name=pl.name,
        ))
    resp = c.get(url)
    assert resp.status_code == 200
    data = resp.json()
    assert data['name'] == pl.name
    assert data['service_id'] == pl.service.id
Exemple #4
0
def test_cannot_change_pipeline_svc():
    db = get_db()()
    pl = random_pipeline()
    db.add(pl)
    db.commit()
    app = make_app()
    c = Client(app, Resp)
    url = unwrap_app(app).url(
        'pipeline_detail',
        dict(
            service_name=pl.service.name,
            pipeline_name=pl.name,
        ))

    new_data = dict(service_id=0)
    resp = c.put(url,
                 data=json.dumps(new_data),
                 content_type='application/json')
    assert resp.status_code == 400