def test_resubmit_approved_app(app): mimetype = 'application/x-www-form-urlencoded' headers = { 'Content-Type': mimetype, 'Accept': mimetype, } card_id = '5e4af2d6fc3c0954ff187ddc' board_id = TALENT_INTAKE_BOARDS['local'] board = Board(query_board_data(board_id)) card = board.cards.get(card_id) approved_list = board.lists['stage'][3] card.move_card(approved_list) board = Board(query_board_data(board_id)) card = board.cards.get(card_id) assert card.stage == 3 url = '/api/form-assembly/talent-app/' data = ( 'contact_id=123&program_id=1&first_name=Billy&last_name=Daly&email=billy%40example.com&phone=9085784622&street1=2401+Liberty+Heights+Ave&street2=Suite+2730&city=Baltimore&state=MD&postal_code=21215&equity=Race&effectiveness=Effectiveness&programs%5B0%5D=Fellowship&programs%5B1%5D=JHU+-+Carey&programs%5B2%5D=Mayoral+Fellowship&programs%5B3%5D=PFP&programs%5B4%5D=PA&programs%5B5%5D=I%27d+like+some+help+figuring+this+out&mayoral_eligible=Yes&experience=0-2+years&capabilities%5B0%5D=Advocacy+and+Public+Policy&capabilities%5B1%5D=Community+Engagement+and+Outreach&capabilities%5B2%5D=Data+Analysis&capabilities%5B3%5D=Fundraising+and+Development&capabilities%5B4%5D=Marketing+and+Public+Relations&alum_radio=No&race_all=American+Indian+or+Alaskan+Native&gender=Male&pronouns=He%2FHim&response_id=160140910' ) with app.test_client() as client: response = client.post(url, data=data, headers=headers) pprint(response.json) assert response.status_code == 400 message = json.loads(response.data)['message'] assert message == 'Application has already been submitted'
def test_talent_intake(app): mimetype = 'application/x-www-form-urlencoded' headers = { 'Content-Type': mimetype, 'Accept': mimetype, } card_id = '5e4af2d6fc3c0954ff187ddc' contact = Contact.query.get(123) board_id = TALENT_INTAKE_BOARDS['local'] board = Board(query_board_data(board_id)) card = board.cards.get(card_id) started_list = board.lists['stage'][1] for attachment in TALENT_INTAKE_ATTACHMENTS: response = card.remove_attachment(attachment) card.set_labels(label_names=['New', 'Fellowship']) card.move_card(started_list) board = Board(query_board_data(board_id)) card = board.cards.get(card_id) assert card.attachments == {} assert card.label_names == ['New', 'Fellowship'] assert card.stage == 1 assert contact.stage == 1 url = '/api/form-assembly/talent-app/' data = ( 'contact_id=123&program_id=1&first_name=Billy&last_name=Daly&email=billy%40example.com&phone=9085784622&street1=2401+Liberty+Heights+Ave&street2=Suite+2730&city=Baltimore&state=MD&postal_code=21215&equity=Race&effectiveness=Effectiveness&programs%5B0%5D=Fellowship&programs%5B1%5D=JHU+-+Carey&programs%5B2%5D=Mayoral+Fellowship&programs%5B3%5D=PFP&programs%5B4%5D=PA&programs%5B5%5D=I%27d+like+some+help+figuring+this+out&mayoral_eligible=Yes&experience=0-2+years&capabilities%5B0%5D=Advocacy+and+Public+Policy&capabilities%5B1%5D=Community+Engagement+and+Outreach&capabilities%5B2%5D=Data+Analysis&capabilities%5B3%5D=Fundraising+and+Development&capabilities%5B4%5D=Marketing+and+Public+Relations&alum_radio=No&race_all=American+Indian+or+Alaskan+Native&gender=Male&pronouns=He%2FHim&response_id=160140910' ) with app.test_client() as client: response = client.post(url, data=data, headers=headers) pprint(response.json) assert response.status_code == 201 board = Board(query_board_data(board_id)) card = board.cards.get(card_id) contact = Contact.query.get(123) assert card.stage == 2 assert contact.stage == 2 assert 'New' in card.label_names for label in TALENT_INTAKE_LABELS[1:]: assert label in card.label_names assert 'Race' in card.desc assert '- Data Analysis\n' in card.desc assert '0-2 years' in card.desc assert '**Mayoral Fellowship:** Yes' in card.desc assert '**JHU - Carey:** N/A' in card.desc pprint(card.attachments) assert card.attachments['Profile']['url'] == ( 'https://app.baltimorecorps.org/profile/123') assert card.attachments['Full Response']['url'] == ( 'https://app.formassembly.com/responses/view/160140910') data = json.loads(response.data)['data']
def check_opportunity_board_custom_fields(env): board_id = OPP_BOARDS[env] board = Board(query_board_data(board_id)) gdoc_id = board.custom_fields['name'].get('Google Doc ID') assert gdoc_id is not None assert gdoc_id.type == 'text' opp_id = board.custom_fields['name'].get('Opp ID') assert opp_id is not None assert opp_id.type == 'text'
def check_opportunity_board_lists(env): board_id = OPP_BOARDS[env] board = Board(query_board_data(board_id)) BOARD_NAMES = [ 'Started', 'Submitted', 'Approved', 'Posted', 'Interviewing', 'Filled', ] for stage, name in enumerate(BOARD_NAMES): list_ = board.lists['stage'][stage] assert list_.name == name, f'At stage {stage}, {list_.name} != {name}'
def check_labels(board_id, expected_labels): board = Board(query_board_data(board_id)) labels = board.labels['name'].keys() print(labels) for label in expected_labels: assert label in labels
def post(self, contact_id): if not is_authorized_view(contact_id): return unauthorized() # query contact and check that all submission criteria is met contact = Contact.query.get(contact_id) email = contact.email_main if not contact: return {'message': 'Contact does not exist'}, 404 if not (contact.about_me_complete['is_complete'] and contact.profile_complete['is_complete']): return {'message': 'Not all profile sections are complete'}, 400 if contact.stage >= 2: return {'message': 'Profile already submitted'}, 400 # Start of Trello specific code PROGRAMS_DICT = { 'Fellowship': 'Fellowship', 'Mayoral Fellowship': 'Mayoral Fellowship', 'Place for Purpose': 'PFP', 'Public Allies': 'PA', 'JHU Carey Humanities Fellowship': 'JHU - Carey' } #query board and check that a card doesn't already exist board_id = get_intake_talent_board_id(program_id=1) board = Board(query_board_data(board_id)) existing_card = board.find_card_by_custom_field('Email', email) if existing_card: return {'message': 'Application has already been submitted'}, 400 # parses form data to fill the card description profile = contact.profile roles = ['- '+role for role in profile.roles_list] roles_str = '\n'.join(roles) programs = [PROGRAMS_DICT[app.program.name] for app in contact.program_apps if app.is_interested] programs_str = '\n'.join(['- ' + p for p in programs]) #formats the string for the description card_data = { 'name': ( f"{contact.first_name} {contact.last_name}" ), 'desc': ( "**Racial Equity & Baltimore: " "Why is racial equity work in Baltimore " "important to you?**\n\n" f"{profile.value_question1}\n\n---\n\n" "**Sector Effectiveness: How has your background" " and experiences prepared you for today’s work" " in Baltimore’s social impact sector?**\n\n" f"{profile.value_question2}\n\n---\n\n" f"**Level of Experience:** {profile.years_exp}\n\n" f"**Types of roles they're interested in:**\n\n" f"{roles_str}\n\n---\n\n" f"**Programs/Services they are interested in:**\n\n" f"{programs_str}\n\n---\n\n" f"**Currently a student:**\n\n" f"{profile.current_edu_status}\n\n---\n\n" ) } fields_data = { 'Phone': contact.phone_primary, 'Email': email, 'External ID': str(contact.id) } #creates the card with the information parsed from the form submitted_list = board.lists['stage'][2] card = submitted_list.add_card_from_template(**card_data) card.add_attachment( url=f'https://app.baltimorecorps.org/profile/{contact_id}', name='Profile' ) labels = set(card.label_names + programs) card.set_labels(labels) card.set_custom_field_values(**fields_data) # updates the contact to stage 2 contact.stage = 2 contact.card_id = card.id db.session.commit() result = instructions_schema.dump(contact) return {'status': 'success', 'data': result}, 201
def test_submit_profile(app): mimetype = 'application/json' headers = { 'Content-Type': mimetype, 'Accept': mimetype, } card_id = '5e4af2d6fc3c0954ff187ddc' contact = Contact.query.get(123) email = contact.email_main contact.stage = 1 db.session.commit() board_id = TALENT_INTAKE_BOARDS['local'] board = Board(query_board_data(board_id)) card = board.find_card_by_custom_field('Email', email) if card: response = card.delete() assert response.status_code == 200 contact = Contact.query.get(123) assert contact.stage == 1 with app.test_client() as client: response = client.post('/api/contacts/123/profile/submit', data={}, headers=headers) pprint(response.json) assert response.status_code == 201 board = Board(query_board_data(board_id)) card = board.find_card_by_custom_field('Email', email) contact = Contact.query.get(123) assert contact.stage == 2 assert 'New' in card.label_names for label in LABELS: assert label in card.label_names assert 'Test response' in card.desc assert '- Data Analysis\n' in card.desc assert '3-5' in card.desc assert card.attachments['Profile']['url'] == ( 'https://app.baltimorecorps.org/profile/123' ) assert card.custom_fields['Email']['value'] == email data = response.json['data'] assert data['instructions']['submit'] #check that the card id was set contact = Contact.query.get(123) card_id = contact.card_id assert card_id is not None # Check that the card is deleted card.delete() board = Board(query_board_data(board_id)) card = board.cards.get(card_id) assert card is None