def test_minespace_user_model_find_all(db_session): user1 = MinespaceUserFactory() user2 = MinespaceUserFactory() all_mu = MinespaceUser.get_all() assert len(all_mu) == 2 assert any(mu.email == user1.email for mu in all_mu)
def setup_info(db_session): User._test_mode = False auth.clear_cache() MinespaceUserFactory(email_or_username='******') yield User._test_mode = True
def test_get_minespace_user_by_id(test_client, db_session, auth_headers): user = MinespaceUserFactory() get_resp = test_client.get(f'/users/minespace/{user.user_id}', headers=auth_headers['full_auth_header']) get_data = json.loads(get_resp.data.decode()) assert get_resp.status_code == 200, get_resp.response assert get_data['email_or_username'] == user.email_or_username
def test_get_minespace_user_by_email(test_client, db_session, auth_headers): user = MinespaceUserFactory() get_resp = test_client.get(f'/users/minespace?email={user.email}', headers=auth_headers['full_auth_header']) get_data = json.loads(get_resp.data.decode()) assert get_resp.status_code == 200, get_resp.response assert get_data['records'][0]["email"] == user.email
def test_get_minespace_users_all(test_client, db_session, auth_headers): user_email = MinespaceUserFactory().email_or_username get_resp = test_client.get('/users/minespace', headers=auth_headers['full_auth_header']) get_data = json.loads(get_resp.data.decode()) assert get_resp.status_code == 200, get_resp.response assert len(get_data['records']) == 1 assert get_data['records'][0]['email_or_username'] == user_email
def test_post_minespace_user_duplicate_email(test_client, db_session, auth_headers): user = MinespaceUserFactory() data = {"email": user.email, "mine_guids": [str(uuid.uuid4())]} post_resp = test_client.post('/users/minespace', json=data, headers=auth_headers['full_auth_header']) assert post_resp.status_code == 400, post_resp.response assert json.loads(post_resp.data.decode())["message"], post_resp.response
def test_minespace_user_model_find_by_id(db_session): user = MinespaceUserFactory() mu = MinespaceUser.find_by_id(user.user_id) assert mu.email == user.email
def test_minespace_user_model_find_by_email(db_session): email = MinespaceUserFactory().email mu = MinespaceUser.find_by_email(email) assert mu.email == email
def test_delete_minespace_success(test_client, db_session, auth_headers): user = MinespaceUserFactory() del_resp = test_client.delete(f'/users/minespace/{user.user_id}', headers=auth_headers['full_auth_header']) assert del_resp.status_code == 204, del_resp.response
def test_minespace_user_model_find_by_email(db_session): email_or_username = MinespaceUserFactory().email_or_username mu = MinespaceUser.find_by_email(email_or_username) assert mu.email_or_username == email_or_username