def test_channels_listall_1channel(): #dictionary of token and uid when user logs in and the element removes when he logs out helper_functions.clear_data() user1_email = '*****@*****.**' user1_password = '******' user1_firstname = 'USER' user1_lastname = '1' diction = auth.auth_register(user1_email, user1_password, user1_firstname, user1_lastname) token = diction.get('token') ## uid = diction.get('u_id') id_dict = channels.channels_create(token, user1_firstname, True) channel_id = id_dict.get('channel_id') chan = channels.channels_listall(token) chan = chan.get('channels') assert chan == [{'channel_id': channel_id, 'name': user1_firstname}]
def test_user_name_valid1(): clear_data() user1_email = '*****@*****.**' user1_password = '******' user1_firstname = 'User' user1_lastname = 'One' user1 = auth.auth_register(user1_email, user1_password, user1_firstname, user1_lastname) user1_u_id = user1['u_id'] user1_token = user1['token'] user_first = 'Yuetong' user_last = 'chen' user_token = user1_token user_uid = user1_u_id user.user_profile_setname(user_token, user_first, user_last) user_data = user.user_profile(user_token, user_uid) user_info = user_data['user'] assert user_info['name_first'] == 'Yuetong' assert user_info['name_last'] == 'chen'
def test_user_profile_valid2(): clear_data() #setup one user user_c = auth.auth_register('*****@*****.**', 'password123', 'Firstname', 'Lastname') user.user_profile_sethandle(user_c['token'], 'handle123') #resetup details user.user_profile_setname(user_c['token'], 'Burt', 'Fan') user.user_profile_setemail(user_c['token'], '*****@*****.**') user.user_profile_sethandle(user_c['token'], 'handle456') assert user.user_profile(user_c['token'], user_c['u_id']) == { 'user': { 'u_id': user_c['u_id'], 'email': '*****@*****.**', 'name_first': 'Burt', 'name_last': 'Fan', 'handle_str': 'handle456' } }
def test_login_empty_password(): clear_data() user_email = '*****@*****.**' user_password = '' with pytest.raises(InputError): auth.auth_login(user_email, user_password)
def test_login_empty_email(): clear_data() user_email = '' user_password = '******' with pytest.raises(InputError): auth.auth_login(user_email, user_password)
def test_login_not_match_password(): clear_data() user_email = '*****@*****.**' user_password = '******' with pytest.raises(InputError): auth.auth_login(user_email, user_password)
def test_login_unregistered(): clear_data() user_email = '*****@*****.**' user_password = '******' with pytest.raises(InputError): auth.auth_login(user_email, user_password)
def test_login_invalid_email(): clear_data() user_email = 'cyttt.com' user_password = '******' with pytest.raises(InputError): auth.auth_login(user_email, user_password)
def test_logout_invalid_3(): clear_data() invalid_token = '0' user3_logout = auth.auth_logout(invalid_token) assert not user3_logout['is_success']