예제 #1
0
파일: test_basic.py 프로젝트: RCReddy/frp
def test_add_donations(test_db, seed_db, test_client):
    with app.app_context():
        campaign = Campaign.query.all()[0]
        total_donations = campaign.total_donations()
        donation = add_donation(campaign, 1000)
        x = test_client.get("/campaign/"+str(donation.campaign.id))
        soup = BeautifulSoup(x.data)
        total_donations += donation.amount
        percent_funded = (total_donations*100.0)/campaign.target()
        assert soup.find('div', {'class': "funds-raised"}).contents[1].text == str(int(round(percent_funded)))+'%'
예제 #2
0
def test_add_donations(test_db, seed_db, test_client):
    with app.app_context():
        campaign = Campaign.query.all()[0]
        total_donations = campaign.total_donations()
        donation = add_donation(campaign, 1000)
        x = test_client.get("/campaign/" + str(donation.campaign.url()))
        soup = BeautifulSoup(x.data)
        total_donations += donation.amount
        percent_funded = (total_donations * 100.0) / campaign.target()
        assert soup.find('div', {
            'class': "funds-raised"
        }).contents[1].text == str(int(round(percent_funded))) + '%'
예제 #3
0
파일: test_basic.py 프로젝트: RCReddy/frp
def test_del_donations(test_db, seed_db, test_client):
    with app.app_context():
        campaign = Campaign.query.all()[0]
        for i in range(1,6):
            donation = add_donation(campaign, 1000)
        donation = Donation.query.filter_by(identification="ABCDEF").first()
        campaign = donation.campaign
        total_donations = campaign.total_donations()
        total_donations -= donation.amount
        db.session.delete(donation)
        db.session.commit()
        x = test_client.get("/campaign/"+str(campaign.id))
        soup = BeautifulSoup(x.data)
        percent_funded = (total_donations*100.0)/campaign.target()
        assert soup.find('div', {'class': "funds-raised"}).contents[1].text == str(int(round(percent_funded)))+'%'
예제 #4
0
def test_del_donations(test_db, seed_db, test_client):
    with app.app_context():
        campaign = Campaign.query.all()[0]
        for i in range(1, 6):
            donation = add_donation(campaign, 1000)
        donation = Donation.query.filter_by(identification="ABCDEF").first()
        campaign = donation.campaign
        total_donations = campaign.total_donations()
        total_donations -= donation.amount
        db.session.delete(donation)
        db.session.commit()
        x = test_client.get("/campaign/" + str(campaign.url()))
        soup = BeautifulSoup(x.data)
        percent_funded = (total_donations * 100.0) / campaign.target()
        assert soup.find('div', {
            'class': "funds-raised"
        }).contents[1].text == str(int(round(percent_funded))) + '%'