From 78ef72ae6becefab16bcb8816687fd21c67f874c Mon Sep 17 00:00:00 2001 From: Jan Romaniak Date: Thu, 3 Oct 2024 16:45:08 +0200 Subject: [PATCH] Project structure 3 (#4287) * chenged tests dir * fixed all linter problems * fix precomit * fix compose * fixed tests root dir --- .flake8 | 1 + .github/helpers/dev.sh | 2 +- .github/helpers/docker-compose.selenium.yml | 2 +- .github/workflows/ci.yml | 2 +- .pre-commit-config.yaml | 49 +----- development_tools/compose.yml | 6 +- docker/Dockerfile | 6 +- pyproject.toml | 31 ++-- .../accountability/test_communication.py | 12 +- tests/selenium/accountability/test_surveys.py | 8 +- tests/selenium/conftest.py | 92 ++++++---- .../test_country_dashboard.py | 5 +- tests/selenium/drawer/test_drawer.py | 8 +- tests/selenium/filters/test_filters.py | 2 +- .../grievance/feedback/test_feedback.py | 12 +- .../test_grievance_dashboard.py | 8 +- .../test_grievance_tickets.py | 8 +- .../login_via_admin_panel/test_login.py | 2 +- .../test_managerial_console.py | 4 +- tests/selenium/page_object/404.py | 3 +- .../accountability/communication.py | 3 +- .../accountability/comunication_details.py | 3 +- .../page_object/accountability/surveys.py | 3 +- .../accountability/surveys_details.py | 3 +- .../page_object/admin_panel/admin_panel.py | 3 +- tests/selenium/page_object/base_components.py | 3 +- .../country_dashboard/country_dashboard.py | 3 +- tests/selenium/page_object/filters.py | 3 +- .../grievance/details_feedback_page.py | 3 +- .../grievance/details_grievance_page.py | 3 +- .../page_object/grievance/feedback.py | 3 +- .../grievance/grievance_dashboard.py | 3 +- .../grievance/grievance_tickets.py | 3 +- .../page_object/grievance/new_feedback.py | 3 +- .../page_object/grievance/new_ticket.py | 3 +- .../managerial_console/managerial_console.py | 3 +- .../payment_module/new_payment_plan.py | 3 +- .../payment_module/payment_module.py | 3 +- .../payment_module/payment_module_details.py | 3 +- .../payment_module/program_cycle.py | 3 +- .../payment_verification/payment_record.py | 3 +- .../payment_verification.py | 3 +- .../payment_verification_details.py | 3 +- tests/selenium/page_object/people/people.py | 3 +- .../page_object/program_log/payment_log.py | 3 +- .../programme_details/programme_details.py | 3 +- .../programme_management.py | 3 +- .../programme_population/households.py | 3 +- .../households_details.py | 3 +- .../programme_population/individuals.py | 3 +- .../individuals_details.py | 3 +- .../periodic_data_update_templates.py | 3 +- .../periodic_data_update_uploads.py | 3 +- .../programme_users/programme_users.py | 3 +- .../rdi_details_page.py | 3 +- .../registration_data_import.py | 3 +- .../page_object/targeting/targeting.py | 2 +- .../page_object/targeting/targeting_create.py | 3 +- .../targeting/targeting_details.py | 3 +- .../payment_module/test_payment_plans.py | 19 +- .../payment_module/test_program_cycles.py | 2 +- .../test_payment_verification.py | 12 +- tests/selenium/people/test_people.py | 2 +- .../test_people_periodic_data_update.py | 3 +- .../program_details/test_program_details.py | 10 +- .../selenium/program_log/test_program_log.py | 8 +- .../test_programme_management.py | 11 +- .../programme_population/test_households.py | 5 +- .../programme_population/test_individuals.py | 5 +- .../test_periodic_data_templates.py | 10 +- .../test_periodic_data_update_upload.py | 16 +- .../programme_user/test_programme_user.py | 4 +- .../test_registration_data_import.py | 14 +- tests/selenium/targeting/test_targeting.py | 6 +- tests/unit/api/base.py | 2 +- tests/unit/api/test_auth.py | 4 +- tests/unit/api/test_business_area.py | 2 +- tests/unit/api/test_delegate_people.py | 2 +- tests/unit/api/test_program.py | 2 +- tests/unit/api/test_push_people.py | 2 +- tests/unit/api/test_rdi.py | 2 +- tests/unit/api/test_soft.py | 2 +- tests/unit/api/test_upload.py | 2 +- .../test_pull_from_datahub.py | 4 +- tests/unit/apps/core/test_exchange_rates.py | 6 +- .../test_approve_automatic_tickets.py | 1 - .../test_create_needs_adjudication_tickets.py | 48 ++---- .../apps/grievance/test_services_utils.py | 10 +- .../test_individual_iban_xlsx_update.py | 12 +- .../apps/household/test_individual_query.py | 162 +++++------------- .../household/test_individual_xlsx_update.py | 8 +- tests/unit/apps/payment/test_models1.py | 128 ++++---------- .../test_update_reconciliation_data.py | 4 +- .../test_periodic_data_update_upload_views.py | 4 +- .../program/test_program_cycle_rest_api.py | 2 +- .../services/test_mark_submissions.py | 4 +- .../apps/registration_data/test_models.py | 6 +- .../apps/registration_data/test_rest_api.py | 2 +- .../test_biometric_deduplication_service.py | 4 +- .../test_deduplication_engine_api.py | 48 ++---- .../test_kobo_validators_methods.py | 2 +- .../test_rdi_kobo_create.py | 8 +- .../test_rdi_people_create.py | 4 +- ...istration_data_import_datahub_mutations.py | 4 +- .../test_validate_xlsx_import_task.py | 4 +- tests/unit/apps/targeting/test_admin.py | 2 +- tests/unit/conftest.py | 5 +- 107 files changed, 437 insertions(+), 571 deletions(-) diff --git a/.flake8 b/.flake8 index 5734c6b738..2de1c3d64e 100644 --- a/.flake8 +++ b/.flake8 @@ -21,6 +21,7 @@ exclude = migrations, snapshots, __pypackages__, + frontend, ignore = # black formatting related diff --git a/.github/helpers/dev.sh b/.github/helpers/dev.sh index ac94420868..9a0c457330 100755 --- a/.github/helpers/dev.sh +++ b/.github/helpers/dev.sh @@ -20,7 +20,7 @@ else --cov-report xml:test-coverage/coverage.xml \ --randomly-seed=42 \ --create-db \ - /tests/unit/ + ./tests/unit/ ;; "lint") mkdir -p ./lint-results diff --git a/.github/helpers/docker-compose.selenium.yml b/.github/helpers/docker-compose.selenium.yml index 2fcbe8577e..7ac51dba81 100644 --- a/.github/helpers/docker-compose.selenium.yml +++ b/.github/helpers/docker-compose.selenium.yml @@ -5,7 +5,7 @@ services: backend: volumes: - ../../tests/test-coverage:/code/test-coverage - - ../../tests/report/:/tests/selenium/output_data/report/ + - ../../tests/report/:/code/tests/selenium/output_data/report/ - type: volume source: backend-web-app target: /code/src/hct_mis_api/apps/web diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61c6d1cc46..1f1c2c97f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -264,7 +264,7 @@ jobs: -f ./.github/helpers/docker-compose.selenium.yml \ run backend bash -c " waitforit -host=db -port=5432 -timeout=30 - pytest -svvv $extra_options /tests/selenium --cov-report xml:test-coverage/coverage.xml --html-report=/tests/selenium/output_data/report/report.html --randomly-seed=42 + pytest -svvv $extra_options ./tests/selenium --cov-report xml:test-coverage/coverage.xml --html-report=./tests/selenium/output_data/report/report.html --randomly-seed=42 " - name: Upload Artifact uses: actions/upload-artifact@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2efe9bbcc8..73c64dd787 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,42 +1,9 @@ repos: - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - stages: [commit] - - repo: https://github.com/ambv/black - rev: 23.12.1 - hooks: - - id: black - args: [--config=backend/pyproject.toml] - exclude: "migrations|snapshots" - stages: [commit] - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - args: [--config=backend/.flake8] - additional_dependencies: [flake8-bugbear==22.12.6] - stages: [ commit ] - exclude: /deployment/|/migrations/ - # mypy precommit hook - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 - hooks: - - id: mypy - verbose: true - args: [--config-file=backend/pyproject.toml, --follow-imports=skip] - pass_filenames: true - stages: [commit] - additional_dependencies: [ - types-requests==2.28.11.15, - types-redis==4.5.1.4, - types-python-dateutil==2.8.19.10, - types-pytz==2022.7.1.2, - djangorestframework-stubs==1.9.1, - graphene-stubs==0.15, - django-stubs==1.15.0, - django-stubs-ext==0.7.0, - openpyxl-stubs==0.1.25 - ] - exclude: /deployment/|/migrations/ + - repo: local + hooks: + - id: Linters checks + name: Linters checks + entry: docker compose -f development_tools/compose.yml run --no-TTY -i --rm backend sh -c 'black . --check && isort . --check-only && flake8 . && mypy .' + language: system + pass_filenames: false + verbose: true \ No newline at end of file diff --git a/development_tools/compose.yml b/development_tools/compose.yml index 1e9c897272..20899f6bda 100644 --- a/development_tools/compose.yml +++ b/development_tools/compose.yml @@ -25,11 +25,7 @@ services: ports: - "8080:8000" volumes: - - ../src:/code/src/ - - ../manage.py:/code/manage.py - - ../pyproject.toml:/code/pyproject.toml - - ../pdm.lock:/code/pdm.lock - - ../tests:/tests/ +# - ../.:/code/ - backend-data:/data - ../pyproject.toml:/packages/pyproject.toml - ../pdm.lock:/packages/pdm.lock diff --git a/docker/Dockerfile b/docker/Dockerfile index 727d72f63d..e546489360 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -47,7 +47,7 @@ ENV PYTHONPYCACHEPREFIX=/tmp/pycache \ PYTHONPATH=$PYPACKAGES/lib:$PYTHONPATH \ PATH=$PYPACKAGES/bin:$PATH \ XDG_RUNTIME_DIR=/run/user/"${UID}" - +ENV DJANGO_SETTINGS_MODULE=hct_mis_api.config.settings WORKDIR $CODE COPY --from=waitforit /data/waitforit /usr/local/bin/waitforit @@ -82,12 +82,12 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -ENV PYTHONPATH=$CODE/src:/test/:$PYTHONPATH +ENV PYTHONPATH=$CODE/src:$CODE/test/:$PYTHONPATH RUN pdm sync --no-editable --no-self --no-isolation WORKDIR $CODE COPY ./src/ ./src/ -COPY ./tests /tests +COPY ./tests ./tests COPY ./manage.py ./manage.py COPY .flake8 pyproject.toml pdm.lock ./ COPY ./docker/entrypoint.sh /bin/ diff --git a/pyproject.toml b/pyproject.toml index b6ef3ae60f..7d5ef6e541 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ exclude = ''' | migrations | snapshots | __pypackages__ + | frontend )/ ''' # TODO: remove migrations exclude rule once it won't create much conflicts between feature branches and develop @@ -45,18 +46,18 @@ known_first_party = [ "accountability", ] known_django = "django" -sections = ["FUTURE","STDLIB","DJANGO","THIRDPARTY","FIRSTPARTY","LOCALFOLDER"] +sections = ["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] include_trailing_comma = true -skip = ["migrations", "snapshots", "venv", "__pypackages__"] +skip = ["migrations", "snapshots", "venv", ".venv", "__pypackages__", "frontend"] [tool.mypy] python_version = 3.11 show_error_codes = true exclude = [ - "migrations", - "venv", - "snapshots", - "__pypackages__", + "migrations", + "venv", + "snapshots", + "__pypackages__", ] strict = true @@ -66,12 +67,12 @@ follow_imports = "skip" # TODO: remove one, fix errors, repeat disable_error_code = [ - "var-annotated", # this enforces Django Model fields to have type annotations - "attr-defined", - "misc", # cannot subclass DjangoObjectType - "union-attr", - "type-arg", # this misses type parameters for graphene.ObjectType - "no-any-return", # this enforces adding return None for function that returns None + "var-annotated", # this enforces Django Model fields to have type annotations + "attr-defined", + "misc", # cannot subclass DjangoObjectType + "union-attr", + "type-arg", # this misses type parameters for graphene.ObjectType + "no-any-return", # this enforces adding return None for function that returns None ] [tool.django-stubs] @@ -133,7 +134,7 @@ requires = ["pdm-backend"] build-backend = "pdm.backend" [tool.pdm.build] -includes = ['src/hct_mis_api','src/data'] +includes = ['src/hct_mis_api', 'src/data'] [tool.pdm] distribution = true @@ -143,7 +144,7 @@ name = "hope" version = "3.0.0" description = "HCT MIS is UNICEF's humanitarian cash transfer platform." authors = [ - {name = "Tivix"}, + { name = "Tivix" }, ] dependencies = [ "setuptools==71.1.0", @@ -242,7 +243,7 @@ dependencies = [ ] requires-python = "==3.11.*" readme = "README.md" -license = {text = "None"} +license = { text = "None" } [tool.setuptools] py-modules = ["hct_mis_api"] diff --git a/tests/selenium/accountability/test_communication.py b/tests/selenium/accountability/test_communication.py index 622ecf9458..adda23c38a 100644 --- a/tests/selenium/accountability/test_communication.py +++ b/tests/selenium/accountability/test_communication.py @@ -1,9 +1,4 @@ import pytest -from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name -from tests.selenium.page_object.accountability.communication import AccountabilityCommunication -from tests.selenium.page_object.accountability.comunication_details import ( - AccountabilityCommunicationDetails, -) from hct_mis_api.apps.account.models import User from hct_mis_api.apps.accountability.fixtures import CommunicationMessageFactory @@ -15,6 +10,13 @@ TargetPopulationFactory, ) from hct_mis_api.apps.targeting.models import TargetPopulation +from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name +from tests.selenium.page_object.accountability.communication import ( + AccountabilityCommunication, +) +from tests.selenium.page_object.accountability.comunication_details import ( + AccountabilityCommunicationDetails, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/accountability/test_surveys.py b/tests/selenium/accountability/test_surveys.py index 64f062cb28..b5935f3e21 100644 --- a/tests/selenium/accountability/test_surveys.py +++ b/tests/selenium/accountability/test_surveys.py @@ -1,9 +1,6 @@ from django.db import transaction import pytest -from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name -from tests.selenium.page_object.accountability.surveys import AccountabilitySurveys -from tests.selenium.page_object.accountability.surveys_details import AccountabilitySurveysDetails from hct_mis_api.apps.account.models import User from hct_mis_api.apps.accountability.fixtures import SurveyFactory @@ -16,6 +13,11 @@ TargetingCriteriaFactory, TargetPopulationFactory, ) +from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name +from tests.selenium.page_object.accountability.surveys import AccountabilitySurveys +from tests.selenium.page_object.accountability.surveys_details import ( + AccountabilitySurveysDetails, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/conftest.py b/tests/selenium/conftest.py index ea799d20c8..ab6945a2d4 100644 --- a/tests/selenium/conftest.py +++ b/tests/selenium/conftest.py @@ -6,49 +6,90 @@ from django.core.management import call_command import pytest -from environ import Env from _pytest.fixtures import FixtureRequest from _pytest.nodes import Item from _pytest.runner import CallInfo +from environ import Env from flags.models import FlagState -from tests.selenium.page_object.accountability.communication import AccountabilityCommunication +from pytest_django.live_server_helper import LiveServer +from pytest_html_reporter import attach +from selenium import webdriver +from selenium.webdriver import Chrome +from selenium.webdriver.chrome.options import Options + +from hct_mis_api.apps.account.fixtures import RoleFactory, UserFactory +from hct_mis_api.apps.account.models import Partner, Role, User, UserRole +from hct_mis_api.apps.account.permissions import Permissions +from hct_mis_api.apps.core.models import ( + BusinessArea, + BusinessAreaPartnerThrough, + DataCollectingType, +) +from hct_mis_api.apps.geo.models import Country +from hct_mis_api.apps.household.fixtures import DocumentTypeFactory +from hct_mis_api.apps.household.models import DocumentType +from tests.selenium.page_object.accountability.communication import ( + AccountabilityCommunication, +) from tests.selenium.page_object.accountability.comunication_details import ( AccountabilityCommunicationDetails, ) from tests.selenium.page_object.accountability.surveys import AccountabilitySurveys -from tests.selenium.page_object.accountability.surveys_details import AccountabilitySurveysDetails +from tests.selenium.page_object.accountability.surveys_details import ( + AccountabilitySurveysDetails, +) from tests.selenium.page_object.admin_panel.admin_panel import AdminPanel -from tests.selenium.page_object.country_dashboard.country_dashboard import CountryDashboard +from tests.selenium.page_object.country_dashboard.country_dashboard import ( + CountryDashboard, +) from tests.selenium.page_object.filters import Filters -from tests.selenium.page_object.grievance.details_feedback_page import FeedbackDetailsPage -from tests.selenium.page_object.grievance.details_grievance_page import GrievanceDetailsPage +from tests.selenium.page_object.grievance.details_feedback_page import ( + FeedbackDetailsPage, +) +from tests.selenium.page_object.grievance.details_grievance_page import ( + GrievanceDetailsPage, +) from tests.selenium.page_object.grievance.feedback import Feedback from tests.selenium.page_object.grievance.grievance_dashboard import GrievanceDashboard from tests.selenium.page_object.grievance.grievance_tickets import GrievanceTickets from tests.selenium.page_object.grievance.new_feedback import NewFeedback from tests.selenium.page_object.grievance.new_ticket import NewTicket -from tests.selenium.page_object.managerial_console.managerial_console import ManagerialConsole +from tests.selenium.page_object.managerial_console.managerial_console import ( + ManagerialConsole, +) from tests.selenium.page_object.payment_module.new_payment_plan import NewPaymentPlan from tests.selenium.page_object.payment_module.payment_module import PaymentModule -from tests.selenium.page_object.payment_module.payment_module_details import PaymentModuleDetails +from tests.selenium.page_object.payment_module.payment_module_details import ( + PaymentModuleDetails, +) from tests.selenium.page_object.payment_module.program_cycle import ( ProgramCycleDetailsPage, ProgramCyclePage, ) from tests.selenium.page_object.payment_verification.payment_record import PaymentRecord -from tests.selenium.page_object.payment_verification.payment_verification import PaymentVerification +from tests.selenium.page_object.payment_verification.payment_verification import ( + PaymentVerification, +) from tests.selenium.page_object.payment_verification.payment_verification_details import ( PaymentVerificationDetails, ) from tests.selenium.page_object.people.people import People from tests.selenium.page_object.people.people_details import PeopleDetails from tests.selenium.page_object.program_log.payment_log import ProgramLog -from tests.selenium.page_object.programme_details.programme_details import ProgrammeDetails -from tests.selenium.page_object.programme_management.programme_management import ProgrammeManagement +from tests.selenium.page_object.programme_details.programme_details import ( + ProgrammeDetails, +) +from tests.selenium.page_object.programme_management.programme_management import ( + ProgrammeManagement, +) from tests.selenium.page_object.programme_population.households import Households -from tests.selenium.page_object.programme_population.households_details import HouseholdsDetails +from tests.selenium.page_object.programme_population.households_details import ( + HouseholdsDetails, +) from tests.selenium.page_object.programme_population.individuals import Individuals -from tests.selenium.page_object.programme_population.individuals_details import IndividualsDetails +from tests.selenium.page_object.programme_population.individuals_details import ( + IndividualsDetails, +) from tests.selenium.page_object.programme_population.periodic_data_update_templates import ( PeriodicDatUpdateTemplates, PeriodicDatUpdateTemplatesDetails, @@ -57,30 +98,15 @@ PeriodicDataUpdateUploads, ) from tests.selenium.page_object.programme_users.programme_users import ProgrammeUsers -from tests.selenium.page_object.registration_data_import.rdi_details_page import RDIDetailsPage +from tests.selenium.page_object.registration_data_import.rdi_details_page import ( + RDIDetailsPage, +) from tests.selenium.page_object.registration_data_import.registration_data_import import ( RegistrationDataImport, ) from tests.selenium.page_object.targeting.targeting import Targeting from tests.selenium.page_object.targeting.targeting_create import TargetingCreate from tests.selenium.page_object.targeting.targeting_details import TargetingDetails -from pytest_django.live_server_helper import LiveServer -from pytest_html_reporter import attach -from selenium import webdriver -from selenium.webdriver import Chrome -from selenium.webdriver.chrome.options import Options - -from hct_mis_api.apps.account.fixtures import RoleFactory, UserFactory -from hct_mis_api.apps.account.models import Partner, Role, User, UserRole -from hct_mis_api.apps.account.permissions import Permissions -from hct_mis_api.apps.core.models import ( - BusinessArea, - BusinessAreaPartnerThrough, - DataCollectingType, -) -from hct_mis_api.apps.geo.models import Country -from hct_mis_api.apps.household.fixtures import DocumentTypeFactory -from hct_mis_api.apps.household.models import DocumentType def pytest_addoption(parser) -> None: # type: ignore @@ -97,8 +123,8 @@ def pytest_configure(config) -> None: # type: ignore settings.SCREENSHOT_DIRECTORY = f"{settings.REPORT_DIRECTORY}/screenshot" if not os.path.exists(settings.SCREENSHOT_DIRECTORY): os.makedirs(settings.SCREENSHOT_DIRECTORY) - print('settings.SCREENSHOT_DIRECTORY',settings.SCREENSHOT_DIRECTORY) - print('*'*70) + print("settings.SCREENSHOT_DIRECTORY", settings.SCREENSHOT_DIRECTORY) + print("*" * 70) for file in os.listdir(settings.SCREENSHOT_DIRECTORY): os.remove(os.path.join(settings.SCREENSHOT_DIRECTORY, file)) diff --git a/tests/selenium/country_dashboard/test_country_dashboard.py b/tests/selenium/country_dashboard/test_country_dashboard.py index b305bcd3d0..1f8f5a3cba 100644 --- a/tests/selenium/country_dashboard/test_country_dashboard.py +++ b/tests/selenium/country_dashboard/test_country_dashboard.py @@ -1,5 +1,8 @@ import pytest -from tests.selenium.page_object.country_dashboard.country_dashboard import CountryDashboard + +from tests.selenium.page_object.country_dashboard.country_dashboard import ( + CountryDashboard, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/drawer/test_drawer.py b/tests/selenium/drawer/test_drawer.py index 25b81ad839..104249977b 100644 --- a/tests/selenium/drawer/test_drawer.py +++ b/tests/selenium/drawer/test_drawer.py @@ -2,13 +2,17 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.page_object.programme_details.programme_details import ProgrammeDetails -from tests.selenium.page_object.programme_management.programme_management import ProgrammeManagement from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory from hct_mis_api.apps.core.models import BusinessArea, DataCollectingType from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program +from tests.selenium.page_object.programme_details.programme_details import ( + ProgrammeDetails, +) +from tests.selenium.page_object.programme_management.programme_management import ( + ProgrammeManagement, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/filters/test_filters.py b/tests/selenium/filters/test_filters.py index f6e6b03536..f6f5c92ec6 100644 --- a/tests/selenium/filters/test_filters.py +++ b/tests/selenium/filters/test_filters.py @@ -5,7 +5,6 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.page_object.filters import Filters from hct_mis_api.apps.account.models import User from hct_mis_api.apps.core.models import BusinessArea @@ -27,6 +26,7 @@ TargetPopulationFactory, ) from hct_mis_api.apps.targeting.models import TargetPopulation +from tests.selenium.page_object.filters import Filters from tests.selenium.page_object.grievance.details_grievance_page import ( GrievanceDetailsPage, ) diff --git a/tests/selenium/grievance/feedback/test_feedback.py b/tests/selenium/grievance/feedback/test_feedback.py index 20195c61d3..7f091d980f 100644 --- a/tests/selenium/grievance/feedback/test_feedback.py +++ b/tests/selenium/grievance/feedback/test_feedback.py @@ -4,10 +4,6 @@ from django.core.management import call_command import pytest -from tests.selenium.page_object.grievance.details_feedback_page import FeedbackDetailsPage -from tests.selenium.page_object.grievance.feedback import Feedback -from tests.selenium.page_object.grievance.new_feedback import NewFeedback -from tests.selenium.page_object.programme_details.programme_details import ProgrammeDetails from pytest_django import DjangoDbBlocker from selenium.webdriver import Keys @@ -15,10 +11,18 @@ from hct_mis_api.apps.household.fixtures import create_household_and_individuals from hct_mis_api.apps.household.models import HOST, Household from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name +from tests.selenium.page_object.grievance.details_feedback_page import ( + FeedbackDetailsPage, +) from tests.selenium.page_object.grievance.details_grievance_page import ( GrievanceDetailsPage, ) +from tests.selenium.page_object.grievance.feedback import Feedback +from tests.selenium.page_object.grievance.new_feedback import NewFeedback from tests.selenium.page_object.grievance.new_ticket import NewTicket +from tests.selenium.page_object.programme_details.programme_details import ( + ProgrammeDetails, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/grievance/grievance_dashboard/test_grievance_dashboard.py b/tests/selenium/grievance/grievance_dashboard/test_grievance_dashboard.py index 3c38c22f58..9d15fd4337 100644 --- a/tests/selenium/grievance/grievance_dashboard/test_grievance_dashboard.py +++ b/tests/selenium/grievance/grievance_dashboard/test_grievance_dashboard.py @@ -5,15 +5,17 @@ from django.utils import timezone import pytest -from tests.selenium.page_object.grievance.details_grievance_page import GrievanceDetailsPage -from tests.selenium.page_object.grievance.grievance_dashboard import GrievanceDashboard -from tests.selenium.page_object.grievance.grievance_tickets import GrievanceTickets from hct_mis_api.apps.account.models import User from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.grievance.models import GrievanceTicket from hct_mis_api.apps.program.models import Program from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name +from tests.selenium.page_object.grievance.details_grievance_page import ( + GrievanceDetailsPage, +) +from tests.selenium.page_object.grievance.grievance_dashboard import GrievanceDashboard +from tests.selenium.page_object.grievance.grievance_tickets import GrievanceTickets pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/grievance/grievance_tickets/test_grievance_tickets.py b/tests/selenium/grievance/grievance_tickets/test_grievance_tickets.py index bcc51e2b55..f203fbc3d4 100644 --- a/tests/selenium/grievance/grievance_tickets/test_grievance_tickets.py +++ b/tests/selenium/grievance/grievance_tickets/test_grievance_tickets.py @@ -8,9 +8,6 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.page_object.grievance.details_grievance_page import GrievanceDetailsPage -from tests.selenium.page_object.grievance.grievance_tickets import GrievanceTickets -from tests.selenium.page_object.grievance.new_ticket import NewTicket from pytest_django import DjangoDbBlocker from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement @@ -38,6 +35,11 @@ from tests.selenium.drawer.test_drawer import get_program_with_dct_type_and_name from tests.selenium.helpers.date_time_format import FormatTime from tests.selenium.page_object.admin_panel.admin_panel import AdminPanel +from tests.selenium.page_object.grievance.details_grievance_page import ( + GrievanceDetailsPage, +) +from tests.selenium.page_object.grievance.grievance_tickets import GrievanceTickets +from tests.selenium.page_object.grievance.new_ticket import NewTicket from tests.selenium.page_object.programme_population.households import Households from tests.selenium.page_object.programme_population.households_details import ( HouseholdsDetails, diff --git a/tests/selenium/login_via_admin_panel/test_login.py b/tests/selenium/login_via_admin_panel/test_login.py index 392f1e3878..6516392d48 100644 --- a/tests/selenium/login_via_admin_panel/test_login.py +++ b/tests/selenium/login_via_admin_panel/test_login.py @@ -1,10 +1,10 @@ import pytest -from tests.selenium.page_object.admin_panel.admin_panel import AdminPanel from selenium.webdriver import Chrome from selenium.webdriver.common.by import By from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.models import User +from tests.selenium.page_object.admin_panel.admin_panel import AdminPanel pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/managerial_console/test_managerial_console.py b/tests/selenium/managerial_console/test_managerial_console.py index a8d592cac8..2d3e759560 100644 --- a/tests/selenium/managerial_console/test_managerial_console.py +++ b/tests/selenium/managerial_console/test_managerial_console.py @@ -4,7 +4,6 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.page_object.managerial_console.managerial_console import ManagerialConsole from selenium.webdriver.common.by import By from hct_mis_api.apps.account.fixtures import UserFactory @@ -20,6 +19,9 @@ TargetPopulationFactory, ) from hct_mis_api.apps.targeting.models import TargetPopulation +from tests.selenium.page_object.managerial_console.managerial_console import ( + ManagerialConsole, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/page_object/404.py b/tests/selenium/page_object/404.py index e3d6568151..7b1737475e 100644 --- a/tests/selenium/page_object/404.py +++ b/tests/selenium/page_object/404.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class ErrorPage(BaseComponents): # Locators diff --git a/tests/selenium/page_object/accountability/communication.py b/tests/selenium/page_object/accountability/communication.py index c406de5076..3cd3a833ee 100644 --- a/tests/selenium/page_object/accountability/communication.py +++ b/tests/selenium/page_object/accountability/communication.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class AccountabilityCommunication(BaseComponents): # Locators diff --git a/tests/selenium/page_object/accountability/comunication_details.py b/tests/selenium/page_object/accountability/comunication_details.py index cbc32e3c3a..9a1dc7610d 100644 --- a/tests/selenium/page_object/accountability/comunication_details.py +++ b/tests/selenium/page_object/accountability/comunication_details.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class AccountabilityCommunicationDetails(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/accountability/surveys.py b/tests/selenium/page_object/accountability/surveys.py index e8447ddc01..4c1c470653 100644 --- a/tests/selenium/page_object/accountability/surveys.py +++ b/tests/selenium/page_object/accountability/surveys.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class AccountabilitySurveys(BaseComponents): # Locators diff --git a/tests/selenium/page_object/accountability/surveys_details.py b/tests/selenium/page_object/accountability/surveys_details.py index e139e3303b..95f4f7c83f 100644 --- a/tests/selenium/page_object/accountability/surveys_details.py +++ b/tests/selenium/page_object/accountability/surveys_details.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class AccountabilitySurveysDetails(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/admin_panel/admin_panel.py b/tests/selenium/page_object/admin_panel/admin_panel.py index 267bd5d5f3..895528d86f 100644 --- a/tests/selenium/page_object/admin_panel/admin_panel.py +++ b/tests/selenium/page_object/admin_panel/admin_panel.py @@ -1,7 +1,8 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class AdminPanel(BaseComponents): login = "id_username" diff --git a/tests/selenium/page_object/base_components.py b/tests/selenium/page_object/base_components.py index 2ad85ba7c0..e9d5b0a876 100644 --- a/tests/selenium/page_object/base_components.py +++ b/tests/selenium/page_object/base_components.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.helpers.helper import Common from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.helpers.helper import Common + class BaseComponents(Common): # Labels diff --git a/tests/selenium/page_object/country_dashboard/country_dashboard.py b/tests/selenium/page_object/country_dashboard/country_dashboard.py index ee7067511c..10a818519b 100644 --- a/tests/selenium/page_object/country_dashboard/country_dashboard.py +++ b/tests/selenium/page_object/country_dashboard/country_dashboard.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class CountryDashboard(BaseComponents): navResourcesReleaseNote = 'a[data-cy="nav-resources-Release Note"]' diff --git a/tests/selenium/page_object/filters.py b/tests/selenium/page_object/filters.py index c2a17efc40..d17a9607c9 100644 --- a/tests/selenium/page_object/filters.py +++ b/tests/selenium/page_object/filters.py @@ -1,9 +1,10 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class Filters(BaseComponents): filtersSearch = 'div[data-cy="filters-search"]' diff --git a/tests/selenium/page_object/grievance/details_feedback_page.py b/tests/selenium/page_object/grievance/details_feedback_page.py index 3800042fdd..188f060023 100644 --- a/tests/selenium/page_object/grievance/details_feedback_page.py +++ b/tests/selenium/page_object/grievance/details_feedback_page.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class FeedbackDetailsPage(BaseComponents): # Locators diff --git a/tests/selenium/page_object/grievance/details_grievance_page.py b/tests/selenium/page_object/grievance/details_grievance_page.py index 7c9c8ca85b..a083204826 100644 --- a/tests/selenium/page_object/grievance/details_grievance_page.py +++ b/tests/selenium/page_object/grievance/details_grievance_page.py @@ -1,9 +1,10 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class GrievanceDetailsPage(BaseComponents): # Locators diff --git a/tests/selenium/page_object/grievance/feedback.py b/tests/selenium/page_object/grievance/feedback.py index 64ff54acc5..c3602b62e4 100644 --- a/tests/selenium/page_object/grievance/feedback.py +++ b/tests/selenium/page_object/grievance/feedback.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class Feedback(BaseComponents): # Locators diff --git a/tests/selenium/page_object/grievance/grievance_dashboard.py b/tests/selenium/page_object/grievance/grievance_dashboard.py index d968bc3b7f..4935296e89 100644 --- a/tests/selenium/page_object/grievance/grievance_dashboard.py +++ b/tests/selenium/page_object/grievance/grievance_dashboard.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class GrievanceDashboard(BaseComponents): # Locators diff --git a/tests/selenium/page_object/grievance/grievance_tickets.py b/tests/selenium/page_object/grievance/grievance_tickets.py index 140af1994e..776511cdde 100644 --- a/tests/selenium/page_object/grievance/grievance_tickets.py +++ b/tests/selenium/page_object/grievance/grievance_tickets.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class GrievanceTickets(BaseComponents): # Locators diff --git a/tests/selenium/page_object/grievance/new_feedback.py b/tests/selenium/page_object/grievance/new_feedback.py index 2a25af307f..37ab4e7c48 100644 --- a/tests/selenium/page_object/grievance/new_feedback.py +++ b/tests/selenium/page_object/grievance/new_feedback.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class NewFeedback(BaseComponents): # Locators diff --git a/tests/selenium/page_object/grievance/new_ticket.py b/tests/selenium/page_object/grievance/new_ticket.py index cd1c87c750..dd0ef168ce 100644 --- a/tests/selenium/page_object/grievance/new_ticket.py +++ b/tests/selenium/page_object/grievance/new_ticket.py @@ -1,9 +1,10 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class NewTicket(BaseComponents): # Locators diff --git a/tests/selenium/page_object/managerial_console/managerial_console.py b/tests/selenium/page_object/managerial_console/managerial_console.py index 273655a87a..f826add927 100644 --- a/tests/selenium/page_object/managerial_console/managerial_console.py +++ b/tests/selenium/page_object/managerial_console/managerial_console.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class ManagerialConsole(BaseComponents): pageHeaderTitle = 'h5[data-cy="page-header-title"]' diff --git a/tests/selenium/page_object/payment_module/new_payment_plan.py b/tests/selenium/page_object/payment_module/new_payment_plan.py index 19d79f7810..e27b34b382 100644 --- a/tests/selenium/page_object/payment_module/new_payment_plan.py +++ b/tests/selenium/page_object/payment_module/new_payment_plan.py @@ -1,7 +1,8 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class NewPaymentPlan(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/payment_module/payment_module.py b/tests/selenium/page_object/payment_module/payment_module.py index 5e8683d346..c2dfad805e 100644 --- a/tests/selenium/page_object/payment_module/payment_module.py +++ b/tests/selenium/page_object/payment_module/payment_module.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class PaymentModule(BaseComponents): pageHeaderTitle = 'h5[data-cy="page-header-title"]' diff --git a/tests/selenium/page_object/payment_module/payment_module_details.py b/tests/selenium/page_object/payment_module/payment_module_details.py index eb2794c306..8e7cba74ed 100644 --- a/tests/selenium/page_object/payment_module/payment_module_details.py +++ b/tests/selenium/page_object/payment_module/payment_module_details.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class PaymentModuleDetails(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/payment_module/program_cycle.py b/tests/selenium/page_object/payment_module/program_cycle.py index 9c9f938351..a65a281ee5 100644 --- a/tests/selenium/page_object/payment_module/program_cycle.py +++ b/tests/selenium/page_object/payment_module/program_cycle.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class ProgramCyclePage(BaseComponents): mainContent = 'div[data-cy="main-content"]' diff --git a/tests/selenium/page_object/payment_verification/payment_record.py b/tests/selenium/page_object/payment_verification/payment_record.py index 30738956d3..b85c2500ad 100644 --- a/tests/selenium/page_object/payment_verification/payment_record.py +++ b/tests/selenium/page_object/payment_verification/payment_record.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class PaymentRecord(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/payment_verification/payment_verification.py b/tests/selenium/page_object/payment_verification/payment_verification.py index b65f7f585d..dd1b88e2fe 100644 --- a/tests/selenium/page_object/payment_verification/payment_verification.py +++ b/tests/selenium/page_object/payment_verification/payment_verification.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class PaymentVerification(BaseComponents): # Locators diff --git a/tests/selenium/page_object/payment_verification/payment_verification_details.py b/tests/selenium/page_object/payment_verification/payment_verification_details.py index 03ba259f11..a0afa25be2 100644 --- a/tests/selenium/page_object/payment_verification/payment_verification_details.py +++ b/tests/selenium/page_object/payment_verification/payment_verification_details.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class PaymentVerificationDetails(BaseComponents): # Locators diff --git a/tests/selenium/page_object/people/people.py b/tests/selenium/page_object/people/people.py index 355eb26895..2708e9d866 100644 --- a/tests/selenium/page_object/people/people.py +++ b/tests/selenium/page_object/people/people.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class People(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/program_log/payment_log.py b/tests/selenium/page_object/program_log/payment_log.py index 9913ceea2c..3f5953e678 100644 --- a/tests/selenium/page_object/program_log/payment_log.py +++ b/tests/selenium/page_object/program_log/payment_log.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class ProgramLog(BaseComponents): mainActivityLogTable = 'div[data-cy="main-activity-log-table"]' diff --git a/tests/selenium/page_object/programme_details/programme_details.py b/tests/selenium/page_object/programme_details/programme_details.py index c9ebd352d5..f4b5d0ba45 100644 --- a/tests/selenium/page_object/programme_details/programme_details.py +++ b/tests/selenium/page_object/programme_details/programme_details.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class ProgrammeDetails(BaseComponents): headerTitle = 'h5[data-cy="page-header-title"]' diff --git a/tests/selenium/page_object/programme_management/programme_management.py b/tests/selenium/page_object/programme_management/programme_management.py index bc79c4c85b..298236911a 100644 --- a/tests/selenium/page_object/programme_management/programme_management.py +++ b/tests/selenium/page_object/programme_management/programme_management.py @@ -1,10 +1,11 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class ProgrammeManagement(BaseComponents): headerTitle = 'h5[data-cy="page-header-title"]' diff --git a/tests/selenium/page_object/programme_population/households.py b/tests/selenium/page_object/programme_population/households.py index 938ed53932..2c00db3f20 100644 --- a/tests/selenium/page_object/programme_population/households.py +++ b/tests/selenium/page_object/programme_population/households.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class Households(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/programme_population/households_details.py b/tests/selenium/page_object/programme_population/households_details.py index dec9e5ccd3..2eb43fada2 100644 --- a/tests/selenium/page_object/programme_population/households_details.py +++ b/tests/selenium/page_object/programme_population/households_details.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class HouseholdsDetails(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/programme_population/individuals.py b/tests/selenium/page_object/programme_population/individuals.py index c3dcbf8c04..204f78254b 100644 --- a/tests/selenium/page_object/programme_population/individuals.py +++ b/tests/selenium/page_object/programme_population/individuals.py @@ -1,8 +1,9 @@ from typing import Union -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class Individuals(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/programme_population/individuals_details.py b/tests/selenium/page_object/programme_population/individuals_details.py index 44c5e2e69f..86b349b800 100644 --- a/tests/selenium/page_object/programme_population/individuals_details.py +++ b/tests/selenium/page_object/programme_population/individuals_details.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class IndividualsDetails(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/programme_population/periodic_data_update_templates.py b/tests/selenium/page_object/programme_population/periodic_data_update_templates.py index 1aa7f13bf0..bfd700609a 100644 --- a/tests/selenium/page_object/programme_population/periodic_data_update_templates.py +++ b/tests/selenium/page_object/programme_population/periodic_data_update_templates.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class PeriodicDatUpdateTemplates(BaseComponents): navProgramPopulation = 'a[data-cy="nav-Programme Population"]' diff --git a/tests/selenium/page_object/programme_population/periodic_data_update_uploads.py b/tests/selenium/page_object/programme_population/periodic_data_update_uploads.py index 66d646689e..285779f314 100644 --- a/tests/selenium/page_object/programme_population/periodic_data_update_uploads.py +++ b/tests/selenium/page_object/programme_population/periodic_data_update_uploads.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class PeriodicDataUpdateUploads(BaseComponents): navProgramPopulation = 'a[data-cy="nav-Programme Population"]' diff --git a/tests/selenium/page_object/programme_users/programme_users.py b/tests/selenium/page_object/programme_users/programme_users.py index 50da539152..db62c5db26 100644 --- a/tests/selenium/page_object/programme_users/programme_users.py +++ b/tests/selenium/page_object/programme_users/programme_users.py @@ -1,6 +1,7 @@ -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class ProgrammeUsers(BaseComponents): pageHeaderTitle = 'h5[data-cy="page-header-title"]' diff --git a/tests/selenium/page_object/registration_data_import/rdi_details_page.py b/tests/selenium/page_object/registration_data_import/rdi_details_page.py index d29fbc4669..2d8eca8ad3 100644 --- a/tests/selenium/page_object/registration_data_import/rdi_details_page.py +++ b/tests/selenium/page_object/registration_data_import/rdi_details_page.py @@ -1,9 +1,10 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class RDIDetailsPage(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' diff --git a/tests/selenium/page_object/registration_data_import/registration_data_import.py b/tests/selenium/page_object/registration_data_import/registration_data_import.py index eb2bed3376..814b3263aa 100644 --- a/tests/selenium/page_object/registration_data_import/registration_data_import.py +++ b/tests/selenium/page_object/registration_data_import/registration_data_import.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class RegistrationDataImport(BaseComponents): # Locators diff --git a/tests/selenium/page_object/targeting/targeting.py b/tests/selenium/page_object/targeting/targeting.py index 7212ed41df..4083e76b48 100644 --- a/tests/selenium/page_object/targeting/targeting.py +++ b/tests/selenium/page_object/targeting/targeting.py @@ -1,10 +1,10 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement from hct_mis_api.apps.core.utils import encode_id_base64 +from tests.selenium.page_object.base_components import BaseComponents class Targeting(BaseComponents): diff --git a/tests/selenium/page_object/targeting/targeting_create.py b/tests/selenium/page_object/targeting/targeting_create.py index d2f19681a5..1c9c938ca1 100644 --- a/tests/selenium/page_object/targeting/targeting_create.py +++ b/tests/selenium/page_object/targeting/targeting_create.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class TargetingCreate(BaseComponents): # Locators diff --git a/tests/selenium/page_object/targeting/targeting_details.py b/tests/selenium/page_object/targeting/targeting_details.py index 981f7059cc..f1f03bd0d6 100644 --- a/tests/selenium/page_object/targeting/targeting_details.py +++ b/tests/selenium/page_object/targeting/targeting_details.py @@ -1,8 +1,9 @@ from time import sleep -from tests.selenium.page_object.base_components import BaseComponents from selenium.webdriver.remote.webelement import WebElement +from tests.selenium.page_object.base_components import BaseComponents + class TargetingDetails(BaseComponents): # Locators diff --git a/tests/selenium/payment_module/test_payment_plans.py b/tests/selenium/payment_module/test_payment_plans.py index c01bc99975..08693d949b 100644 --- a/tests/selenium/payment_module/test_payment_plans.py +++ b/tests/selenium/payment_module/test_payment_plans.py @@ -6,16 +6,8 @@ import openpyxl import pytest from dateutil.relativedelta import relativedelta -from sorl.thumbnail.conf import settings - -from tests.selenium.page_object.payment_module.new_payment_plan import NewPaymentPlan -from tests.selenium.page_object.payment_module.payment_module import PaymentModule -from tests.selenium.page_object.payment_module.payment_module_details import PaymentModuleDetails -from tests.selenium.page_object.payment_module.program_cycle import ( - ProgramCycleDetailsPage, - ProgramCyclePage, -) from selenium.webdriver.common.by import By +from sorl.thumbnail.conf import settings from hct_mis_api.apps.account.models import User from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory @@ -42,6 +34,15 @@ ) from hct_mis_api.apps.targeting.models import TargetPopulation from tests.selenium.helpers.date_time_format import FormatTime +from tests.selenium.page_object.payment_module.new_payment_plan import NewPaymentPlan +from tests.selenium.page_object.payment_module.payment_module import PaymentModule +from tests.selenium.page_object.payment_module.payment_module_details import ( + PaymentModuleDetails, +) +from tests.selenium.page_object.payment_module.program_cycle import ( + ProgramCycleDetailsPage, + ProgramCyclePage, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/payment_module/test_program_cycles.py b/tests/selenium/payment_module/test_program_cycles.py index 1e59cd666b..dca1769a61 100644 --- a/tests/selenium/payment_module/test_program_cycles.py +++ b/tests/selenium/payment_module/test_program_cycles.py @@ -2,7 +2,6 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.page_object.payment_module.program_cycle import ProgramCyclePage from selenium.webdriver.common.by import By from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory @@ -10,6 +9,7 @@ from hct_mis_api.apps.payment.fixtures import PaymentPlanFactory from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program, ProgramCycle +from tests.selenium.page_object.payment_module.program_cycle import ProgramCyclePage pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/payment_verification/test_payment_verification.py b/tests/selenium/payment_verification/test_payment_verification.py index 707b1d97ba..086c14fbf1 100644 --- a/tests/selenium/payment_verification/test_payment_verification.py +++ b/tests/selenium/payment_verification/test_payment_verification.py @@ -3,11 +3,6 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.page_object.payment_verification.payment_record import PaymentRecord -from tests.selenium.page_object.payment_verification.payment_verification import PaymentVerification -from tests.selenium.page_object.payment_verification.payment_verification_details import ( - PaymentVerificationDetails, -) from selenium.webdriver.common.by import By from hct_mis_api.apps.account.models import User @@ -32,6 +27,13 @@ TargetingCriteriaFactory, TargetPopulationFactory, ) +from tests.selenium.page_object.payment_verification.payment_record import PaymentRecord +from tests.selenium.page_object.payment_verification.payment_verification import ( + PaymentVerification, +) +from tests.selenium.page_object.payment_verification.payment_verification_details import ( + PaymentVerificationDetails, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/people/test_people.py b/tests/selenium/people/test_people.py index b2abc03a2e..d3cd69b48b 100644 --- a/tests/selenium/people/test_people.py +++ b/tests/selenium/people/test_people.py @@ -5,7 +5,6 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.page_object.people.people import People from selenium.webdriver.common.by import By from hct_mis_api.apps.account.models import User @@ -30,6 +29,7 @@ ) from tests.selenium.page_object.grievance.grievance_tickets import GrievanceTickets from tests.selenium.page_object.grievance.new_ticket import NewTicket +from tests.selenium.page_object.people.people import People from tests.selenium.page_object.people.people_details import PeopleDetails pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/people/test_people_periodic_data_update.py b/tests/selenium/people/test_people_periodic_data_update.py index 2956a6017a..c07729e89b 100644 --- a/tests/selenium/people/test_people_periodic_data_update.py +++ b/tests/selenium/people/test_people_periodic_data_update.py @@ -2,9 +2,10 @@ from datetime import datetime from time import sleep +from django.conf import settings + import pytest from dateutil.relativedelta import relativedelta -from django.conf import settings from hct_mis_api.apps.account.models import User from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory, create_afghanistan diff --git a/tests/selenium/program_details/test_program_details.py b/tests/selenium/program_details/test_program_details.py index dd9a30ef44..a87668f885 100644 --- a/tests/selenium/program_details/test_program_details.py +++ b/tests/selenium/program_details/test_program_details.py @@ -7,9 +7,6 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.helpers.date_time_format import FormatTime -from tests.selenium.page_object.programme_details.programme_details import ProgrammeDetails -from tests.selenium.page_object.programme_management.programme_management import ProgrammeManagement from selenium.webdriver import Keys from hct_mis_api.apps.account.models import User @@ -28,6 +25,13 @@ TargetPopulationFactory, ) from hct_mis_api.apps.targeting.models import TargetPopulation +from tests.selenium.helpers.date_time_format import FormatTime +from tests.selenium.page_object.programme_details.programme_details import ( + ProgrammeDetails, +) +from tests.selenium.page_object.programme_management.programme_management import ( + ProgrammeManagement, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/program_log/test_program_log.py b/tests/selenium/program_log/test_program_log.py index 252908f4e6..8c3ab19df5 100644 --- a/tests/selenium/program_log/test_program_log.py +++ b/tests/selenium/program_log/test_program_log.py @@ -1,12 +1,14 @@ from datetime import datetime import pytest -from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name -from tests.selenium.page_object.program_log.payment_log import ProgramLog -from tests.selenium.page_object.programme_details.programme_details import ProgrammeDetails from hct_mis_api.apps.account.models import User from hct_mis_api.apps.program.models import Program +from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name +from tests.selenium.page_object.program_log.payment_log import ProgramLog +from tests.selenium.page_object.programme_details.programme_details import ( + ProgrammeDetails, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/programme_management/test_programme_management.py b/tests/selenium/programme_management/test_programme_management.py index dc39300971..dd8b2a0289 100644 --- a/tests/selenium/programme_management/test_programme_management.py +++ b/tests/selenium/programme_management/test_programme_management.py @@ -7,10 +7,6 @@ import pytest from dateutil.relativedelta import relativedelta -from freezegun import freeze_time -from tests.selenium.helpers.date_time_format import FormatTime -from tests.selenium.page_object.programme_details.programme_details import ProgrammeDetails -from tests.selenium.page_object.programme_management.programme_management import ProgrammeManagement from selenium import webdriver from selenium.webdriver import Keys from selenium.webdriver.common.by import By @@ -20,6 +16,13 @@ from hct_mis_api.apps.core.models import BusinessArea, BusinessAreaPartnerThrough from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory +from tests.selenium.helpers.date_time_format import FormatTime +from tests.selenium.page_object.programme_details.programme_details import ( + ProgrammeDetails, +) +from tests.selenium.page_object.programme_management.programme_management import ( + ProgrammeManagement, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/programme_population/test_households.py b/tests/selenium/programme_population/test_households.py index 22e0f2dcc9..a8f57e54db 100644 --- a/tests/selenium/programme_population/test_households.py +++ b/tests/selenium/programme_population/test_households.py @@ -2,8 +2,11 @@ from django.core.management import call_command import pytest + from tests.selenium.page_object.programme_population.households import Households -from tests.selenium.page_object.programme_population.households_details import HouseholdsDetails +from tests.selenium.page_object.programme_population.households_details import ( + HouseholdsDetails, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/programme_population/test_individuals.py b/tests/selenium/programme_population/test_individuals.py index b995ef2754..5b3456efd2 100644 --- a/tests/selenium/programme_population/test_individuals.py +++ b/tests/selenium/programme_population/test_individuals.py @@ -3,8 +3,11 @@ import pytest from freezegun import freeze_time + from tests.selenium.page_object.programme_population.individuals import Individuals -from tests.selenium.page_object.programme_population.individuals_details import IndividualsDetails +from tests.selenium.page_object.programme_population.individuals_details import ( + IndividualsDetails, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/programme_population/test_periodic_data_templates.py b/tests/selenium/programme_population/test_periodic_data_templates.py index a435a34dac..3710661764 100644 --- a/tests/selenium/programme_population/test_periodic_data_templates.py +++ b/tests/selenium/programme_population/test_periodic_data_templates.py @@ -1,13 +1,9 @@ import os from time import sleep -import pytest from django.conf import settings -from tests.selenium.page_object.programme_population.periodic_data_update_templates import ( - PeriodicDatUpdateTemplates, - PeriodicDatUpdateTemplatesDetails, -) +import pytest from selenium.webdriver.common.by import By from hct_mis_api.apps.core.fixtures import create_afghanistan @@ -27,6 +23,10 @@ from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory from hct_mis_api.apps.registration_data.models import RegistrationDataImport from tests.selenium.page_object.programme_population.individuals import Individuals +from tests.selenium.page_object.programme_population.periodic_data_update_templates import ( + PeriodicDatUpdateTemplates, + PeriodicDatUpdateTemplatesDetails, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/programme_population/test_periodic_data_update_upload.py b/tests/selenium/programme_population/test_periodic_data_update_upload.py index e827e73e0b..cf62007c2b 100644 --- a/tests/selenium/programme_population/test_periodic_data_update_upload.py +++ b/tests/selenium/programme_population/test_periodic_data_update_upload.py @@ -2,16 +2,10 @@ from tempfile import NamedTemporaryFile, _TemporaryFileWrapper from typing import Any -import openpyxl -import pytest from django.conf import settings -from tests.selenium.page_object.programme_population.periodic_data_update_templates import ( - PeriodicDatUpdateTemplates, -) -from tests.selenium.page_object.programme_population.periodic_data_update_uploads import ( - PeriodicDataUpdateUploads, -) +import openpyxl +import pytest from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory, create_afghanistan from hct_mis_api.apps.core.models import ( @@ -40,6 +34,12 @@ from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory from tests.selenium.page_object.programme_population.individuals import Individuals +from tests.selenium.page_object.programme_population.periodic_data_update_templates import ( + PeriodicDatUpdateTemplates, +) +from tests.selenium.page_object.programme_population.periodic_data_update_uploads import ( + PeriodicDataUpdateUploads, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/programme_user/test_programme_user.py b/tests/selenium/programme_user/test_programme_user.py index 87399502ac..996fd1350f 100644 --- a/tests/selenium/programme_user/test_programme_user.py +++ b/tests/selenium/programme_user/test_programme_user.py @@ -1,9 +1,9 @@ import pytest -from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name -from tests.selenium.page_object.programme_users.programme_users import ProgrammeUsers from hct_mis_api.apps.core.models import DataCollectingType from hct_mis_api.apps.program.models import Program +from tests.selenium.helpers.fixtures import get_program_with_dct_type_and_name +from tests.selenium.page_object.programme_users.programme_users import ProgrammeUsers pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/registration_data_import/test_registration_data_import.py b/tests/selenium/registration_data_import/test_registration_data_import.py index 7925ee11e9..e63c0bf912 100644 --- a/tests/selenium/registration_data_import/test_registration_data_import.py +++ b/tests/selenium/registration_data_import/test_registration_data_import.py @@ -3,17 +3,21 @@ import pytest from elasticsearch_dsl import connections -from tests.selenium.page_object.programme_population.households_details import HouseholdsDetails -from tests.selenium.page_object.registration_data_import.rdi_details_page import RDIDetailsPage -from tests.selenium.page_object.registration_data_import.registration_data_import import ( - RegistrationDataImport, -) from hct_mis_api.apps.account.fixtures import PartnerFactory from hct_mis_api.apps.account.models import Partner from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.geo.models import Area, AreaType, Country from hct_mis_api.apps.utils.elasticsearch_utils import rebuild_search_index +from tests.selenium.page_object.programme_population.households_details import ( + HouseholdsDetails, +) +from tests.selenium.page_object.registration_data_import.rdi_details_page import ( + RDIDetailsPage, +) +from tests.selenium.page_object.registration_data_import.registration_data_import import ( + RegistrationDataImport, +) pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/selenium/targeting/test_targeting.py b/tests/selenium/targeting/test_targeting.py index a76c25b2e7..5687670633 100644 --- a/tests/selenium/targeting/test_targeting.py +++ b/tests/selenium/targeting/test_targeting.py @@ -7,9 +7,6 @@ import pytest from dateutil.relativedelta import relativedelta -from tests.selenium.page_object.targeting.targeting import Targeting -from tests.selenium.page_object.targeting.targeting_create import TargetingCreate -from tests.selenium.page_object.targeting.targeting_details import TargetingDetails from selenium.common import NoSuchElementException from selenium.webdriver import ActionChains, Keys from selenium.webdriver.common.by import By @@ -44,6 +41,9 @@ from hct_mis_api.apps.targeting.fixtures import TargetingCriteriaFactory from hct_mis_api.apps.targeting.models import TargetPopulation from tests.selenium.page_object.filters import Filters +from tests.selenium.page_object.targeting.targeting import Targeting +from tests.selenium.page_object.targeting.targeting_create import TargetingCreate +from tests.selenium.page_object.targeting.targeting_details import TargetingDetails pytestmark = pytest.mark.django_db(transaction=True) diff --git a/tests/unit/api/base.py b/tests/unit/api/base.py index fc9f9af6ea..f13b28ad72 100644 --- a/tests/unit/api/base.py +++ b/tests/unit/api/base.py @@ -4,13 +4,13 @@ from rest_framework.test import APITestCase from hct_mis_api.api.models import APIToken, Grant -from tests.unit.api.factories import APITokenFactory from hct_mis_api.apps.account.fixtures import ( BusinessAreaFactory, RoleFactory, UserFactory, ) from hct_mis_api.apps.core.models import BusinessArea +from tests.unit.api.factories import APITokenFactory class HOPEApiTestCase(APITestCase): diff --git a/tests/unit/api/test_auth.py b/tests/unit/api/test_auth.py index 781ee862d7..c017532516 100644 --- a/tests/unit/api/test_auth.py +++ b/tests/unit/api/test_auth.py @@ -8,13 +8,13 @@ from hct_mis_api.api.auth import HOPEAuthentication, HOPEPermission from hct_mis_api.api.models import APIToken, Grant -from tests.unit.api.base import HOPEApiTestCase -from tests.unit.api.factories import APITokenFactory from hct_mis_api.apps.account.fixtures import ( BusinessAreaFactory, RoleFactory, UserFactory, ) +from tests.unit.api.base import HOPEApiTestCase +from tests.unit.api.factories import APITokenFactory class HOPEPermissionTest(TestCase): diff --git a/tests/unit/api/test_business_area.py b/tests/unit/api/test_business_area.py index 2434e8cf86..5367be30b4 100644 --- a/tests/unit/api/test_business_area.py +++ b/tests/unit/api/test_business_area.py @@ -4,9 +4,9 @@ from rest_framework.reverse import reverse from hct_mis_api.api.models import APIToken, Grant -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.account.fixtures import BusinessAreaFactory from hct_mis_api.apps.core.models import BusinessArea +from tests.unit.api.base import HOPEApiTestCase @contextlib.contextmanager diff --git a/tests/unit/api/test_delegate_people.py b/tests/unit/api/test_delegate_people.py index d014376d6f..72883f351f 100644 --- a/tests/unit/api/test_delegate_people.py +++ b/tests/unit/api/test_delegate_people.py @@ -7,7 +7,6 @@ from rest_framework.reverse import reverse from hct_mis_api.api.models import Grant -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory from hct_mis_api.apps.core.models import DataCollectingType from hct_mis_api.apps.core.utils import IDENTIFICATION_TYPE_TO_KEY_MAPPING @@ -22,6 +21,7 @@ from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.registration_data.models import RegistrationDataImport +from tests.unit.api.base import HOPEApiTestCase class TestDelegatePeople(HOPEApiTestCase): diff --git a/tests/unit/api/test_program.py b/tests/unit/api/test_program.py index dfe43248a9..1f006f50ba 100644 --- a/tests/unit/api/test_program.py +++ b/tests/unit/api/test_program.py @@ -4,11 +4,11 @@ from rest_framework.reverse import reverse from hct_mis_api.api.models import APIToken, Grant -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.account.fixtures import BusinessAreaFactory from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program +from tests.unit.api.base import HOPEApiTestCase @contextlib.contextmanager diff --git a/tests/unit/api/test_push_people.py b/tests/unit/api/test_push_people.py index 7e1dfb3a63..cbfa9c33f1 100644 --- a/tests/unit/api/test_push_people.py +++ b/tests/unit/api/test_push_people.py @@ -5,7 +5,6 @@ from rest_framework.reverse import reverse from hct_mis_api.api.models import Grant -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory from hct_mis_api.apps.core.models import DataCollectingType from hct_mis_api.apps.core.utils import IDENTIFICATION_TYPE_TO_KEY_MAPPING @@ -24,6 +23,7 @@ from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.registration_data.models import RegistrationDataImport +from tests.unit.api.base import HOPEApiTestCase class TestPushPeople(HOPEApiTestCase): diff --git a/tests/unit/api/test_rdi.py b/tests/unit/api/test_rdi.py index 0bbb29c129..c4a8c3bed9 100644 --- a/tests/unit/api/test_rdi.py +++ b/tests/unit/api/test_rdi.py @@ -8,7 +8,6 @@ from rest_framework.reverse import reverse from hct_mis_api.api.models import Grant -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.core.utils import IDENTIFICATION_TYPE_TO_KEY_MAPPING from hct_mis_api.apps.household.models import ( COLLECT_TYPE_FULL, @@ -25,6 +24,7 @@ ) from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.registration_data.models import RegistrationDataImport +from tests.unit.api.base import HOPEApiTestCase class CreateRDITests(HOPEApiTestCase): diff --git a/tests/unit/api/test_soft.py b/tests/unit/api/test_soft.py index 069e913e67..c5d4c40a2e 100644 --- a/tests/unit/api/test_soft.py +++ b/tests/unit/api/test_soft.py @@ -8,7 +8,6 @@ from rest_framework import status from hct_mis_api.api.models import Grant -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.core.utils import IDENTIFICATION_TYPE_TO_KEY_MAPPING from hct_mis_api.apps.household.models import ( COLLECT_TYPE_FULL, @@ -24,6 +23,7 @@ from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.registration_data.models import RegistrationDataImport +from tests.unit.api.base import HOPEApiTestCase class PushLaxToRDITests(HOPEApiTestCase): diff --git a/tests/unit/api/test_upload.py b/tests/unit/api/test_upload.py index 6af798e0bf..f7db0431b5 100644 --- a/tests/unit/api/test_upload.py +++ b/tests/unit/api/test_upload.py @@ -7,7 +7,6 @@ from rest_framework.reverse import reverse from hct_mis_api.api.models import Grant -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.core.utils import IDENTIFICATION_TYPE_TO_KEY_MAPPING from hct_mis_api.apps.household.models import ( COLLECT_TYPE_FULL, @@ -25,6 +24,7 @@ from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.registration_data.models import RegistrationDataImport +from tests.unit.api.base import HOPEApiTestCase class UploadRDITests(HOPEApiTestCase): diff --git a/tests/unit/apps/cash_assist_datahub/test_pull_from_datahub.py b/tests/unit/apps/cash_assist_datahub/test_pull_from_datahub.py index f820e0301d..48cafbd0f4 100644 --- a/tests/unit/apps/cash_assist_datahub/test_pull_from_datahub.py +++ b/tests/unit/apps/cash_assist_datahub/test_pull_from_datahub.py @@ -28,9 +28,6 @@ ) from hct_mis_api.apps.core.fixtures import create_afghanistan from hct_mis_api.apps.core.models import BusinessArea -from tests.unit.apps.core.test_exchange_rates import ( - EXCHANGE_RATES_WITH_HISTORICAL_DATA, -) from hct_mis_api.apps.household.fixtures import create_household from hct_mis_api.apps.payment.delivery_mechanisms import DeliveryMechanismChoices from hct_mis_api.apps.payment.fixtures import generate_delivery_mechanisms @@ -46,6 +43,7 @@ ) from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.targeting.models import TargetPopulation +from tests.unit.apps.core.test_exchange_rates import EXCHANGE_RATES_WITH_HISTORICAL_DATA class DummyExchangeRates: diff --git a/tests/unit/apps/core/test_exchange_rates.py b/tests/unit/apps/core/test_exchange_rates.py index 524e3c5a3f..6312604c00 100644 --- a/tests/unit/apps/core/test_exchange_rates.py +++ b/tests/unit/apps/core/test_exchange_rates.py @@ -14,9 +14,6 @@ from hct_mis_api.apps.core.exchange_rates import ExchangeRateClientAPI, ExchangeRates from hct_mis_api.apps.core.exchange_rates.api import ExchangeRateClientDummy from hct_mis_api.apps.core.models import BusinessArea -from tests.unit.apps.core.test_files.exchange_rates_api_response import ( - EXCHANGE_RATES_API_RESPONSE, -) from hct_mis_api.apps.household.fixtures import create_household from hct_mis_api.apps.payment.fixtures import ( RealCashPlanFactory, @@ -25,6 +22,9 @@ ServiceProviderFactory, ) from hct_mis_api.apps.payment.models import PaymentRecord +from tests.unit.apps.core.test_files.exchange_rates_api_response import ( + EXCHANGE_RATES_API_RESPONSE, +) EXCHANGE_RATES_WITH_HISTORICAL_DATA = { "ROWSET": { diff --git a/tests/unit/apps/grievance/test_approve_automatic_tickets.py b/tests/unit/apps/grievance/test_approve_automatic_tickets.py index 42966cfcbb..2147327fbb 100644 --- a/tests/unit/apps/grievance/test_approve_automatic_tickets.py +++ b/tests/unit/apps/grievance/test_approve_automatic_tickets.py @@ -22,7 +22,6 @@ from hct_mis_api.apps.grievance.models import GrievanceTicket from hct_mis_api.apps.household.fixtures import HouseholdFactory, IndividualFactory from hct_mis_api.apps.program.fixtures import ProgramFactory -from hct_mis_api.apps.registration_data.models import DeduplicationEngineSimilarityPair from hct_mis_api.apps.sanction_list.models import SanctionListIndividual diff --git a/tests/unit/apps/grievance/test_create_needs_adjudication_tickets.py b/tests/unit/apps/grievance/test_create_needs_adjudication_tickets.py index 6ec9df520f..1e6e1c8e19 100644 --- a/tests/unit/apps/grievance/test_create_needs_adjudication_tickets.py +++ b/tests/unit/apps/grievance/test_create_needs_adjudication_tickets.py @@ -110,9 +110,7 @@ def test_create_needs_adjudication_ticket_with_the_same_ind(self) -> None: "duplicates": [{"hit_id": str(ind_2.pk)}], "possible_duplicates": [{"hit_id": str(ind_2.pk)}], } - ind.deduplication_golden_record_results = ( - deduplication_golden_record_results_data - ) + ind.deduplication_golden_record_results = deduplication_golden_record_results_data ind_2.deduplication_golden_record_results = { "duplicates": [], "possible_duplicates": [], @@ -216,22 +214,18 @@ def setUpTestData(cls) -> None: cls.ind1, cls.ind2 = sorted(individuals, key=lambda x: x.id) cls.ind3, cls.ind4 = sorted([cls.ind1, other_individual], key=lambda x: x.id) - cls.dedup_engine_similarity_pair = ( - DeduplicationEngineSimilarityPair.objects.create( - program=program, - individual1=cls.ind1, - individual2=cls.ind2, - similarity_score=55.55, - ) + cls.dedup_engine_similarity_pair = DeduplicationEngineSimilarityPair.objects.create( + program=program, + individual1=cls.ind1, + individual2=cls.ind2, + similarity_score=55.55, ) - cls.dedup_engine_similarity_pair_2 = ( - DeduplicationEngineSimilarityPair.objects.create( - program=program, - individual1=cls.ind3, - individual2=cls.ind4, - similarity_score=75.25, - ) + cls.dedup_engine_similarity_pair_2 = DeduplicationEngineSimilarityPair.objects.create( + program=program, + individual1=cls.ind3, + individual2=cls.ind4, + similarity_score=75.25, ) def test_create_na_tickets_biometrics(self) -> None: @@ -239,17 +233,13 @@ def test_create_na_tickets_biometrics(self) -> None: self.assertEqual(TicketNeedsAdjudicationDetails.objects.all().count(), 0) self.assertIsNone(self.rdi.deduplication_engine_status) - create_needs_adjudication_tickets_for_biometrics( - DeduplicationEngineSimilarityPair.objects.none(), self.rdi - ) + create_needs_adjudication_tickets_for_biometrics(DeduplicationEngineSimilarityPair.objects.none(), self.rdi) self.assertEqual(GrievanceTicket.objects.all().count(), 0) self.assertEqual(TicketNeedsAdjudicationDetails.objects.all().count(), 0) self.assertEqual(DeduplicationEngineSimilarityPair.objects.all().count(), 2) create_needs_adjudication_tickets_for_biometrics( - DeduplicationEngineSimilarityPair.objects.filter( - pk=self.dedup_engine_similarity_pair.pk - ), + DeduplicationEngineSimilarityPair.objects.filter(pk=self.dedup_engine_similarity_pair.pk), self.rdi, ) @@ -258,9 +248,7 @@ def test_create_na_tickets_biometrics(self) -> None: grievance_ticket = GrievanceTicket.objects.first() na_ticket = TicketNeedsAdjudicationDetails.objects.first() - self.assertEqual( - grievance_ticket.category, GrievanceTicket.CATEGORY_NEEDS_ADJUDICATION - ) + self.assertEqual(grievance_ticket.category, GrievanceTicket.CATEGORY_NEEDS_ADJUDICATION) self.assertEqual( grievance_ticket.issue_type, GrievanceTicket.ISSUE_TYPE_BIOMETRICS_SIMILARITY, @@ -274,18 +262,14 @@ def test_create_na_tickets_biometrics(self) -> None: # different RDI create_needs_adjudication_tickets_for_biometrics( - DeduplicationEngineSimilarityPair.objects.filter( - pk=self.dedup_engine_similarity_pair_2.pk - ), + DeduplicationEngineSimilarityPair.objects.filter(pk=self.dedup_engine_similarity_pair_2.pk), self.rdi, ) self.assertEqual(GrievanceTicket.objects.all().count(), 2) self.assertEqual(TicketNeedsAdjudicationDetails.objects.all().count(), 2) # run one time create_needs_adjudication_tickets_for_biometrics( - DeduplicationEngineSimilarityPair.objects.filter( - pk=self.dedup_engine_similarity_pair_2.pk - ), + DeduplicationEngineSimilarityPair.objects.filter(pk=self.dedup_engine_similarity_pair_2.pk), self.rdi, ) self.assertEqual(GrievanceTicket.objects.all().count(), 2) diff --git a/tests/unit/apps/grievance/test_services_utils.py b/tests/unit/apps/grievance/test_services_utils.py index 3ca9cd72fd..08198b31f6 100644 --- a/tests/unit/apps/grievance/test_services_utils.py +++ b/tests/unit/apps/grievance/test_services_utils.py @@ -8,8 +8,6 @@ import pytest -from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory -from hct_mis_api.apps.registration_data.models import DeduplicationEngineSimilarityPair from hct_mis_api.apps.account.fixtures import ( BusinessAreaFactory, PartnerFactory, @@ -58,6 +56,8 @@ IndividualRoleInHousehold, ) from hct_mis_api.apps.program.fixtures import ProgramFactory +from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory +from hct_mis_api.apps.registration_data.models import DeduplicationEngineSimilarityPair from hct_mis_api.apps.utils.models import MergeStatusModel @@ -487,7 +487,9 @@ def test_close_needs_adjudication_ticket_service_when_just_duplicates(self) -> N @patch( "hct_mis_api.apps.registration_datahub.services.biometric_deduplication.BiometricDeduplicationService.report_false_positive_duplicate" ) - def test_close_needs_adjudication_ticket_service_for_biometrics(self, report_false_positive_duplicate_mock) -> None: + def test_close_needs_adjudication_ticket_service_for_biometrics( + self, report_false_positive_duplicate_mock: MagicMock + ) -> None: user = UserFactory() ba = BusinessAreaFactory(slug="afghanistan") deduplication_set_id = uuid.uuid4() @@ -535,6 +537,8 @@ def test_close_needs_adjudication_ticket_service_for_biometrics(self, report_fal similarity_score=90.55, ), ) + if not ticket: + raise ValueError("Ticket not created") ticket.registration_data_import = rdi ticket.save() diff --git a/tests/unit/apps/household/test_individual_iban_xlsx_update.py b/tests/unit/apps/household/test_individual_iban_xlsx_update.py index dcaa66d0e2..4d6eac522f 100644 --- a/tests/unit/apps/household/test_individual_iban_xlsx_update.py +++ b/tests/unit/apps/household/test_individual_iban_xlsx_update.py @@ -37,23 +37,17 @@ def valid_file() -> File: def invalid_file_no_match() -> File: - content = Path( - f"{settings.TESTS_ROOT}/apps/household/test_file/iban_update_invalid_no_match.xlsx" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/household/test_file/iban_update_invalid_no_match.xlsx").read_bytes() return File(BytesIO(content), name="iban_update_invalid_no_match.xlsx") def invalid_file_empty_cell() -> File: - content = Path( - f"{settings.TESTS_ROOT}/apps/household/test_file/iban_update_invalid_empty_cell.xlsx" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/household/test_file/iban_update_invalid_empty_cell.xlsx").read_bytes() return File(BytesIO(content), name="iban_update_invalid_empty_cell.xlsx") def invalid_file_bad_columns() -> File: - content = Path( - f"{settings.TESTS_ROOT}/apps/household/test_file/iban_update_invalid_bad_columns.xlsx" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/household/test_file/iban_update_invalid_bad_columns.xlsx").read_bytes() return File(BytesIO(content), name="iban_update_invalid_bad_columns.xlsx") diff --git a/tests/unit/apps/household/test_individual_query.py b/tests/unit/apps/household/test_individual_query.py index 10269047d7..36d82ba38a 100644 --- a/tests/unit/apps/household/test_individual_query.py +++ b/tests/unit/apps/household/test_individual_query.py @@ -5,11 +5,6 @@ from constance.test import override_config from parameterized import parameterized -from hct_mis_api.apps.payment.fixtures import ( - generate_delivery_mechanisms, - DeliveryMechanismDataFactory, -) -from hct_mis_api.apps.payment.models import DeliveryMechanism from hct_mis_api.apps.account.fixtures import ( BusinessAreaFactory, PartnerFactory, @@ -35,6 +30,11 @@ create_household_and_individuals, ) from hct_mis_api.apps.household.models import DocumentType, Individual +from hct_mis_api.apps.payment.fixtures import ( + DeliveryMechanismDataFactory, + generate_delivery_mechanisms, +) +from hct_mis_api.apps.payment.models import DeliveryMechanism from hct_mis_api.apps.periodic_data_update.utils import populate_pdu_with_null_values from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program @@ -118,9 +118,7 @@ def setUpTestData(cls) -> None: data_collecting_type=partial, ) - cls.household_one = HouseholdFactory.build( - business_area=cls.business_area, program=cls.program - ) + cls.household_one = HouseholdFactory.build(business_area=cls.business_area, program=cls.program) cls.household_one.household_collection.save() cls.household_one.registration_data_import.imported_by.save() cls.household_one.registration_data_import.program = cls.program @@ -187,23 +185,17 @@ def setUpTestData(cls) -> None: ] cls.individuals = [ - IndividualFactory( - household=cls.household_one, program=cls.program, **individual - ) + IndividualFactory(household=cls.household_one, program=cls.program, **individual) for index, individual in enumerate(cls.individuals_to_create) ] - cls.individuals_from_hh_one = [ - ind for ind in cls.individuals if ind.household == cls.household_one - ] + cls.individuals_from_hh_one = [ind for ind in cls.individuals if ind.household == cls.household_one] # cls.individuals_from_hh_two = [ind for ind in cls.individuals if ind.household == household_two] cls.household_one.head_of_household = cls.individuals_from_hh_one[0] # household_two.head_of_household = cls.individuals_from_hh_two[1] cls.household_one.save() # individual in program that cls.user does not have access to - cls.household_2 = HouseholdFactory.build( - business_area=cls.business_area, program=cls.program - ) + cls.household_2 = HouseholdFactory.build(business_area=cls.business_area, program=cls.program) cls.household_2.household_collection.save() cls.household_2.registration_data_import.imported_by.save() cls.household_2.registration_data_import.program = cls.program @@ -230,12 +222,8 @@ def setUpTestData(cls) -> None: bank_account_number=11110000222255558888999925, ) - cls.individual_unicef_id_to_search = Individual.objects.get( - full_name="Benjamin Butler" - ).unicef_id - cls.household_unicef_id_to_search = Individual.objects.get( - full_name="Benjamin Butler" - ).household.unicef_id + cls.individual_unicef_id_to_search = Individual.objects.get(full_name="Benjamin Butler").unicef_id + cls.household_unicef_id_to_search = Individual.objects.get(full_name="Benjamin Butler").household.unicef_id DocumentTypeFactory(key="national_id") DocumentTypeFactory(key="national_passport") @@ -295,9 +283,7 @@ def setUpTestData(cls) -> None: area_level=2, ) - cls.area1 = AreaFactory( - name="City Test1", area_type=area_type_level_1, p_code="area1" - ) + cls.area1 = AreaFactory(name="City Test1", area_type=area_type_level_1, p_code="area1") cls.area2 = AreaFactory( name="City Test2", area_type=area_type_level_2, @@ -307,12 +293,8 @@ def setUpTestData(cls) -> None: cls.household_one.set_admin_areas(cls.area2) - cls.update_partner_access_to_program( - cls.partner, cls.program, [cls.household_one.admin_area] - ) - cls.update_partner_access_to_program( - cls.partner, cls.program_draft, [cls.household_one.admin_area] - ) + cls.update_partner_access_to_program(cls.partner, cls.program, [cls.household_one.admin_area]) + cls.update_partner_access_to_program(cls.partner, cls.program_draft, [cls.household_one.admin_area]) # remove after data migration migrate_data_to_representations() @@ -326,9 +308,7 @@ def setUpTestData(cls) -> None: ] ) def test_individual_query_all(self, _: Any, permissions: List[Permissions]) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) self.snapshot_graphql_request( request_string=self.ALL_INDIVIDUALS_QUERY, @@ -347,12 +327,8 @@ def test_individual_query_all(self, _: Any, permissions: List[Permissions]) -> N ("without_permission", []), ] ) - def test_individual_query_single( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_individual_query_single(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) self.snapshot_graphql_request( request_string=self.INDIVIDUAL_QUERY, @@ -363,9 +339,7 @@ def test_individual_query_single( "Business-Area": self.business_area.slug, }, }, - variables={ - "id": self.id_to_base64(self.individuals[0].id, "IndividualNode") - }, + variables={"id": self.id_to_base64(self.individuals[0].id, "IndividualNode")}, ) def test_individual_query_single_different_program_in_header(self) -> None: @@ -385,9 +359,7 @@ def test_individual_query_single_different_program_in_header(self) -> None: "Business-Area": self.business_area.slug, }, }, - variables={ - "id": self.id_to_base64(self.individuals[0].id, "IndividualNode") - }, + variables={"id": self.id_to_base64(self.individuals[0].id, "IndividualNode")}, ) @parameterized.expand( @@ -397,12 +369,8 @@ def test_individual_query_single_different_program_in_header(self) -> None: ] ) @skip("After merging GPF, remove 2nd program") - def test_individual_programme_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program_two - ) + def test_individual_programme_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program_two) self.snapshot_graphql_request( request_string=self.ALL_INDIVIDUALS_BY_PROGRAMME_QUERY, @@ -422,12 +390,8 @@ def test_individual_programme_filter( ("without_permission", []), ] ) - def test_query_individuals_by_search_full_name_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_search_full_name_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be Jenna Franklin self.snapshot_graphql_request( @@ -459,9 +423,7 @@ def test_individual_query_draft(self) -> None: "Business-Area": self.business_area.slug, }, }, - variables={ - "program": self.id_to_base64(self.program_draft.id, "ProgramNode") - }, + variables={"program": self.id_to_base64(self.program_draft.id, "ProgramNode")}, ) @parameterized.expand( @@ -470,12 +432,8 @@ def test_individual_query_draft(self) -> None: ("without_permission", []), ] ) - def test_query_individuals_by_search_phone_no_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_search_phone_no_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be Robin Ford self.snapshot_graphql_request( @@ -496,12 +454,8 @@ def test_query_individuals_by_search_phone_no_filter( ("without_permission", []), ] ) - def test_query_individuals_by_search_national_id_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_search_national_id_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be Benjamin Butler self.snapshot_graphql_request( @@ -525,12 +479,8 @@ def test_query_individuals_by_search_national_id_filter( ("without_permission", []), ] ) - def test_query_individuals_by_search_national_passport_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_search_national_passport_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be Robin Ford self.snapshot_graphql_request( @@ -554,12 +504,8 @@ def test_query_individuals_by_search_national_passport_filter( ("without_permission", []), ] ) - def test_query_individuals_by_search_tax_id_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_search_tax_id_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be Timothy Perry self.snapshot_graphql_request( @@ -583,9 +529,7 @@ def test_query_individuals_by_search_tax_id_filter( def test_query_individuals_by_search_bank_account_number_filter( self, _: Any, permissions: List[Permissions] ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be James Bond self.snapshot_graphql_request( @@ -606,12 +550,8 @@ def test_query_individuals_by_search_bank_account_number_filter( ("without_permission", []), ] ) - def test_query_individuals_by_search_birth_certificate_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_search_birth_certificate_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be Jenna Franklin self.snapshot_graphql_request( @@ -635,12 +575,8 @@ def test_query_individuals_by_search_birth_certificate_filter( ("without_permission", []), ] ) - def test_query_individuals_by_search_disability_card_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_search_disability_card_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be Peter Parker self.snapshot_graphql_request( @@ -664,12 +600,8 @@ def test_query_individuals_by_search_disability_card_filter( ("without_permission", []), ] ) - def test_query_individuals_by_search_drivers_license_filter( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_search_drivers_license_filter(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) # Should be Benjamin Butler self.snapshot_graphql_request( @@ -693,12 +625,8 @@ def test_query_individuals_by_search_drivers_license_filter( ("without_permission", []), ] ) - def test_query_individuals_by_admin2( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_query_individuals_by_admin2(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) self.snapshot_graphql_request( request_string=self.ALL_INDIVIDUALS_QUERY, @@ -954,12 +882,8 @@ def setUpTestData(cls) -> None: ), ] ) - def test_individual_query_delivery_mechanisms_data( - self, _: Any, permissions: List[Permissions] - ) -> None: - self.create_user_role_with_permissions( - self.user, permissions, self.business_area, self.program - ) + def test_individual_query_delivery_mechanisms_data(self, _: Any, permissions: List[Permissions]) -> None: + self.create_user_role_with_permissions(self.user, permissions, self.business_area, self.program) self.snapshot_graphql_request( request_string=self.INDIVIDUAL_QUERY, diff --git a/tests/unit/apps/household/test_individual_xlsx_update.py b/tests/unit/apps/household/test_individual_xlsx_update.py index 390970ab51..452cc7faee 100644 --- a/tests/unit/apps/household/test_individual_xlsx_update.py +++ b/tests/unit/apps/household/test_individual_xlsx_update.py @@ -30,16 +30,12 @@ def valid_file() -> File: def valid_file_complex() -> File: - content = Path( - f"{settings.TESTS_ROOT}/apps/household//test_file/valid_updated_test_file_complex.xlsx" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/household//test_file/valid_updated_test_file_complex.xlsx").read_bytes() return File(BytesIO(content), name="valid_updated_test_file_complex.xlsx") def invalid_file() -> File: - content = Path( - f"{settings.TESTS_ROOT}/apps/household/test_file/invalid_updated_test_file.xlsx" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/household/test_file/invalid_updated_test_file.xlsx").read_bytes() return File(BytesIO(content), name="invalid_updated_test_file.xlsx") diff --git a/tests/unit/apps/payment/test_models1.py b/tests/unit/apps/payment/test_models1.py index b39f426c7b..fcd7a8918f 100644 --- a/tests/unit/apps/payment/test_models1.py +++ b/tests/unit/apps/payment/test_models1.py @@ -154,9 +154,7 @@ def test_can_be_locked(self) -> None: conflicted=False, currency="PLN", ) - self.assertEqual( - pp1.payment_items.filter(payment_plan_hard_conflicted=True).count(), 1 - ) + self.assertEqual(pp1.payment_items.filter(payment_plan_hard_conflicted=True).count(), 1) self.assertEqual(pp1.can_be_locked, False) # create not conflicted payment @@ -243,15 +241,9 @@ def test_manager_annotations_pp_conflicts(self) -> None: program_cycle=program_cycle, ) p1 = PaymentFactory(parent=pp1, conflicted=False, currency="PLN") - p2 = PaymentFactory( - parent=pp2, household=p1.household, conflicted=False, currency="PLN" - ) - p3 = PaymentFactory( - parent=pp3, household=p1.household, conflicted=False, currency="PLN" - ) - p4 = PaymentFactory( - parent=pp4, household=p1.household, conflicted=False, currency="PLN" - ) + p2 = PaymentFactory(parent=pp2, household=p1.household, conflicted=False, currency="PLN") + p3 = PaymentFactory(parent=pp3, household=p1.household, conflicted=False, currency="PLN") + p4 = PaymentFactory(parent=pp4, household=p1.household, conflicted=False, currency="PLN") for obj in [pp1, pp2, pp3, pp4, p1, p2, p3, p4]: obj.refresh_from_db() # update unicef_id from trigger @@ -267,9 +259,7 @@ def test_manager_annotations_pp_conflicts(self) -> None: "payment_id": str(p2.id), "payment_plan_id": str(pp2.id), "payment_plan_status": str(pp2.status), - "payment_plan_start_date": program_cycle.start_date.strftime( - "%Y-%m-%d" - ), + "payment_plan_start_date": program_cycle.start_date.strftime("%Y-%m-%d"), "payment_plan_end_date": program_cycle.end_date.strftime("%Y-%m-%d"), "payment_plan_unicef_id": str(pp2.unicef_id), "payment_unicef_id": str(p2.unicef_id), @@ -277,21 +267,14 @@ def test_manager_annotations_pp_conflicts(self) -> None: ) self.assertEqual(len(p1_data["payment_plan_soft_conflicted_data"]), 2) self.assertCountEqual( - [ - json.loads(conflict_data) - for conflict_data in p1_data["payment_plan_soft_conflicted_data"] - ], + [json.loads(conflict_data) for conflict_data in p1_data["payment_plan_soft_conflicted_data"]], [ { "payment_id": str(p3.id), "payment_plan_id": str(pp3.id), "payment_plan_status": str(pp3.status), - "payment_plan_start_date": program_cycle.start_date.strftime( - "%Y-%m-%d" - ), - "payment_plan_end_date": program_cycle.end_date.strftime( - "%Y-%m-%d" - ), + "payment_plan_start_date": program_cycle.start_date.strftime("%Y-%m-%d"), + "payment_plan_end_date": program_cycle.end_date.strftime("%Y-%m-%d"), "payment_plan_unicef_id": str(pp3.unicef_id), "payment_unicef_id": str(p3.unicef_id), }, @@ -299,12 +282,8 @@ def test_manager_annotations_pp_conflicts(self) -> None: "payment_id": str(p4.id), "payment_plan_id": str(pp4.id), "payment_plan_status": str(pp4.status), - "payment_plan_start_date": program_cycle.start_date.strftime( - "%Y-%m-%d" - ), - "payment_plan_end_date": program_cycle.end_date.strftime( - "%Y-%m-%d" - ), + "payment_plan_start_date": program_cycle.start_date.strftime("%Y-%m-%d"), + "payment_plan_end_date": program_cycle.end_date.strftime("%Y-%m-%d"), "payment_plan_unicef_id": str(pp4.unicef_id), "payment_unicef_id": str(p4.unicef_id), }, @@ -328,9 +307,7 @@ def test_manager_annotations_pp_conflicts(self) -> None: "payment_id": str(p2.id), "payment_plan_id": str(pp2.id), "payment_plan_status": str(pp2.status), - "payment_plan_start_date": program_cycle.start_date.strftime( - "%Y-%m-%d" - ), + "payment_plan_start_date": program_cycle.start_date.strftime("%Y-%m-%d"), "payment_plan_end_date": None, "payment_plan_unicef_id": str(pp2.unicef_id), "payment_unicef_id": str(p2.unicef_id), @@ -338,18 +315,13 @@ def test_manager_annotations_pp_conflicts(self) -> None: ) self.assertEqual(len(payment_data["payment_plan_soft_conflicted_data"]), 2) self.assertCountEqual( - [ - json.loads(conflict_data) - for conflict_data in payment_data["payment_plan_soft_conflicted_data"] - ], + [json.loads(conflict_data) for conflict_data in payment_data["payment_plan_soft_conflicted_data"]], [ { "payment_id": str(p3.id), "payment_plan_id": str(pp3.id), "payment_plan_status": str(pp3.status), - "payment_plan_start_date": program_cycle.start_date.strftime( - "%Y-%m-%d" - ), + "payment_plan_start_date": program_cycle.start_date.strftime("%Y-%m-%d"), "payment_plan_end_date": None, "payment_plan_unicef_id": str(pp3.unicef_id), "payment_unicef_id": str(p3.unicef_id), @@ -358,9 +330,7 @@ def test_manager_annotations_pp_conflicts(self) -> None: "payment_id": str(p4.id), "payment_plan_id": str(pp4.id), "payment_plan_status": str(pp4.status), - "payment_plan_start_date": program_cycle.start_date.strftime( - "%Y-%m-%d" - ), + "payment_plan_start_date": program_cycle.start_date.strftime("%Y-%m-%d"), "payment_plan_end_date": None, "payment_plan_unicef_id": str(pp4.unicef_id), "payment_unicef_id": str(p4.unicef_id), @@ -437,9 +407,7 @@ def test_properties(self) -> None: order=0, ) pp_split1.payments.set([p1, p2]) - self.assertEqual( - pp_split1.financial_service_provider, dm.financial_service_provider - ) + self.assertEqual(pp_split1.financial_service_provider, dm.financial_service_provider) self.assertEqual(pp_split1.chosen_configuration, dm.chosen_configuration) self.assertEqual(pp_split1.delivery_mechanism, dm.delivery_mechanism) @@ -494,12 +462,8 @@ def test_fsp_template_get_column_from_core_field(self) -> None: ) country = CountryFactory() admin_type_1 = AreaTypeFactory(country=country, area_level=1) - admin_type_2 = AreaTypeFactory( - country=country, area_level=2, parent=admin_type_1 - ) - admin_type_3 = AreaTypeFactory( - country=country, area_level=3, parent=admin_type_2 - ) + admin_type_2 = AreaTypeFactory(country=country, area_level=2, parent=admin_type_1) + admin_type_3 = AreaTypeFactory(country=country, area_level=3, parent=admin_type_2) area1 = AreaFactory(parent=None, p_code="AF01", area_type=admin_type_1) area2 = AreaFactory(parent=area1, p_code="AF0101", area_type=admin_type_2) area3 = AreaFactory(parent=area2, p_code="AF010101", area_type=admin_type_3) @@ -508,34 +472,24 @@ def test_fsp_template_get_column_from_core_field(self) -> None: household.admin3 = area3 household.save() - payment = PaymentFactory( - program=ProgramFactory(), household=household, collector=individuals[0] - ) - data_collecting_type = DataCollectingTypeFactory( - type=DataCollectingType.Type.SOCIAL - ) + payment = PaymentFactory(program=ProgramFactory(), household=household, collector=individuals[0]) + data_collecting_type = DataCollectingTypeFactory(type=DataCollectingType.Type.SOCIAL) fsp_xlsx_template = FinancialServiceProviderXlsxTemplate payment.parent.program.data_collecting_type = data_collecting_type payment.parent.program.save() # check invalid filed name - result = fsp_xlsx_template.get_column_from_core_field( - payment, "invalid_people_field_name" - ) + result = fsp_xlsx_template.get_column_from_core_field(payment, "invalid_people_field_name") self.assertIsNone(result) # People program given_name = fsp_xlsx_template.get_column_from_core_field(payment, "given_name") self.assertEqual(given_name, individuals[0].given_name) - ind_unicef_id = fsp_xlsx_template.get_column_from_core_field( - payment, "individual_unicef_id" - ) + ind_unicef_id = fsp_xlsx_template.get_column_from_core_field(payment, "individual_unicef_id") self.assertEqual(ind_unicef_id, individuals[0].unicef_id) # Standard program - payment.parent.program.data_collecting_type.type = ( - DataCollectingType.Type.STANDARD - ) + payment.parent.program.data_collecting_type.type = DataCollectingType.Type.STANDARD payment.parent.program.data_collecting_type.save() # check fields value @@ -549,35 +503,21 @@ def test_fsp_template_get_column_from_core_field(self) -> None: self.assertEqual(admin3, f"{area3.p_code} - {area3.name}") given_name = fsp_xlsx_template.get_column_from_core_field(payment, "given_name") self.assertEqual(given_name, individuals[0].given_name) - ind_unicef_id = fsp_xlsx_template.get_column_from_core_field( - payment, "individual_unicef_id" - ) + ind_unicef_id = fsp_xlsx_template.get_column_from_core_field(payment, "individual_unicef_id") self.assertEqual(ind_unicef_id, individuals[0].unicef_id) - hh_unicef_id = fsp_xlsx_template.get_column_from_core_field( - payment, "household_unicef_id" - ) + hh_unicef_id = fsp_xlsx_template.get_column_from_core_field(payment, "household_unicef_id") self.assertEqual(hh_unicef_id, household.unicef_id) phone_no = fsp_xlsx_template.get_column_from_core_field(payment, "phone_no") self.assertEqual(phone_no, individuals[0].phone_no) - phone_no_alternative = fsp_xlsx_template.get_column_from_core_field( - payment, "phone_no_alternative" - ) + phone_no_alternative = fsp_xlsx_template.get_column_from_core_field(payment, "phone_no_alternative") self.assertEqual(phone_no_alternative, individuals[0].phone_no_alternative) - national_id_no = fsp_xlsx_template.get_column_from_core_field( - payment, "national_id_no" - ) + national_id_no = fsp_xlsx_template.get_column_from_core_field(payment, "national_id_no") self.assertEqual(national_id_no, document.document_number) - wallet_name = fsp_xlsx_template.get_column_from_core_field( - payment, "wallet_name" - ) + wallet_name = fsp_xlsx_template.get_column_from_core_field(payment, "wallet_name") self.assertEqual(wallet_name, individuals[0].wallet_name) - blockchain_name = fsp_xlsx_template.get_column_from_core_field( - payment, "blockchain_name" - ) + blockchain_name = fsp_xlsx_template.get_column_from_core_field(payment, "blockchain_name") self.assertEqual(blockchain_name, individuals[0].blockchain_name) - wallet_address = fsp_xlsx_template.get_column_from_core_field( - payment, "wallet_address" - ) + wallet_address = fsp_xlsx_template.get_column_from_core_field(payment, "wallet_address") self.assertEqual(wallet_address, individuals[0].wallet_address) @@ -615,15 +555,9 @@ def test_model_form_integration(self) -> None: template = form.save() self.assertEqual(template.core_fields, ["age", "residence_status"]) - form = self.FinancialServiceProviderXlsxTemplateForm( - data={"core_fields": ["field1"]} - ) # fake core fields + form = self.FinancialServiceProviderXlsxTemplateForm(data={"core_fields": ["field1"]}) # fake core fields self.assertFalse(form.is_valid()) self.assertEqual( form.errors, - { - "core_fields": [ - "Select a valid choice. field1 is not one of the available choices." - ] - }, + {"core_fields": ["Select a valid choice. field1 is not one of the available choices."]}, ) diff --git a/tests/unit/apps/payment/test_update_reconciliation_data.py b/tests/unit/apps/payment/test_update_reconciliation_data.py index 96c90c8cda..803568c471 100644 --- a/tests/unit/apps/payment/test_update_reconciliation_data.py +++ b/tests/unit/apps/payment/test_update_reconciliation_data.py @@ -22,9 +22,7 @@ def file_without_delivery_dates() -> BytesIO: - content = Path( - f"{settings.TESTS_ROOT}/apps/payment/test_file/import_file_no_delivery_date.xlsx" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/payment/test_file/import_file_no_delivery_date.xlsx").read_bytes() file = BytesIO(content) return file diff --git a/tests/unit/apps/periodic_data_update/test_periodic_data_update_upload_views.py b/tests/unit/apps/periodic_data_update/test_periodic_data_update_upload_views.py index 9944edd76a..6315784760 100644 --- a/tests/unit/apps/periodic_data_update/test_periodic_data_update_upload_views.py +++ b/tests/unit/apps/periodic_data_update/test_periodic_data_update_upload_views.py @@ -31,11 +31,11 @@ from hct_mis_api.apps.periodic_data_update.service.periodic_data_update_export_template_service import ( PeriodicDataUpdateExportTemplateService, ) +from hct_mis_api.apps.periodic_data_update.utils import populate_pdu_with_null_values +from hct_mis_api.apps.program.fixtures import ProgramFactory from tests.unit.apps.periodic_data_update.test_periodic_data_update_import_service import ( add_pdu_data_to_xlsx, ) -from hct_mis_api.apps.periodic_data_update.utils import populate_pdu_with_null_values -from hct_mis_api.apps.program.fixtures import ProgramFactory pytestmark = pytest.mark.django_db diff --git a/tests/unit/apps/program/test_program_cycle_rest_api.py b/tests/unit/apps/program/test_program_cycle_rest_api.py index 2c093798aa..04a53e9109 100644 --- a/tests/unit/apps/program/test_program_cycle_rest_api.py +++ b/tests/unit/apps/program/test_program_cycle_rest_api.py @@ -11,7 +11,6 @@ from rest_framework.exceptions import ValidationError from rest_framework.test import APIClient, APIRequestFactory -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.account.fixtures import ( BusinessAreaFactory, PartnerFactory, @@ -30,6 +29,7 @@ from hct_mis_api.apps.program.models import Program, ProgramCycle from hct_mis_api.apps.targeting.fixtures import TargetPopulationFactory from hct_mis_api.apps.targeting.models import TargetPopulation +from tests.unit.api.base import HOPEApiTestCase class ProgramCycleAPITestCase(HOPEApiTestCase): diff --git a/tests/unit/apps/registration_data/services/test_mark_submissions.py b/tests/unit/apps/registration_data/services/test_mark_submissions.py index 58390d3206..1a6382e968 100644 --- a/tests/unit/apps/registration_data/services/test_mark_submissions.py +++ b/tests/unit/apps/registration_data/services/test_mark_submissions.py @@ -46,9 +46,7 @@ def _create_submission_with_merged_rdi(cls) -> None: @classmethod def _create_submission(cls, status: str) -> None: - content = Path( - f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/kobo_submissions.json" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/kobo_submissions.json").read_bytes() file = File(BytesIO(content), name="kobo_submissions.json") import_data = ImportData.objects.create( file=file, diff --git a/tests/unit/apps/registration_data/test_models.py b/tests/unit/apps/registration_data/test_models.py index 696822d28e..112c035e48 100644 --- a/tests/unit/apps/registration_data/test_models.py +++ b/tests/unit/apps/registration_data/test_models.py @@ -20,10 +20,7 @@ RegistrationDataImportDatahubFactory, RegistrationDataImportFactory, ) -from hct_mis_api.apps.registration_data.models import ( - DeduplicationEngineSimilarityPair, - RegistrationDataImport, -) +from hct_mis_api.apps.registration_data.models import RegistrationDataImport class TestRegistrationDataModels(TestCase): @@ -144,4 +141,3 @@ def test_linked_rdi(self) -> None: self.rdi_datahub.linked_rdi, self.rdi, ) - diff --git a/tests/unit/apps/registration_data/test_rest_api.py b/tests/unit/apps/registration_data/test_rest_api.py index 8a32e1e31a..806df4d619 100644 --- a/tests/unit/apps/registration_data/test_rest_api.py +++ b/tests/unit/apps/registration_data/test_rest_api.py @@ -6,13 +6,13 @@ from rest_framework import status from rest_framework.test import APIClient, APIRequestFactory -from tests.unit.api.base import HOPEApiTestCase from hct_mis_api.apps.account.fixtures import PartnerFactory, UserFactory from hct_mis_api.apps.account.models import Role, UserRole from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.registration_data.api.views import WebhookDeduplicationView +from tests.unit.api.base import HOPEApiTestCase class RegistrationDataImportViewSetTest(HOPEApiTestCase): diff --git a/tests/unit/apps/registration_datahub/test_biometric_deduplication_service.py b/tests/unit/apps/registration_datahub/test_biometric_deduplication_service.py index fd5691a46c..7840c47531 100644 --- a/tests/unit/apps/registration_datahub/test_biometric_deduplication_service.py +++ b/tests/unit/apps/registration_datahub/test_biometric_deduplication_service.py @@ -22,10 +22,10 @@ DeduplicationEngineAPI, DeduplicationImage, DeduplicationSet, - DeduplicationSetData, - SimilarityPair, DeduplicationSetConfig, + DeduplicationSetData, IgnoredFilenamesPair, + SimilarityPair, ) from hct_mis_api.apps.registration_datahub.services.biometric_deduplication import ( BiometricDeduplicationService, diff --git a/tests/unit/apps/registration_datahub/test_deduplication_engine_api.py b/tests/unit/apps/registration_datahub/test_deduplication_engine_api.py index a3b2ce5bd4..2227780518 100644 --- a/tests/unit/apps/registration_datahub/test_deduplication_engine_api.py +++ b/tests/unit/apps/registration_datahub/test_deduplication_engine_api.py @@ -30,9 +30,7 @@ def mock_deduplication_engine_env_vars() -> None: class DeduplicationEngineApiTest(TestCase): - @patch( - "hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._delete" - ) + @patch("hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._delete") def test_delete_deduplication_set(self, mock_delete: mock.Mock) -> None: api = DeduplicationEngineAPI() @@ -41,13 +39,9 @@ def test_delete_deduplication_set(self, mock_delete: mock.Mock) -> None: api.delete_deduplication_set(deduplication_set_id) - mock_delete.assert_called_once_with( - f"deduplication_sets/{deduplication_set_id}/" - ) + mock_delete.assert_called_once_with(f"deduplication_sets/{deduplication_set_id}/") - @patch( - "hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._post" - ) + @patch("hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._post") def test_create_deduplication_set(self, mock_post: mock.Mock) -> None: api = DeduplicationEngineAPI() @@ -60,13 +54,9 @@ def test_create_deduplication_set(self, mock_post: mock.Mock) -> None: api.create_deduplication_set(deduplication_set) print(dataclasses.asdict(deduplication_set)) - mock_post.assert_called_once_with( - "deduplication_sets/", dataclasses.asdict(deduplication_set) - ) + mock_post.assert_called_once_with("deduplication_sets/", dataclasses.asdict(deduplication_set)) - @patch( - "hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._get" - ) + @patch("hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._get") def test_get_deduplication_set(self, get_mock: mock.Mock) -> None: api = DeduplicationEngineAPI() deduplication_set_id = str(uuid.uuid4()) @@ -76,9 +66,7 @@ def test_get_deduplication_set(self, get_mock: mock.Mock) -> None: get_mock.assert_called_once_with(f"deduplication_sets/{deduplication_set_id}/") - @patch( - "hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._post" - ) + @patch("hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._post") def test_bulk_upload_images(self, mock_post: mock.Mock) -> None: api = DeduplicationEngineAPI() deduplication_set_id = str(uuid.uuid4()) @@ -98,9 +86,7 @@ def test_bulk_upload_images(self, mock_post: mock.Mock) -> None: [dataclasses.asdict(image) for image in images], ) - @patch( - "hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._delete" - ) + @patch("hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._delete") def test_bulk_delete_images(self, mock_delete: mock.Mock) -> None: api = DeduplicationEngineAPI() deduplication_set_id = str(uuid.uuid4()) @@ -108,13 +94,9 @@ def test_bulk_delete_images(self, mock_delete: mock.Mock) -> None: api.bulk_delete_images(deduplication_set_id) - mock_delete.assert_called_once_with( - f"deduplication_sets/{deduplication_set_id}/images_bulk/" - ) + mock_delete.assert_called_once_with(f"deduplication_sets/{deduplication_set_id}/images_bulk/") - @patch( - "hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._get" - ) + @patch("hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._get") def test_get_duplicates(self, get_mock: mock.Mock) -> None: api = DeduplicationEngineAPI() deduplication_set_id = str(uuid.uuid4()) @@ -122,13 +104,9 @@ def test_get_duplicates(self, get_mock: mock.Mock) -> None: api.get_duplicates(deduplication_set_id) - get_mock.assert_called_once_with( - f"deduplication_sets/{deduplication_set_id}/duplicates/" - ) + get_mock.assert_called_once_with(f"deduplication_sets/{deduplication_set_id}/duplicates/") - @patch( - "hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._post" - ) + @patch("hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._post") def test_process_deduplication(self, post_mock: mock.Mock) -> None: api = DeduplicationEngineAPI() deduplication_set_id = str(uuid.uuid4()) @@ -141,9 +119,7 @@ def test_process_deduplication(self, post_mock: mock.Mock) -> None: validate_response=False, ) - @patch( - "hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._post" - ) + @patch("hct_mis_api.apps.registration_datahub.apis.deduplication_engine.DeduplicationEngineAPI._post") def test_report_false_positive_duplicate(self, post_mock: mock.Mock) -> None: api = DeduplicationEngineAPI() deduplication_set_id = str(uuid.uuid4()) diff --git a/tests/unit/apps/registration_datahub/test_kobo_validators_methods.py b/tests/unit/apps/registration_datahub/test_kobo_validators_methods.py index b81a50b577..f8132715a9 100644 --- a/tests/unit/apps/registration_datahub/test_kobo_validators_methods.py +++ b/tests/unit/apps/registration_datahub/test_kobo_validators_methods.py @@ -762,7 +762,7 @@ def test_validate_everything(self) -> None: {"header": "role_i_c", "message": "Only one person can be a primary collector"}, { "header": "role_i_c", - "message": "The same individual cannot be a primary and alternate collector for the same household." + "message": "The same individual cannot be a primary and alternate collector for the same household.", }, ] self.assertEqual(result, expected) diff --git a/tests/unit/apps/registration_datahub/test_rdi_kobo_create.py b/tests/unit/apps/registration_datahub/test_rdi_kobo_create.py index 30844c4078..58d6fd5966 100644 --- a/tests/unit/apps/registration_datahub/test_rdi_kobo_create.py +++ b/tests/unit/apps/registration_datahub/test_rdi_kobo_create.py @@ -42,9 +42,7 @@ class TestRdiKoboCreateTask(TestCase): @staticmethod def _return_test_image(*args: Any, **kwargs: Any) -> BytesIO: - return BytesIO( - Path(f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/image.png").read_bytes() - ) + return BytesIO(Path(f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/image.png").read_bytes()) @classmethod def setUpTestData(cls) -> None: @@ -62,9 +60,7 @@ def setUpTestData(cls) -> None: document_types.append(DocumentType(label=label, key=IDENTIFICATION_TYPE_TO_KEY_MAPPING[doc_type])) DocumentType.objects.bulk_create(document_types, ignore_conflicts=True) - content = Path( - f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/kobo_submissions.json" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/kobo_submissions.json").read_bytes() file = File(BytesIO(content), name="kobo_submissions.json") cls.import_data = ImportData.objects.create( file=file, diff --git a/tests/unit/apps/registration_datahub/test_rdi_people_create.py b/tests/unit/apps/registration_datahub/test_rdi_people_create.py index 5894aa706a..a35e00684d 100644 --- a/tests/unit/apps/registration_datahub/test_rdi_people_create.py +++ b/tests/unit/apps/registration_datahub/test_rdi_people_create.py @@ -43,9 +43,7 @@ class TestRdiXlsxPeople(TestCase): def setUpTestData(cls) -> None: super().setUpTestData() PartnerFactory(name="UNHCR") - content = Path( - f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/rdi_people_test.xlsx" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/rdi_people_test.xlsx").read_bytes() file = File(BytesIO(content), name="rdi_people_test.xlsx") cls.business_area = create_afghanistan() diff --git a/tests/unit/apps/registration_datahub/test_registration_data_import_datahub_mutations.py b/tests/unit/apps/registration_datahub/test_registration_data_import_datahub_mutations.py index 409ea82881..215379152b 100644 --- a/tests/unit/apps/registration_datahub/test_registration_data_import_datahub_mutations.py +++ b/tests/unit/apps/registration_datahub/test_registration_data_import_datahub_mutations.py @@ -142,9 +142,7 @@ def setUpTestData(cls) -> None: charset=None, ) - xlsx_valid_file_path = ( - f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/new_reg_data_import.xlsx" - ) + xlsx_valid_file_path = f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/new_reg_data_import.xlsx" xlsx_invalid_file_path = f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/rdi_import_3_hh_missing_required_delivery_fields.xlsx" diff --git a/tests/unit/apps/registration_datahub/test_validate_xlsx_import_task.py b/tests/unit/apps/registration_datahub/test_validate_xlsx_import_task.py index 33b933419f..06477d3ad2 100644 --- a/tests/unit/apps/registration_datahub/test_validate_xlsx_import_task.py +++ b/tests/unit/apps/registration_datahub/test_validate_xlsx_import_task.py @@ -37,9 +37,7 @@ def setUpTestData(cls) -> None: "hct_mis_api.apps.registration_datahub.tasks.validate_xlsx_import.UploadXLSXInstanceValidator.validate_everything" ) def test_people(self, validate_everything_mock: Mock) -> None: - content = Path( - f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/rdi_people_test.xlsx" - ).read_bytes() + content = Path(f"{settings.TESTS_ROOT}/apps/registration_datahub/test_file/rdi_people_test.xlsx").read_bytes() file = File(BytesIO(content), name="rdi_people_test.xlsx") import_data = ImportData.objects.create( file=file, diff --git a/tests/unit/apps/targeting/test_admin.py b/tests/unit/apps/targeting/test_admin.py index c50ec08a26..468a1ced01 100644 --- a/tests/unit/apps/targeting/test_admin.py +++ b/tests/unit/apps/targeting/test_admin.py @@ -1,5 +1,5 @@ -from tests.unit.apps.household.test_admin import BaseTest from hct_mis_api.apps.targeting.fixtures import TargetPopulationFactory +from tests.unit.apps.household.test_admin import BaseTest # temporary added test for AutoCompleteFilterTemp have to be removed after fix in AutoCompleteFilter diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index c0fb59b405..6de7143d3f 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -1,4 +1,3 @@ -from .fixtures import * # noqa: ABS101, F403, F401 import logging import os import re @@ -14,6 +13,8 @@ from django_elasticsearch_dsl.test import is_es_online from elasticsearch_dsl import connections +from .fixtures import * # noqa: ABS101, F403, F401 + def pytest_addoption(parser: Parser) -> None: parser.addoption( @@ -52,7 +53,7 @@ def pytest_configure(config: Config) -> None: settings.SECURE_REFERRER_POLICY = "same-origin" settings.CACHE_ENABLED = False - settings.TESTS_ROOT = "/tests/unit" + settings.TESTS_ROOT = "/code/tests/unit" settings.CACHES = { "default": { "BACKEND": "hct_mis_api.apps.core.memcache.LocMemCache",