Skip to content

Commit

Permalink
(PC-34407)[API] refactor: flag tests for later rework
Browse files Browse the repository at this point in the history
  • Loading branch information
cnormant-pass committed Feb 6, 2025
1 parent 07bcb0e commit 8b6a6d8
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 8 deletions.
6 changes: 5 additions & 1 deletion api/tests/core/external/external_users_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@

MAX_BATCH_PARAMETER_SIZE = 30

pytestmark = pytest.mark.usefixtures("db_session")
pytestmark = [
pytest.mark.usefixtures("db_session"),
pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime(2026, 1, 1)),
]


@pytest.mark.parametrize("marketing_subscription", [True, False])
Expand Down Expand Up @@ -406,6 +409,7 @@ def test_get_user_attributes_double_beneficiary():
assert attributes.deposits_count == 2


@pytest.mark.features(WIP_ENABLE_CREDIT_V3=0)
def test_get_user_attributes_not_beneficiary():
user = UserFactory(
dateOfBirth=datetime.utcnow() - relativedelta(years=18, months=3),
Expand Down
2 changes: 1 addition & 1 deletion api/tests/core/fraud/dms/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def test_get_fraud_check(self):
assert len(user_fraud_checks) == 1
assert user_fraud_checks[0] == fraud_check
assert user_fraud_checks[0].thirdPartyId == str(application_number)
assert user_fraud_checks[0].eligibilityType == users_models.EligibilityType.AGE18
assert user_fraud_checks[0].eligibilityType == users_models.EligibilityType.AGE17_18
4 changes: 4 additions & 0 deletions api/tests/core/fraud/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import pcapi.core.users.models as users_models


pytestmark = pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1))


@pytest.mark.usefixtures("db_session")
class CommonTest:
@pytest.mark.parametrize(
Expand Down Expand Up @@ -588,6 +591,7 @@ def test_has_user_performed_identity_check_without_identity_fraud_check(self):

assert not fraud_api.has_user_performed_identity_check(user)

@pytest.mark.features(WIP_ENABLE_CREDIT_V3=0)
def test_has_user_performed_identity_check_status_initiated(self):
user = user = build_user_at_id_check(18)
ubble_content = fraud_factories.UbbleContentFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def should_not_find_users_when_they_are_already_beneficiary(self):
# Then
assert not result

@pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1))
def should_not_find_users_when_they_have_another_id_check_ok(self):
# Given
user = build_user_with_ko_retryable_ubble_fraud_check(user_age=18)
Expand Down Expand Up @@ -147,6 +148,7 @@ def should_not_find_user_if_they_already_retried_thrice(self):
# Then
assert not result

@pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1))
def should_not_find_user_if_they_have_a_pending_id_check(self):
# Given
user = build_user_with_ko_retryable_ubble_fraud_check()
Expand Down
1 change: 1 addition & 0 deletions api/tests/core/subscription/dms/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def test_handle_dms_application_made_for_beneficiary_by_representative(self):
"user_id": applicant.id,
}

@pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1))
def test_handle_dms_application_updates_birth_date(self):
beneficiary = users_factories.ExUnderageBeneficiaryFactory()
seventeen_years_ago = datetime.datetime.utcnow() - relativedelta(years=17, months=1)
Expand Down
2 changes: 2 additions & 0 deletions api/tests/core/subscription/phone_validation/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from ssl import SSLError
from unittest.mock import patch

Expand Down Expand Up @@ -28,6 +29,7 @@ def test_send_phone_code_error_if_validated_by_beneficiary(self):

token_utils.Token.token_exists(token_utils.TokenType.PHONE_VALIDATION, in_validation_user.id)

@pytest.mark.features(WIP_ENABLE_CREDIT_V3=0)
@patch(
"pcapi.notifications.sms.backends.sendinblue.brevo_python.TransactionalSMSApi.send_transac_sms",
)
Expand Down
6 changes: 6 additions & 0 deletions api/tests/core/subscription/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
from pcapi.utils.string import u_nbsp


pytestmark = [
pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime(2026, 1, 1)),
pytest.mark.features(WIP_ENABLE_CREDIT_V3=0),
]


@pytest.mark.usefixtures("db_session")
class RequiresIdCheckTest:
def test_requires_identity_check_step_with_no_underage_beneficiary_role(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

IMAGES_DIR = pathlib.Path(tests.__path__[0]) / "files"

pytestmark = pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1))


@pytest.mark.usefixtures("db_session")
class UbbleV2EndToEndTest:
Expand Down Expand Up @@ -81,6 +83,7 @@ def test_beneficiary_activation_with_ubble_mocked_response(self, client, ubble_c

assert user.is_beneficiary

@pytest.mark.features(WIP_ENABLE_CREDIT_V3=0)
def _start_ubble_workflow(self, user, client, requests_mock) -> None:
requests_mock.post(f"{settings.UBBLE_API_URL}/v2/applicants", json=fixtures.APPLICANT_CREATION_RESPONSE)
requests_mock.post(
Expand Down
2 changes: 2 additions & 0 deletions api/tests/core/subscription/ubble/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

IMAGES_DIR = pathlib.Path(tests.__path__[0]) / "files"

pytestmark = pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1))


