예제 #1
0
def test_bid_create_invalid(app, db, session):
    data = dict(test_bid_data_1)
    del data['cost']

    with pytest.raises(DBError):
        api.bid_create(data, scoped_context)
    test_bid_data_1['creator_bid_id'] = '12a59a51-b4d6-497d-9f75-f56c409305c8'
예제 #2
0
def test_bid_get_all_unexpired(app, db, session):
    api.bid_create(test_bid_data_1, scoped_context)
    api.bid_create(test_bid_data_2, scoped_context)

    bids = api.bid_get_all(scoped_context)

    assert len(api.bid_get_all(scoped_context)) == 2
    assert len(api.bid_get_all_unexpired(scoped_context)) == 2

    api.bid_update(bids[1].marketplace_bid_id, dict(status='expired'),
                   scoped_context)
    assert len(api.bid_get_all_unexpired(scoped_context)) == 1
예제 #3
0
def test_bid_update(app, db, session):
    bid = api.bid_create(test_bid_data)
    bid = api.bid_update(bid.marketplace_bid_id, dict(status='testing'))
    check = api.bid_get(bid.marketplace_bid_id)

    assert check.status == 'testing'
    assert check.creator_id == '12a59a51-b4d6-497d-9f75-f56c409305c8'
예제 #4
0
def test_bid_update_scoped_valid(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)
    bid = api.bid_update(bid.marketplace_bid_id, dict(status='testing'),
                         scoped_context)
    check = api.bid_get(bid.marketplace_bid_id, scoped_context)

    assert check.status == 'testing'
예제 #5
0
def test_bid_update_scoped_valid(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)
    bid = api.bid_update(bid.bid_id, dict(status=statuses.EXPIRED),
                         scoped_context)
    check = api.bid_get(bid.bid_id, scoped_context)

    assert check.status == statuses.EXPIRED
예제 #6
0
def test_bid_update_scoped_invalid(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)

    with pytest.raises(e.ResourceNoPermission) as excinfo:
        api.bid_update(bid.bid_id, dict(status=statuses.EXPIRED),
                       scoped_context_2)
    assert (excinfo.value.code == 403)
    assert (api.bid_get(bid.bid_id, scoped_context).status != statuses.EXPIRED)
예제 #7
0
def create_test_contract_data_for_ocr():
    bid = api.bid_create(test_bid_data_1, scoped_context)
    offer = api.offer_create(test_offer_data, scoped_context)

    contract_data = dict(time_created=now,
                         status='available',
                         start_time=now - timedelta(days=2),
                         end_time=now - timedelta(days=1),
                         cost=0.0,
                         bid_id=bid.marketplace_bid_id,
                         offers=[offer.marketplace_offer_id],
                         project_id='5599')

    return contract_data, offer.marketplace_offer_id
예제 #8
0
def create_test_contract_data_for_ocr(is_resource_admin):
    is_resource_admin.return_value = True
    bid = api.bid_create(test_bid_data_1, scoped_context)
    offer = api.offer_create(test_offer_data, scoped_context)

    contract_data = dict(time_created=now,
                         status=statuses.AVAILABLE,
                         start_time=now - timedelta(days=2),
                         end_time=now - timedelta(days=1),
                         cost=0.0,
                         bid_id=bid.bid_id,
                         offers=[offer.offer_id],
                         project_id='5599')

    return contract_data, offer.offer_id
예제 #9
0
 def create(cls, data, context):
     b = db.bid_create(data, context)
     return cls._from_db_object(cls(), b)
예제 #10
0
def test_bid_update_scoped_invalid(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)
    updated = api.bid_update(bid.marketplace_bid_id, dict(status='testing'),
                             scoped_context_2)

    assert updated is None
예제 #11
0
def test_bid_delete_admin(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)
    api.bid_destroy(bid.marketplace_bid_id, admin_context)
    check = api.bid_get(bid.marketplace_bid_id, scoped_context)
    assert check is None
예제 #12
0
def test_bid_delete_scoped_invalid(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)
    api.bid_destroy(bid.marketplace_bid_id, scoped_context_2)
    check = api.bid_get(bid.marketplace_bid_id, scoped_context)
    assert check is not None
예제 #13
0
def test_bid_create(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)
    check = api.bid_get(bid.marketplace_bid_id, scoped_context)

    assert check.to_dict() == bid.to_dict()
예제 #14
0
def test_bid_delete(app, db, session):
    bid = api.bid_create(test_bid_data)
    api.bid_destroy(bid.marketplace_bid_id)
    check = api.bid_get(bid.marketplace_bid_id)
    assert check is None
예제 #15
0
def test_bid_get_all(app, db, session):
    api.bid_create(test_bid_data)
    api.bid_create(test_bid_data)

    assert len(api.bid_get_all()) == 2
예제 #16
0
def test_bid_get_all_by_project_id(app, db, session):
    api.bid_create(test_bid_data_1, scoped_context)
    api.bid_create(test_bid_data_2, scoped_context)

    assert len(api.bid_get_all(admin_context)) == 2
예제 #17
0
def test_bid_create(app, db, session):
    bid = api.bid_create(test_bid_data)
    check = api.bid_get(bid.marketplace_bid_id)

    assert check.to_dict() == bid.to_dict()
예제 #18
0
def test_bid_delete_scoped_invalid(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)
    with pytest.raises(e.ResourceNoPermission) as excinfo:
        api.bid_destroy(bid.marketplace_bid_id, scoped_context_2)
    assert (excinfo.value.code == 403)
    assert (api.bid_get(bid.marketplace_bid_id, scoped_context))
예제 #19
0
def test_bid_delete_admin(app, db, session):
    bid = api.bid_create(test_bid_data_1, scoped_context)
    api.bid_destroy(bid.marketplace_bid_id, admin_context)
    with pytest.raises(e.ResourceNotFound) as excinfo:
        api.bid_get(bid.marketplace_bid_id, scoped_context)
    assert (excinfo.value.code == 404)