Example #1
0
    def test_proposal_with_attachment(self, db_session):
        proposal = ProposalFactory()
        attachment = AttachmentFactory(proposal_id=proposal.id)
        db_session.flush()

        proposal.attachments.append(attachment)
        db_session.flush()

        proposal = Proposal.find_by_id(proposal.id)
        attachment = Attachment.find_by_id(attachment.id)
        assert proposal.attachments[0] == attachment
    def test_proposal_with_attachment(self, db_session):
        proposal = ProposalFactory()
        attachment = AttachmentFactory(proposal_id = proposal.id)
        db_session.flush()

        proposal.attachments.append(attachment)
        db_session.flush()

        proposal = Proposal.find_by_id(proposal.id)
        attachment = Attachment.find_by_id(attachment.id)
        assert proposal.attachments[0] == attachment
Example #3
0
    def test_create(self, db_session):
        person_id = 1
        proposal_type_id = 10
        proposal_id = 15

        proposal_type = ProposalTypeFactory(id=proposal_type_id)
        person = PersonFactory(id=person_id)
        proposal = ProposalFactory(id=proposal_id, type=proposal_type)
        db_session.flush()

        # give this sub to person
        person.proposals.append(proposal)
        db_session.flush()

        proposal_type = ProposalType.find_by_id(proposal_type_id)
        person = Person.find_by_id(person_id, abort_404=False)
        proposal = Proposal.find_by_id(proposal_id, abort_404=False)

        assert person is not None
        assert proposal_type is not None
        assert proposal is not None

        assert len(person.proposals) == 1
        assert proposal.title == person.proposals[0].title

        # check references
        assert person.proposals[0].people[0] == person
        assert person.proposals[0].type.name == proposal_type.name

        # check the proposal relations
        assert proposal.type.name == proposal_type.name
        assert proposal.people[0] == person

        # perform and check delete
        db_session.delete(proposal)
        db_session.delete(proposal_type)
        db_session.delete(person)

        assert ProposalType.find_by_id(proposal_type_id) is None
        assert Person.find_by_id(person_id, abort_404=False) is None
        assert Proposal.find_by_id(proposal_id, abort_404=False) is None
    def test_create(self, db_session):
        person_id = 1
        proposal_type_id = 10
        proposal_id = 15

        proposal_type = ProposalTypeFactory(id=proposal_type_id)
        person = PersonFactory(id=person_id)
        proposal = ProposalFactory(id=proposal_id, type=proposal_type)
        db_session.flush()
        
        # give this sub to person
        person.proposals.append(proposal)
        db_session.flush()

        proposal_type = ProposalType.find_by_id(proposal_type_id)
        person = Person.find_by_id(person_id, abort_404=False)
        proposal = Proposal.find_by_id(proposal_id, abort_404=False)
        
        assert person is not None
        assert proposal_type is not None
        assert proposal is not None

        assert len(person.proposals) == 1
        assert proposal.title == person.proposals[0].title

        # check references
        assert person.proposals[0].people[0] == person
        assert person.proposals[0].type.name == proposal_type.name

        # check the proposal relations
        assert proposal.type.name == proposal_type.name
        assert proposal.people[0] == person

        # perform and check delete
        db_session.delete(proposal)
        db_session.delete(proposal_type)
        db_session.delete(person)
        
        assert ProposalType.find_by_id(proposal_type_id)         is None
        assert Person.find_by_id(person_id, abort_404=False)     is None
        assert Proposal.find_by_id(proposal_id, abort_404=False) is None
Example #5
0
    def test_submit_another(self, app, db_session, smtplib):
        # created guy and proposal
        pers = CompletePersonFactory()
        prop = ProposalFactory(title='sub one', people=[pers])
        type = ProposalTypeFactory()
        stat = ProposalStatusFactory(name='Pending Review')  # Required by code
        trav = TravelAssistanceTypeFactory()
        accm = AccommodationAssistanceTypeFactory()
        audc = TargetAudienceFactory()
        db_session.commit()

        # now go to list, click on the submit another link, and do so
        do_login(app, pers)
        resp = app.get(url_for(controller='proposal', action='index'))
        assert prop.title in unicode(resp.body, 'utf-8')
        assert "You haven't submitted any proposals" not in unicode(
            resp.body, 'utf-8')

        resp = resp.click(description='New proposal')
        resp = resp.maybe_follow()
        f = resp.form
        f['proposal.title'] = 'sub two'
        f['proposal.type'] = str(type.id)
        f['proposal.abstract'] = "cubist"
        f['proposal.accommodation_assistance'] = str(accm.id)
        f['proposal.travel_assistance'] = str(trav.id)
        f['proposal.audience'] = str(audc.id)
        f['person.experience'] = "n"
        f['attachment'] = "foo"
        f['person.mobile'] = "NONE"
        f['person.bio'] = "Jim isn't real Dave, he never was"
        resp = f.submit()
        resp.status_code = 302  # Failure suggests form didn't submit cleanly

        pers_id = pers.id
        db_session.expunge_all()

        # does it exist?
        s2 = Proposal.find_by_title('sub two')
        assert len(s2) == 1
        s2 = s2[0]
        assert Person.find_by_id(
            pers_id) in s2.people  # Attached to correct person
        assert len(s2.attachments) == 1  # With attachment

        # Ensure that confirmation email was sent
        assert smtplib.existing is not None
        assert "Thank you for proposing" in smtplib.existing.message
Example #6
0
    def test_submit_another(self, app, db_session, smtplib):
        # created guy and proposal
        pers = CompletePersonFactory()
        prop = ProposalFactory(title='sub one', people=[pers])
        type = ProposalTypeFactory()
        stat = ProposalStatusFactory(name = 'Pending Review') # Required by code
        trav = TravelAssistanceTypeFactory()
        accm = AccommodationAssistanceTypeFactory()
        audc = TargetAudienceFactory()
        db_session.commit()

        # now go to list, click on the submit another link, and do so
        do_login(app, pers)
        resp = app.get(url_for(controller='proposal', action='index'))
        assert prop.title in unicode(resp.body, 'utf-8')
        assert "You haven't submitted any proposals" not in unicode(resp.body, 'utf-8')

        resp = resp.click(description='New proposal')
        resp = resp.maybe_follow()
        f = resp.form
        f['proposal.title']    = 'sub two'
        f['proposal.type']     = str(type.id)
        f['proposal.abstract'] = "cubist"
        f['proposal.accommodation_assistance'] = str(accm.id)
        f['proposal.travel_assistance'] = str(trav.id)
        f['proposal.audience'] = str(audc.id)
        f['person.experience'] = "n"
        f['attachment']        = "foo"
        f['person.mobile']     = "NONE"
        f['person.bio']        = "Jim isn't real Dave, he never was"
        resp = f.submit()
        resp.status_code = 302 # Failure suggests form didn't submit cleanly

        pers_id = pers.id
        db_session.expunge_all()

        # does it exist?
        s2 = Proposal.find_by_title('sub two')
        assert len(s2) == 1
        s2 = s2[0]
        assert Person.find_by_id(pers_id) in s2.people # Attached to correct person
        assert len(s2.attachments) == 1 # With attachment

        # Ensure that confirmation email was sent
        assert smtplib.existing is not None
        assert "Thank you for proposing" in smtplib.existing.message