@pytest.mark.usefixtures("db_session")
class UbbleWorkflowV2Test:
Expand Down
5 changes: 4 additions & 1 deletion api/tests/core/users/young_status_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
from pcapi.core.users import young_status


pytestmark = pytest.mark.usefixtures("db_session")
pytestmark = [
pytest.mark.usefixtures("db_session"),
pytest.mark.features(WIP_ENABLE_CREDIT_V3=0),
]


def _with_age(age):
Expand Down
3 changes: 3 additions & 0 deletions api/tests/routes/backoffice/accounts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
pytestmark = [
pytest.mark.usefixtures("db_session"),
pytest.mark.backoffice,
pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1)),
]


Expand Down Expand Up @@ -949,6 +950,7 @@ def test_get_beneficiary_bookings_empty(self, authenticated_client):
assert not html_parser.extract_table_rows(response.data, parent_class="bookings-tab-pane")
assert "Aucune réservation à ce jour" in response.data.decode("utf-8")

@pytest.mark.features(WIP_ENABLE_CREDIT_V3=0)
def test_fraud_check_link(self, authenticated_client):
user = users_factories.BeneficiaryGrant18Factory()
# modifiy the date for clearer tests
Expand Down Expand Up @@ -2337,6 +2339,7 @@ def test_get_id_check_histories_desc(self):
assert before_ids != after_ids
assert sorted(before_ids, reverse=True) == after_ids

@pytest.mark.features(WIP_ENABLE_CREDIT_V3=0)
def test_get_steps_tunnel_age18(self):
dateOfBirth = datetime.date.today() - relativedelta(years=users_constants.ELIGIBILITY_AGE_18, days=1)
user = users_factories.UserFactory(dateOfBirth=dateOfBirth, validatedBirthDate=dateOfBirth)
Expand Down
3 changes: 3 additions & 0 deletions api/tests/routes/external/user_subscription_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
from tests.test_utils import json_default


pytestmark = pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1))


@pytest.mark.usefixtures("db_session")
class DmsWebhookApplicationTest:
def test_dms_request_no_token(self, client):
Expand Down
5 changes: 4 additions & 1 deletion api/tests/routes/native/v1/account_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
from pcapi.utils.postal_code import INELIGIBLE_POSTAL_CODES


pytestmark = pytest.mark.usefixtures("db_session")
pytestmark = [
pytest.mark.usefixtures("db_session"),
pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime(2026, 1, 1)),
]


class AccountTest:
Expand Down
1 change: 1 addition & 0 deletions api/tests/routes/native/v1/banner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pcapi.utils.string import u_nbsp


@pytest.mark.features(WIP_ENABLE_CREDIT_V3=0)
@pytest.mark.usefixtures("db_session")
class BannerTest:
# - authenticated user
Expand Down
5 changes: 4 additions & 1 deletion api/tests/routes/native/v1/subscription_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
from pcapi.utils.string import u_nbsp


pytestmark = pytest.mark.usefixtures("db_session")
pytestmark = [
pytest.mark.usefixtures("db_session"),
pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1)),
]


class NextStepTest:
Expand Down
7 changes: 5 additions & 2 deletions api/tests/routes/saml/educonnect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import pcapi.notifications.push.testing as push_testing


pytestmark = pytest.mark.usefixtures("db_session")
pytestmark = [
pytest.mark.usefixtures("db_session"),
pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1)),
]


def build_date_of_birth_from_age(age: int | None) -> datetime.datetime:
Expand Down Expand Up @@ -519,7 +522,7 @@ def test_educonnect_connection_updates_validated_birth_date(self, mock_get_educo


class PerformanceTest:
@pytest.mark.settings(IS_PERFORMANCE_TESTS=True)
@pytest.mark.settings(IS_PERFORMANCE_TESTS=True, CREDIT_V3_DECREE_DATETIME=datetime.datetime(2026, 1, 1))
def test_performance_tests(self, client):
user = users_factories.UserFactory(age=17)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
NOW = datetime.utcnow()

AGE18_ELIGIBLE_BIRTH_DATE = datetime.utcnow() - relativedelta(years=ELIGIBILITY_AGE_18)
pytestmark = [
pytest.mark.settings(CREDIT_V3_DECREE_DATETIME=datetime(2026, 1, 1)),
pytest.mark.features(WIP_ENABLE_CREDIT_V3=0),
]


@pytest.mark.usefixtures("db_session")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_format_batch_user():
"ut.booking_categories": ["FILM"],
"ut.booking_subcategories": ["SUPPORT_PHYSIQUE_FILM"],
"ut.roles": [UserRole.BENEFICIARY.value],
"u.eligibility": EligibilityType.AGE17_18.value,
"u.eligibility": user.eligibility.value,
"u.is_eligible": True,
}

Expand Down

0 comments on commit 8b6a6d8

Please sign in to comment.