def test_image(client): user_id = helpers.get_user_id('csander') assert helpers.get_image(user_id) == ('png', b'NOT_A_REAL_IMAGE') core_helpers.set_image(user_id, 'jpg', 'FAKE_JPG') assert helpers.get_image(user_id) == ('jpg', b'FAKE_JPG') with pytest.raises(Exception): helpers.get_image(helpers.get_user_id('dqu'))
def test_hidden_fields(client): user_id = helpers.get_user_id('csander') assert not helpers.get_hidden_fields('csander', user_id) #dqu should see all fields via admin priviledges assert not helpers.get_hidden_fields('dqu', user_id) assert helpers.get_hidden_fields('dtardif', user_id) assert helpers.get_hidden_fields(None, user_id)
def test_gender(client): user_id = helpers.get_user_id('csander') assert core_helpers.get_gender(user_id) == 'Male' core_helpers.set_member_field(user_id, 'gender_custom', 'new_gender') assert core_helpers.get_gender(user_id) == 'new_gender' assert core_helpers.get_gender(helpers.get_user_id('dqu')) == ''
def test_preferred_name(client): user_id = helpers.get_user_id('csander') assert core_helpers.get_preferred_name(user_id) == 'Cleb' core_helpers.set_member_field(user_id, 'preferred_name', 'Belac') assert core_helpers.get_preferred_name(user_id) == 'Belac' assert core_helpers.get_preferred_name(helpers.get_user_id('reng')) == ''
def test_get_user(client): user_data = helpers.get_user(helpers.get_user_id('csander')) assert user_data == { 'address': None, 'birthday': date(1999, 5, 8), 'building_name': 'Ruddock House', 'city': 'Lincoln', 'country': None, 'email': '*****@*****.**', 'entry_year': 2017, 'first_name': 'Caleb', 'gender': 0, 'gender_custom': 'Male', 'gender_string': 'Male', 'graduation_year': 2021, 'hometown_string': 'Lincoln, MA', 'houses': [{ 'group_name': 'Ruddock House', 'pos_name': 'Full Member' }], 'image': 1, 'last_name': 'Sander', 'middle_name': 'Caldwell', 'msc': 707, 'options': [{ 'option_name': 'CS', 'option_type': 'Major' }, { 'option_name': 'MechE', 'option_type': 'Minor' }], 'phone': '6178003347', 'phone_string': '(617) 800-3347', 'positions': (), 'preferred_name': 'Cleb', 'room': '203', 'state': 'MA', 'uid': '2078141', 'username': '******', 'zip': None } user_data2 = helpers.get_user(helpers.get_user_id('dqu')) assert user_data2['image'] == 0 assert 'gender_string' not in user_data2 assert not user_data2['hometown_string'] assert 'phone_string' not in user_data2 user_data3 = helpers.get_user(helpers.get_user_id('reng')) assert user_data3['phone_string'] == '+11234567890' assert helpers.get_user(0) is None