def test_product_view_accessible(db, user):
    product_view = ProductView(name="other")
    assert product_view.is_accessible(user)

    product_view = ProductView(name="other", token="testtoken")
    assert product_view.is_accessible(user, "testtoken")
    assert not product_view.is_accessible(user)

    product_view = ProductView(name="cfp", cfp_accepted_only=True)
    assert not product_view.is_accessible(user)

    proposal = TalkProposal()
    proposal.title = "title"
    proposal.description = "description"
    proposal.requirements = "requirements"
    proposal.user = user
    db.session.add(proposal)
    db.session.commit()
    proposal.set_state("accepted")

    assert product_view.is_accessible(user)
Example #2
0
def test_product_view_accessible(db, user):
    product_view = ProductView(name="other")
    assert product_view.is_accessible(user)

    product_view = ProductView(name="other", token="testtoken")
    assert product_view.is_accessible(user, "testtoken")
    assert not product_view.is_accessible(user)

    product_view = ProductView(name="cfp", cfp_accepted_only=True)
    assert not product_view.is_accessible(user)

    proposal = TalkProposal()
    proposal.title = "title"
    proposal.description = "description"
    proposal.requirements = "requirements"
    proposal.user = user
    db.session.add(proposal)
    db.session.commit()
    proposal.set_state('accepted')

    assert product_view.is_accessible(user)
Example #3
0
def test_product_view_accessible(db, user, monkeypatch):
    product_view = ProductView(name="other", type="ticket")
    assert product_view.is_accessible(user), "Default view should be visible"

    product_view = ProductView(name="another-other", type="ticket", vouchers_only=True)
    voucher = Voucher(view=product_view)

    db.session.add(product_view)
    db.session.add(voucher)
    db.session.commit()

    assert product_view.is_accessible(
        user, voucher.code
    ), "Product should be visible with voucher"

    assert not product_view.is_accessible(
        user
    ), "Product should be inaccessible without voucher"

    assert not product_view.is_accessible(
        user, "wrong"
    ), "Product should be inaccessible with incorrect voucher"

    product_view = ProductView(name="cfp", cfp_accepted_only=True, type="ticket")
    assert not product_view.is_accessible(
        user
    ), "CfP products should not be visible without accepted proposal"

    proposal = TalkProposal()
    proposal.title = "title"
    proposal.description = "description"
    proposal.requirements = "requirements"
    proposal.user = user
    db.session.add(proposal)
    db.session.commit()
    proposal.set_state("accepted")

    assert product_view.is_accessible(
        user
    ), "CfP products should be visible with accepted proposal"
Example #4
0
def test_cfp(db, app, user, outbox, title, description, requirements):
    for c in ["\0", "\r", "\n"]:
        assume(c not in title)

    assume("\0" not in description)
    assume("\0" not in requirements)

    proposal = TalkProposal()
    proposal.title = title
    proposal.description = description
    proposal.requirements = requirements
    proposal.user = user

    db.session.add(proposal)
    db.session.commit()

    proposal.set_state('accepted')
    with app.test_request_context('/'):
        send_email_for_proposal(proposal, reason='accepted')

    assert len(outbox) == 1
    del outbox[:]