def test_add_new_user(): """Test adding new user.""" with mocked_transaction() as session: user = add_user(session, fake.name(), fake.email(), fake.password(), fake.address(), fake.latitude(), fake.longitude()) assert user is not None assert get_user_by_id(session, user.id) is not None
def test_get_exist_user_by_id(): """Test search exists user by email.""" with mocked_transaction() as session: user = add_user(session, fake.name(), fake.email(), fake.password(), fake.address(), fake.latitude(), fake.longitude()) assert user is not None assert get_user_by_id(session, user.id) is not None
def test_delete_exists_user(): """Test deleting user.""" with mocked_transaction() as session: not_hashed_password = fake.password() user = add_user(session, fake.name(), fake.email(), not_hashed_password, fake.address(), fake.latitude(), fake.longitude()) assert user is not None assert delete_user(session, user.email, not_hashed_password) assert get_user_by_id(session, user.id) is None
def test_update_user_categories(): """Test update user categories.""" categories_ids = [1, 2, 3, 4, 5, 48, 201] with mocked_transaction() as session: user = add_user(session, fake.name(), fake.email(), fake.password(), fake.address(), fake.latitude(), fake.longitude()) assert user is not None update_categories_to_user(session, user.id, categories_ids) user = get_user_by_id(session, user.id) assert user.categories_ids == categories_ids
def test_get_not_exist_user_by_id(): """Test search not exists user by email.""" id = -1 # not_existing_id with mocked_transaction() as session: assert get_user_by_id(session, id) is None