diff --git a/backend/hct_mis_api/apps/account/authentication.py b/backend/hct_mis_api/apps/account/authentication.py index eb0ab71d1d..7e4210dacf 100644 --- a/backend/hct_mis_api/apps/account/authentication.py +++ b/backend/hct_mis_api/apps/account/authentication.py @@ -1,12 +1,13 @@ import logging from django.contrib.auth import get_user_model + from social_core.exceptions import InvalidEmail from social_core.pipeline import social_auth from social_core.pipeline import user as social_core_user from hct_mis_api.apps.account.microsoft_graph import MicrosoftGraphAPI -from hct_mis_api.apps.account.models import UserRole, Role, ACTIVE +from hct_mis_api.apps.account.models import ACTIVE, Role, UserRole from hct_mis_api.apps.core.models import BusinessArea logger = logging.getLogger(__name__) diff --git a/backend/hct_mis_api/apps/account/tests/test_user_roles.py b/backend/hct_mis_api/apps/account/tests/test_user_roles.py index 0fb1e75dc2..9197e4e6c9 100644 --- a/backend/hct_mis_api/apps/account/tests/test_user_roles.py +++ b/backend/hct_mis_api/apps/account/tests/test_user_roles.py @@ -4,7 +4,7 @@ from hct_mis_api.apps.account.admin import UserRoleAdminForm, UserRoleInlineFormSet from hct_mis_api.apps.account.fixtures import UserFactory -from hct_mis_api.apps.account.models import IncompatibleRoles, Role, UserRole, User +from hct_mis_api.apps.account.models import IncompatibleRoles, Role, User, UserRole from hct_mis_api.apps.core.models import BusinessArea diff --git a/backend/hct_mis_api/apps/account/views.py b/backend/hct_mis_api/apps/account/views.py index 119880f044..f9155bf404 100644 --- a/backend/hct_mis_api/apps/account/views.py +++ b/backend/hct_mis_api/apps/account/views.py @@ -1,6 +1,7 @@ from datetime import datetime from django.http import HttpResponse + from openpyxl.writer.excel import save_virtual_workbook from hct_mis_api.apps.account.export_users_xlsx import ExportUsersXlsx diff --git a/backend/hct_mis_api/apps/activity_log/schema.py b/backend/hct_mis_api/apps/activity_log/schema.py index a8a8ec7692..a4452afa0a 100644 --- a/backend/hct_mis_api/apps/activity_log/schema.py +++ b/backend/hct_mis_api/apps/activity_log/schema.py @@ -1,11 +1,16 @@ -import graphene from django.contrib.contenttypes.models import ContentType from django.db.models import Q -from django_filters import FilterSet, CharFilter + +import graphene +from django_filters import CharFilter, FilterSet from graphene import relay from graphene_django import DjangoObjectType -from hct_mis_api.apps.account.permissions import DjangoPermissionFilterConnectionField, hopePermissionClass, Permissions +from hct_mis_api.apps.account.permissions import ( + DjangoPermissionFilterConnectionField, + Permissions, + hopePermissionClass, +) from hct_mis_api.apps.activity_log.models import LogEntry from hct_mis_api.apps.core.extended_connection import ExtendedConnection from hct_mis_api.apps.core.schema import ChoiceObject diff --git a/backend/hct_mis_api/apps/cash_assist_datahub/celery_tasks.py b/backend/hct_mis_api/apps/cash_assist_datahub/celery_tasks.py index 5ee6723385..46dca95085 100644 --- a/backend/hct_mis_api/apps/cash_assist_datahub/celery_tasks.py +++ b/backend/hct_mis_api/apps/cash_assist_datahub/celery_tasks.py @@ -1,8 +1,7 @@ import logging -from hct_mis_api.apps.core.exchange_rates.utils import fix_exchange_rates - from hct_mis_api.apps.core.celery import app +from hct_mis_api.apps.core.exchange_rates.utils import fix_exchange_rates logger = logging.getLogger(__name__) @@ -12,7 +11,9 @@ def pull_from_cashassist_datahub_task(): logger.info("pull_from_cashassist_datahub_task start") try: - from hct_mis_api.apps.cash_assist_datahub.tasks.pull_from_datahub import PullFromDatahubTask + from hct_mis_api.apps.cash_assist_datahub.tasks.pull_from_datahub import ( + PullFromDatahubTask, + ) PullFromDatahubTask().execute() except Exception as e: diff --git a/backend/hct_mis_api/apps/cash_assist_datahub/fixtures.py b/backend/hct_mis_api/apps/cash_assist_datahub/fixtures.py index 6ffe96bd0e..e9792c160a 100644 --- a/backend/hct_mis_api/apps/cash_assist_datahub/fixtures.py +++ b/backend/hct_mis_api/apps/cash_assist_datahub/fixtures.py @@ -6,10 +6,10 @@ from pytz import utc from hct_mis_api.apps.cash_assist_datahub.models import ( - PaymentRecord, - ServiceProvider, CashPlan, + PaymentRecord, Programme, + ServiceProvider, ) from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.household.models import Household diff --git a/backend/hct_mis_api/apps/cash_assist_datahub/tests/test_pull_from_datahub.py b/backend/hct_mis_api/apps/cash_assist_datahub/tests/test_pull_from_datahub.py index ad1dde7ce2..08802ff72d 100644 --- a/backend/hct_mis_api/apps/cash_assist_datahub/tests/test_pull_from_datahub.py +++ b/backend/hct_mis_api/apps/cash_assist_datahub/tests/test_pull_from_datahub.py @@ -36,7 +36,7 @@ @mock.patch.dict(os.environ, {"EXCHANGE_RATES_API_KEY": "TEST_API_KEY"}) class TestPullDataFromDatahub(TestCase): - multi_db = True + databases = "__all__" program = None target_population = None dh_cash_plan1 = None @@ -276,7 +276,7 @@ def test_pull_data(self, mocker): class TestSessionsPullDataFromDatahub(TestCase): - multi_db = True + databases = "__all__" @classmethod def setUpTestData(cls): diff --git a/backend/hct_mis_api/apps/core/celery_tasks.py b/backend/hct_mis_api/apps/core/celery_tasks.py index 0fc96cc246..e669ee7df5 100644 --- a/backend/hct_mis_api/apps/core/celery_tasks.py +++ b/backend/hct_mis_api/apps/core/celery_tasks.py @@ -2,7 +2,9 @@ from hct_mis_api.apps.core.celery import app from hct_mis_api.apps.core.models import XLSXKoboTemplate -from hct_mis_api.apps.core.tasks.upload_new_template_and_update_flex_fields import KoboRetriableError +from hct_mis_api.apps.core.tasks.upload_new_template_and_update_flex_fields import ( + KoboRetriableError, +) logger = logging.getLogger(__name__) diff --git a/backend/hct_mis_api/apps/core/converters.py b/backend/hct_mis_api/apps/core/converters.py index cc0d02f819..67c55a7a39 100644 --- a/backend/hct_mis_api/apps/core/converters.py +++ b/backend/hct_mis_api/apps/core/converters.py @@ -1,9 +1,10 @@ import json -import graphene -from concurrency.fields import IntegerVersionField from django.contrib.gis.db.models import GeometryField from django.forms import MultipleChoiceField + +import graphene +from concurrency.fields import IntegerVersionField from graphene_django.converter import convert_django_field from graphene_django.forms.converter import convert_form_field diff --git a/backend/hct_mis_api/apps/core/filters.py b/backend/hct_mis_api/apps/core/filters.py index e26729e7ed..f0c65c20c3 100644 --- a/backend/hct_mis_api/apps/core/filters.py +++ b/backend/hct_mis_api/apps/core/filters.py @@ -1,8 +1,9 @@ import json -from datetime import datetime, date, timedelta +from datetime import date, datetime, timedelta + +from django.forms import DateField, DateTimeField, DecimalField, Field, IntegerField from dateutil.parser import parse -from django.forms import IntegerField, DecimalField, Field, DateTimeField, DateField from django_filters import Filter diff --git a/backend/hct_mis_api/apps/core/management/commands/generatedocumenttypes.py b/backend/hct_mis_api/apps/core/management/commands/generatedocumenttypes.py index ce827b5797..fd96a669ff 100644 --- a/backend/hct_mis_api/apps/core/management/commands/generatedocumenttypes.py +++ b/backend/hct_mis_api/apps/core/management/commands/generatedocumenttypes.py @@ -1,10 +1,17 @@ from django.core.management import BaseCommand from django.db import transaction + from django_countries import countries -from hct_mis_api.apps.household.models import IDENTIFICATION_TYPE_CHOICE, Agency, DocumentType +from hct_mis_api.apps.household.models import ( + IDENTIFICATION_TYPE_CHOICE, + Agency, + DocumentType, +) from hct_mis_api.apps.registration_datahub.models import ImportedAgency -from hct_mis_api.apps.registration_datahub.models import ImportedDocumentType as RDHDocumentType +from hct_mis_api.apps.registration_datahub.models import ( + ImportedDocumentType as RDHDocumentType, +) class Command(BaseCommand): diff --git a/backend/hct_mis_api/apps/core/management/commands/generatefakefile.py b/backend/hct_mis_api/apps/core/management/commands/generatefakefile.py index 31ff50b298..6121ae5574 100644 --- a/backend/hct_mis_api/apps/core/management/commands/generatefakefile.py +++ b/backend/hct_mis_api/apps/core/management/commands/generatefakefile.py @@ -1,9 +1,10 @@ import datetime import random -from dateutil.relativedelta import relativedelta from django.conf import settings from django.core.management import BaseCommand + +from dateutil.relativedelta import relativedelta from faker import Faker from openpyxl.drawing.image import Image @@ -18,7 +19,9 @@ ) from hct_mis_api.apps.core.utils import get_combined_attributes from hct_mis_api.apps.household.models import HEAD -from hct_mis_api.apps.registration_datahub.template_generator import TemplateFileGenerator +from hct_mis_api.apps.registration_datahub.template_generator import ( + TemplateFileGenerator, +) class Command(BaseCommand): diff --git a/backend/hct_mis_api/apps/core/management/commands/init.py b/backend/hct_mis_api/apps/core/management/commands/init.py index ea26accc61..7bce5a0eeb 100644 --- a/backend/hct_mis_api/apps/core/management/commands/init.py +++ b/backend/hct_mis_api/apps/core/management/commands/init.py @@ -1,4 +1,4 @@ -from django.core.management import call_command, BaseCommand +from django.core.management import BaseCommand, call_command class Command(BaseCommand): diff --git a/backend/hct_mis_api/apps/core/management/commands/pullfromcadatahub.py b/backend/hct_mis_api/apps/core/management/commands/pullfromcadatahub.py index 32ebba3f41..f84fb0543d 100644 --- a/backend/hct_mis_api/apps/core/management/commands/pullfromcadatahub.py +++ b/backend/hct_mis_api/apps/core/management/commands/pullfromcadatahub.py @@ -1,6 +1,8 @@ from django.core.management.commands import makemigrations -from hct_mis_api.apps.cash_assist_datahub.tasks.pull_from_datahub import PullFromDatahubTask +from hct_mis_api.apps.cash_assist_datahub.tasks.pull_from_datahub import ( + PullFromDatahubTask, +) class Command(makemigrations.Command): diff --git a/backend/hct_mis_api/apps/core/management/commands/pullfromerpdatahub.py b/backend/hct_mis_api/apps/core/management/commands/pullfromerpdatahub.py index 6dc1498374..8039bb01f6 100644 --- a/backend/hct_mis_api/apps/core/management/commands/pullfromerpdatahub.py +++ b/backend/hct_mis_api/apps/core/management/commands/pullfromerpdatahub.py @@ -1,6 +1,8 @@ from django.core.management.commands import makemigrations -from hct_mis_api.apps.erp_datahub.tasks.pull_from_erp_datahub import PullFromErpDatahubTask +from hct_mis_api.apps.erp_datahub.tasks.pull_from_erp_datahub import ( + PullFromErpDatahubTask, +) class Command(makemigrations.Command): diff --git a/backend/hct_mis_api/apps/core/storage.py b/backend/hct_mis_api/apps/core/storage.py index 59f43412f6..e8e74db9ec 100644 --- a/backend/hct_mis_api/apps/core/storage.py +++ b/backend/hct_mis_api/apps/core/storage.py @@ -1,4 +1,5 @@ from django.conf import settings + from storages.backends.azure_storage import AzureStorage diff --git a/backend/hct_mis_api/apps/core/tests/test_exchange_rates.py b/backend/hct_mis_api/apps/core/tests/test_exchange_rates.py index 78ffad0d6d..5ccb70f1d8 100644 --- a/backend/hct_mis_api/apps/core/tests/test_exchange_rates.py +++ b/backend/hct_mis_api/apps/core/tests/test_exchange_rates.py @@ -1,26 +1,27 @@ import os +from datetime import datetime, timedelta from decimal import Decimal from unittest import mock -import requests_mock -from datetime import datetime, timedelta - from django.core.management import call_command -from parameterized import parameterized from django.test import TestCase +import requests_mock +from parameterized import parameterized + from hct_mis_api.apps.core.exchange_rates import ExchangeRateAPI, ExchangeRates from hct_mis_api.apps.core.models import BusinessArea +from hct_mis_api.apps.core.tests.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 ( - ServiceProviderFactory, - RealProgramFactory, RealCashPlanFactory, RealPaymentRecordFactory, + RealProgramFactory, + ServiceProviderFactory, ) from hct_mis_api.apps.payment.models import PaymentRecord -from hct_mis_api.apps.core.tests.test_files.exchange_rates_api_response import EXCHANGE_RATES_API_RESPONSE - EXCHANGE_RATES_WITH_HISTORICAL_DATA = { "ROWSET": { diff --git a/backend/hct_mis_api/apps/core/tests/test_flexible_helper_methods.py b/backend/hct_mis_api/apps/core/tests/test_flexible_helper_methods.py index 51aca5dae8..23fc2c79e0 100644 --- a/backend/hct_mis_api/apps/core/tests/test_flexible_helper_methods.py +++ b/backend/hct_mis_api/apps/core/tests/test_flexible_helper_methods.py @@ -1,7 +1,8 @@ -import xlrd from django.conf import settings from django.core.exceptions import ValidationError from django.test import TestCase + +import xlrd from xlrd.sheet import Cell from hct_mis_api.apps.core.flex_fields_importer import FlexibleAttributeImporter diff --git a/backend/hct_mis_api/apps/core/tests/test_flexibles.py b/backend/hct_mis_api/apps/core/tests/test_flexibles.py index f3ca2d2fca..496d599faa 100644 --- a/backend/hct_mis_api/apps/core/tests/test_flexibles.py +++ b/backend/hct_mis_api/apps/core/tests/test_flexibles.py @@ -1,10 +1,15 @@ from django.conf import settings from django.core.exceptions import ValidationError from django.test import TestCase + from xlrd import XLRDError from hct_mis_api.apps.core.flex_fields_importer import FlexibleAttributeImporter -from hct_mis_api.apps.core.models import FlexibleAttribute, FlexibleAttributeChoice, FlexibleAttributeGroup +from hct_mis_api.apps.core.models import ( + FlexibleAttribute, + FlexibleAttributeChoice, + FlexibleAttributeGroup, +) class MockSuperUser: diff --git a/backend/hct_mis_api/apps/core/tests/test_kobo_template_upload.py b/backend/hct_mis_api/apps/core/tests/test_kobo_template_upload.py index be2f708cbf..61926834f2 100644 --- a/backend/hct_mis_api/apps/core/tests/test_kobo_template_upload.py +++ b/backend/hct_mis_api/apps/core/tests/test_kobo_template_upload.py @@ -123,7 +123,7 @@ def test_upload_valid_template(self): class TestKoboErrorHandling(APITestCase): def generate_empty_template(self): with NamedTemporaryFile(mode="w+b") as tmp_file: - tmp_file.write("abcdefg".encode()) + tmp_file.write(b"abcdefg") tmp_file.seek(0) template = XLSXKoboTemplate(file_name="test.xlsx", status=XLSXKoboTemplate.UPLOADED) template.file.save("test.xlsx", tmp_file) diff --git a/backend/hct_mis_api/apps/core/tests/test_setting_types_for_calculate_fields.py b/backend/hct_mis_api/apps/core/tests/test_setting_types_for_calculate_fields.py index 959b70c2b4..1d0f7c78b6 100644 --- a/backend/hct_mis_api/apps/core/tests/test_setting_types_for_calculate_fields.py +++ b/backend/hct_mis_api/apps/core/tests/test_setting_types_for_calculate_fields.py @@ -1,9 +1,15 @@ from django.conf import settings from django.core.exceptions import ValidationError from django.test import TestCase + from parameterized import parameterized -from hct_mis_api.apps.core.core_fields_attributes import TYPE_STRING, TYPE_INTEGER, TYPE_DECIMAL, TYPE_DATE +from hct_mis_api.apps.core.core_fields_attributes import ( + TYPE_DATE, + TYPE_DECIMAL, + TYPE_INTEGER, + TYPE_STRING, +) from hct_mis_api.apps.core.flex_fields_importer import FlexibleAttributeImporter from hct_mis_api.apps.core.models import FlexibleAttribute diff --git a/backend/hct_mis_api/apps/core/views.py b/backend/hct_mis_api/apps/core/views.py index e1e4f789c7..e8edf8dd3d 100644 --- a/backend/hct_mis_api/apps/core/views.py +++ b/backend/hct_mis_api/apps/core/views.py @@ -2,11 +2,12 @@ from django import forms from django.contrib.auth import logout -from django.contrib.auth.decorators import user_passes_test, login_required +from django.contrib.auth.decorators import login_required, user_passes_test from django.core.exceptions import PermissionDenied from django.core.management import call_command from django.http import HttpResponse -from django.shortcuts import redirect, render, get_object_or_404 +from django.shortcuts import get_object_or_404, redirect, render + from graphene_django.settings import graphene_settings from graphql.utils import schema_printer diff --git a/backend/hct_mis_api/apps/erp_datahub/celery_tasks.py b/backend/hct_mis_api/apps/erp_datahub/celery_tasks.py index 53dcb71178..03b2f27f49 100644 --- a/backend/hct_mis_api/apps/erp_datahub/celery_tasks.py +++ b/backend/hct_mis_api/apps/erp_datahub/celery_tasks.py @@ -10,7 +10,9 @@ def sync_to_mis_datahub_task(): logger.info("sync_to_mis_datahub_task start") try: - from hct_mis_api.apps.erp_datahub.tasks.sync_to_mis_datahub import SyncToMisDatahubTask + from hct_mis_api.apps.erp_datahub.tasks.sync_to_mis_datahub import ( + SyncToMisDatahubTask, + ) SyncToMisDatahubTask().execute() except Exception as e: diff --git a/backend/hct_mis_api/apps/erp_datahub/fixtures.py b/backend/hct_mis_api/apps/erp_datahub/fixtures.py index 630ce1c6b2..dede1557b7 100644 --- a/backend/hct_mis_api/apps/erp_datahub/fixtures.py +++ b/backend/hct_mis_api/apps/erp_datahub/fixtures.py @@ -1,10 +1,10 @@ import factory +from factory import fuzzy from pytz import utc -from factory import fuzzy from hct_mis_api.apps.core.models import BusinessArea -from hct_mis_api.apps.program.models import CashPlan from hct_mis_api.apps.erp_datahub.models import FundsCommitment +from hct_mis_api.apps.program.models import CashPlan class FundsCommitmentFactory(factory.DjangoModelFactory): diff --git a/backend/hct_mis_api/apps/erp_datahub/tests/test_pull_from_erp_datahub.py b/backend/hct_mis_api/apps/erp_datahub/tests/test_pull_from_erp_datahub.py index 6d01f9dc36..d40150a9d1 100644 --- a/backend/hct_mis_api/apps/erp_datahub/tests/test_pull_from_erp_datahub.py +++ b/backend/hct_mis_api/apps/erp_datahub/tests/test_pull_from_erp_datahub.py @@ -3,15 +3,17 @@ from django.core.management import call_command from django.test import TestCase -from hct_mis_api.apps.erp_datahub.tasks.pull_from_erp_datahub import PullFromErpDatahubTask -from hct_mis_api.apps.program.fixtures import CashPlanFactory -from hct_mis_api.apps.payment.fixtures import PaymentRecordFactory from hct_mis_api.apps.erp_datahub.fixtures import FundsCommitmentFactory +from hct_mis_api.apps.erp_datahub.tasks.pull_from_erp_datahub import ( + PullFromErpDatahubTask, +) from hct_mis_api.apps.household.fixtures import create_household +from hct_mis_api.apps.payment.fixtures import PaymentRecordFactory +from hct_mis_api.apps.program.fixtures import CashPlanFactory class TestPullDataFromErpDatahub(TestCase): - multi_db = True + databases = "__all__" cash_plan_1 = None cash_plan_2 = None payment_record_1 = None diff --git a/backend/hct_mis_api/apps/erp_datahub/tests/test_sync_to_mis_datahub.py b/backend/hct_mis_api/apps/erp_datahub/tests/test_sync_to_mis_datahub.py index 7fd98ba18c..1be21e7980 100644 --- a/backend/hct_mis_api/apps/erp_datahub/tests/test_sync_to_mis_datahub.py +++ b/backend/hct_mis_api/apps/erp_datahub/tests/test_sync_to_mis_datahub.py @@ -11,7 +11,7 @@ class TestSyncToMisDatahubTask(TestCase): - multi_db = True + databases = "__all__" bosnia_and_herzegovina = None bosnia = None herzegovina = None diff --git a/backend/hct_mis_api/apps/geo/utils.py b/backend/hct_mis_api/apps/geo/utils.py index 59df098142..9624400908 100644 --- a/backend/hct_mis_api/apps/geo/utils.py +++ b/backend/hct_mis_api/apps/geo/utils.py @@ -104,11 +104,11 @@ def initialise_countries(): def copy_admin_area_data(): areas = {} from django.db import models + from hct_mis_api.apps.grievance.models import GrievanceTicket from hct_mis_api.apps.household.models import Household from hct_mis_api.apps.program.models import Program - from hct_mis_api.apps.reporting.models import DashboardReport - from hct_mis_api.apps.reporting.models import Report + from hct_mis_api.apps.reporting.models import DashboardReport, Report models_to_update = ( GrievanceTicket, @@ -140,14 +140,15 @@ def copy_admin_area_data(): def copy_country_data(): from django.db import models - from hct_mis_api.apps.sanction_list.models import SanctionListIndividual - from hct_mis_api.apps.sanction_list.models import SanctionListIndividualDocument - from hct_mis_api.apps.sanction_list.models import SanctionListIndividualNationalities - from hct_mis_api.apps.sanction_list.models import SanctionListIndividualCountries - from hct_mis_api.apps.household.models import Agency - from hct_mis_api.apps.household.models import DocumentType - from hct_mis_api.apps.household.models import Household + from hct_mis_api.apps.core.models import CountryCodeMap + from hct_mis_api.apps.household.models import Agency, DocumentType, Household + from hct_mis_api.apps.sanction_list.models import ( + SanctionListIndividual, + SanctionListIndividualCountries, + SanctionListIndividualDocument, + SanctionListIndividualNationalities, + ) models_to_update = ( CountryCodeMap, diff --git a/backend/hct_mis_api/apps/grievance/notifications.py b/backend/hct_mis_api/apps/grievance/notifications.py index 78034192d3..8dd88f1bcb 100644 --- a/backend/hct_mis_api/apps/grievance/notifications.py +++ b/backend/hct_mis_api/apps/grievance/notifications.py @@ -5,6 +5,7 @@ from django.conf import settings from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string + from constance import config from hct_mis_api.apps.account.models import User, UserRole diff --git a/backend/hct_mis_api/apps/grievance/tasks/deduplicate_and_check_sanctions.py b/backend/hct_mis_api/apps/grievance/tasks/deduplicate_and_check_sanctions.py index 4c57be07c9..8550edf198 100644 --- a/backend/hct_mis_api/apps/grievance/tasks/deduplicate_and_check_sanctions.py +++ b/backend/hct_mis_api/apps/grievance/tasks/deduplicate_and_check_sanctions.py @@ -3,7 +3,12 @@ from hct_mis_api.apps.grievance.common import create_needs_adjudication_tickets from hct_mis_api.apps.household.documents import IndividualDocument from hct_mis_api.apps.household.elasticsearch_utils import populate_index -from hct_mis_api.apps.household.models import Individual, DUPLICATE, NEEDS_ADJUDICATION, Document +from hct_mis_api.apps.household.models import ( + DUPLICATE, + NEEDS_ADJUDICATION, + Document, + Individual, +) from hct_mis_api.apps.registration_data.models import RegistrationDataImport from hct_mis_api.apps.registration_datahub.tasks.deduplicate import DeduplicateTask from hct_mis_api.apps.sanction_list.tasks.check_against_sanction_list_pre_merge import ( diff --git a/backend/hct_mis_api/apps/grievance/tests/mutations_extras/test_reassign_roles_on_disable_individual.py b/backend/hct_mis_api/apps/grievance/tests/mutations_extras/test_reassign_roles_on_disable_individual.py index 6a53005f76..f76ca183d0 100644 --- a/backend/hct_mis_api/apps/grievance/tests/mutations_extras/test_reassign_roles_on_disable_individual.py +++ b/backend/hct_mis_api/apps/grievance/tests/mutations_extras/test_reassign_roles_on_disable_individual.py @@ -1,4 +1,5 @@ from django.core.management import call_command + from graphql import GraphQLError from hct_mis_api.apps.core.base_test_case import APITestCase diff --git a/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_filter_already_existing_tickets.py b/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_filter_already_existing_tickets.py index a007190428..1f2dc35bc1 100644 --- a/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_filter_already_existing_tickets.py +++ b/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_filter_already_existing_tickets.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestAlreadyExistingFilterTickets::test_filter_existing_tickets_by_household_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_grievance_create_complaint_ticket.py b/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_grievance_create_complaint_ticket.py index a74374808c..18810d3037 100644 --- a/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_grievance_create_complaint_ticket.py +++ b/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_grievance_create_complaint_ticket.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestGrievanceCreateComplaintTicketQuery::test_create_complaint_ticket_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_grievance_create_sensitive_ticket.py b/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_grievance_create_sensitive_ticket.py index 4629e57600..19b0e76ed9 100644 --- a/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_grievance_create_sensitive_ticket.py +++ b/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_grievance_create_sensitive_ticket.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestGrievanceCreateSensitiveTicketQuery::test_create_sensitive_ticket_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_ticket_notes.py b/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_ticket_notes.py index 1d17fcfa93..ab234c4dd0 100644 --- a/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_ticket_notes.py +++ b/backend/hct_mis_api/apps/grievance/tests/snapshots/snap_test_ticket_notes.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestTicketNotes::test_ticket_notes_query_all 1'] = { diff --git a/backend/hct_mis_api/apps/grievance/tests/test_filter_already_existing_tickets.py b/backend/hct_mis_api/apps/grievance/tests/test_filter_already_existing_tickets.py index 11a4e50733..734bb5c510 100644 --- a/backend/hct_mis_api/apps/grievance/tests/test_filter_already_existing_tickets.py +++ b/backend/hct_mis_api/apps/grievance/tests/test_filter_already_existing_tickets.py @@ -1,21 +1,22 @@ from django.core.management import call_command + from parameterized import parameterized -from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.account.fixtures import UserFactory +from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase -from hct_mis_api.apps.core.fixtures import AdminAreaLevelFactory, AdminAreaFactory +from hct_mis_api.apps.core.fixtures import AdminAreaFactory, AdminAreaLevelFactory from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.grievance.fixtures import ( - GrievanceTicketFactory, GrievanceComplaintTicketFactory, - SensitiveGrievanceTicketWithoutExtrasFactory, + GrievanceTicketFactory, SensitiveGrievanceTicketFactory, + SensitiveGrievanceTicketWithoutExtrasFactory, ) from hct_mis_api.apps.grievance.models import GrievanceTicket from hct_mis_api.apps.household.fixtures import create_household from hct_mis_api.apps.payment.fixtures import PaymentRecordFactory -from hct_mis_api.apps.program.fixtures import ProgramFactory, CashPlanFactory +from hct_mis_api.apps.program.fixtures import CashPlanFactory, ProgramFactory class TestAlreadyExistingFilterTickets(APITestCase): diff --git a/backend/hct_mis_api/apps/grievance/tests/test_grievance_data_change_mutations.py b/backend/hct_mis_api/apps/grievance/tests/test_grievance_data_change_mutations.py index d764ea068a..391658cc1e 100644 --- a/backend/hct_mis_api/apps/grievance/tests/test_grievance_data_change_mutations.py +++ b/backend/hct_mis_api/apps/grievance/tests/test_grievance_data_change_mutations.py @@ -232,7 +232,7 @@ def test_grievance_create_individual_data_change(self, _, permissions): "type": IDENTIFICATION_TYPE_NATIONAL_ID, "country": "POL", "number": "123-123-UX-321", - "photo": SimpleUploadedFile(name="test.jpg", content="".encode("utf-8")), + "photo": SimpleUploadedFile(name="test.jpg", content=b""), } ], "identities": [ @@ -291,7 +291,7 @@ def test_grievance_update_individual_data_change(self, _, permissions): "type": IDENTIFICATION_TYPE_NATIONAL_PASSPORT, "country": "POL", "number": "321-321-XU-987", - "photo": SimpleUploadedFile(name="test.jpg", content="".encode("utf-8")), + "photo": SimpleUploadedFile(name="test.jpg", content=b""), } ], "documentsToEdit": [ @@ -300,7 +300,7 @@ def test_grievance_update_individual_data_change(self, _, permissions): "type": IDENTIFICATION_TYPE_NATIONAL_ID, "country": "POL", "number": "321-321-XU-123", - "photo": SimpleUploadedFile(name="test.jpg", content="".encode("utf-8")), + "photo": SimpleUploadedFile(name="test.jpg", content=b""), } ], "identities": [ diff --git a/backend/hct_mis_api/apps/grievance/tests/test_ticket_notes.py b/backend/hct_mis_api/apps/grievance/tests/test_ticket_notes.py index ef8017164d..b4965d33fd 100644 --- a/backend/hct_mis_api/apps/grievance/tests/test_ticket_notes.py +++ b/backend/hct_mis_api/apps/grievance/tests/test_ticket_notes.py @@ -1,12 +1,16 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase -from hct_mis_api.apps.core.fixtures import AdminAreaLevelFactory, AdminAreaFactory +from hct_mis_api.apps.core.fixtures import AdminAreaFactory, AdminAreaLevelFactory from hct_mis_api.apps.core.models import BusinessArea -from hct_mis_api.apps.grievance.fixtures import TicketNoteFactory, GrievanceTicketFactory +from hct_mis_api.apps.grievance.fixtures import ( + GrievanceTicketFactory, + TicketNoteFactory, +) class TestTicketNotes(APITestCase): diff --git a/backend/hct_mis_api/apps/grievance/tests/test_update_grievance_tickets.py b/backend/hct_mis_api/apps/grievance/tests/test_update_grievance_tickets.py index 1e92170e76..0db5eb22bd 100644 --- a/backend/hct_mis_api/apps/grievance/tests/test_update_grievance_tickets.py +++ b/backend/hct_mis_api/apps/grievance/tests/test_update_grievance_tickets.py @@ -298,7 +298,7 @@ def test_update_add_individual(self, name, permissions): "type": IDENTIFICATION_TYPE_NATIONAL_ID, "country": "USA", "number": "321-321-UX-321", - "photo": SimpleUploadedFile(name="test.jpg", content="".encode("utf-8")), + "photo": SimpleUploadedFile(name="test.jpg", content=b""), } ], "identities": [ @@ -410,7 +410,7 @@ def test_update_change_individual(self, name, permissions): "country": "POL", "type": IDENTIFICATION_TYPE_NATIONAL_ID, "number": "111-222-777", - "photo": SimpleUploadedFile(name="test.jpg", content="".encode("utf-8")), + "photo": SimpleUploadedFile(name="test.jpg", content=b""), }, ], "documentsToRemove": [], diff --git a/backend/hct_mis_api/apps/grievance/validators.py b/backend/hct_mis_api/apps/grievance/validators.py index e2d6e27fe8..8e1e66be34 100644 --- a/backend/hct_mis_api/apps/grievance/validators.py +++ b/backend/hct_mis_api/apps/grievance/validators.py @@ -1,4 +1,5 @@ import logging + from graphql import GraphQLError logger = logging.getLogger(__name__) diff --git a/backend/hct_mis_api/apps/household/elasticsearch_utils.py b/backend/hct_mis_api/apps/household/elasticsearch_utils.py index 1985d5c8f2..9fd5a9849a 100644 --- a/backend/hct_mis_api/apps/household/elasticsearch_utils.py +++ b/backend/hct_mis_api/apps/household/elasticsearch_utils.py @@ -1,6 +1,7 @@ import logging from django.core.management import CommandError + from django_elasticsearch_dsl.registries import registry from elasticsearch_dsl import Search diff --git a/backend/hct_mis_api/apps/household/migrations/0044_migration.py b/backend/hct_mis_api/apps/household/migrations/0044_migration.py index 000882f9c5..d8f379a800 100644 --- a/backend/hct_mis_api/apps/household/migrations/0044_migration.py +++ b/backend/hct_mis_api/apps/household/migrations/0044_migration.py @@ -13,12 +13,12 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='household', name='child_hoh', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='household', name='consent', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='household', @@ -28,7 +28,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='household', name='fchild_hoh', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='household', @@ -43,7 +43,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='household', name='returnee', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='household', @@ -63,17 +63,17 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='individual', name='administration_of_rutf', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='individual', name='enrolled_in_nutrition_programme', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='individual', name='pregnant', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.DeleteModel( name='HouseholdIdentity', diff --git a/backend/hct_mis_api/apps/household/tests/snapshots/snap_test_household_query.py b/backend/hct_mis_api/apps/household/tests/snapshots/snap_test_household_query.py index d6ee9a1a51..1cb717e459 100644 --- a/backend/hct_mis_api/apps/household/tests/snapshots/snap_test_household_query.py +++ b/backend/hct_mis_api/apps/household/tests/snapshots/snap_test_household_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestHouseholdQuery::test_household_query_all_0_all_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/household/tests/snapshots/snap_test_individual_query.py b/backend/hct_mis_api/apps/household/tests/snapshots/snap_test_individual_query.py index 811f90bccd..23f39e73cf 100644 --- a/backend/hct_mis_api/apps/household/tests/snapshots/snap_test_individual_query.py +++ b/backend/hct_mis_api/apps/household/tests/snapshots/snap_test_individual_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestIndividualQuery::test_individual_programme_filter_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/household/tests/test_document_type_model.py b/backend/hct_mis_api/apps/household/tests/test_document_type_model.py index f95255e283..847d65035a 100644 --- a/backend/hct_mis_api/apps/household/tests/test_document_type_model.py +++ b/backend/hct_mis_api/apps/household/tests/test_document_type_model.py @@ -9,7 +9,7 @@ class TestDocumentTypeModel(TestCase): - multi_db = True + databases = "__all__" def test_create_document_type_with_specific_country(self): document_type = DocumentType.objects.create( diff --git a/backend/hct_mis_api/apps/household/tests/test_household_query.py b/backend/hct_mis_api/apps/household/tests/test_household_query.py index aa90166a7e..e200899ad5 100644 --- a/backend/hct_mis_api/apps/household/tests/test_household_query.py +++ b/backend/hct_mis_api/apps/household/tests/test_household_query.py @@ -1,4 +1,5 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory diff --git a/backend/hct_mis_api/apps/household/tests/test_individual_query.py b/backend/hct_mis_api/apps/household/tests/test_individual_query.py index ebd28d24ce..d96f80deff 100644 --- a/backend/hct_mis_api/apps/household/tests/test_individual_query.py +++ b/backend/hct_mis_api/apps/household/tests/test_individual_query.py @@ -1,16 +1,14 @@ import unittest from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase from hct_mis_api.apps.core.models import BusinessArea -from hct_mis_api.apps.household.fixtures import ( - IndividualFactory, - HouseholdFactory, -) +from hct_mis_api.apps.household.fixtures import HouseholdFactory, IndividualFactory from hct_mis_api.apps.program.fixtures import ProgramFactory diff --git a/backend/hct_mis_api/apps/household/tests/test_individual_xlsx_update.py b/backend/hct_mis_api/apps/household/tests/test_individual_xlsx_update.py index aa4b466593..5ab7049f73 100644 --- a/backend/hct_mis_api/apps/household/tests/test_individual_xlsx_update.py +++ b/backend/hct_mis_api/apps/household/tests/test_individual_xlsx_update.py @@ -45,7 +45,7 @@ def invalid_file(): class TestIndividualXlsxUpdate(APITestCase): - multi_db = True + databases = "__all__" def setUp(self) -> None: call_command("loadbusinessareas") diff --git a/backend/hct_mis_api/apps/mis_datahub/migrations/0028_migration.py b/backend/hct_mis_api/apps/mis_datahub/migrations/0028_migration.py index efcce4925c..f7817a4d59 100644 --- a/backend/hct_mis_api/apps/mis_datahub/migrations/0028_migration.py +++ b/backend/hct_mis_api/apps/mis_datahub/migrations/0028_migration.py @@ -13,6 +13,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='individual', name='pregnant', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), ] diff --git a/backend/hct_mis_api/apps/mis_datahub/tests/test_send_tp_to_datahub.py b/backend/hct_mis_api/apps/mis_datahub/tests/test_send_tp_to_datahub.py index f658e99710..5b07c33953 100644 --- a/backend/hct_mis_api/apps/mis_datahub/tests/test_send_tp_to_datahub.py +++ b/backend/hct_mis_api/apps/mis_datahub/tests/test_send_tp_to_datahub.py @@ -32,7 +32,7 @@ class TestSendTpToDatahub(TestCase): - multi_db = True + databases = "__all__" @staticmethod def _pre_test_commands(): diff --git a/backend/hct_mis_api/apps/payment/celery_tasks.py b/backend/hct_mis_api/apps/payment/celery_tasks.py index 529e8edc9e..01e35850e3 100644 --- a/backend/hct_mis_api/apps/payment/celery_tasks.py +++ b/backend/hct_mis_api/apps/payment/celery_tasks.py @@ -10,7 +10,9 @@ def get_sync_run_rapid_pro_task(): logger.info(f"get_sync_run_rapid_pro_task start") try: - from hct_mis_api.apps.payment.tasks.CheckRapidProVerificationTask import CheckRapidProVerificationTask + from hct_mis_api.apps.payment.tasks.CheckRapidProVerificationTask import ( + CheckRapidProVerificationTask, + ) CheckRapidProVerificationTask().execute() except Exception as e: diff --git a/backend/hct_mis_api/apps/payment/fixtures.py b/backend/hct_mis_api/apps/payment/fixtures.py index 465700d1a7..064d2b8944 100644 --- a/backend/hct_mis_api/apps/payment/fixtures.py +++ b/backend/hct_mis_api/apps/payment/fixtures.py @@ -11,10 +11,10 @@ from hct_mis_api.apps.household.fixtures import HouseholdFactory from hct_mis_api.apps.household.models import Household from hct_mis_api.apps.payment.models import ( - PaymentRecord, - ServiceProvider, CashPlanPaymentVerification, + PaymentRecord, PaymentVerification, + ServiceProvider, ) from hct_mis_api.apps.program.fixtures import CashPlanFactory from hct_mis_api.apps.program.models import CashPlan, Program diff --git a/backend/hct_mis_api/apps/payment/rapid_pro/api.py b/backend/hct_mis_api/apps/payment/rapid_pro/api.py index 25097c2d64..0bf4a08387 100644 --- a/backend/hct_mis_api/apps/payment/rapid_pro/api.py +++ b/backend/hct_mis_api/apps/payment/rapid_pro/api.py @@ -1,11 +1,12 @@ import logging from decimal import Decimal -import requests -from constance import config from django.conf import settings from django.core.exceptions import ValidationError +import requests +from constance import config + from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.household.models import Individual diff --git a/backend/hct_mis_api/apps/payment/tests/snapshots/snap_test_chart_total_transferred_cash_by_country.py b/backend/hct_mis_api/apps/payment/tests/snapshots/snap_test_chart_total_transferred_cash_by_country.py index 70f862e5c5..9ba57d067d 100644 --- a/backend/hct_mis_api/apps/payment/tests/snapshots/snap_test_chart_total_transferred_cash_by_country.py +++ b/backend/hct_mis_api/apps/payment/tests/snapshots/snap_test_chart_total_transferred_cash_by_country.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestChartTotalTransferredCashByCountry::test_resolving_chart_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/payment/tests/snapshots/snap_test_discard_verification_mutation.py b/backend/hct_mis_api/apps/payment/tests/snapshots/snap_test_discard_verification_mutation.py index fc3eb29feb..ca916b65c9 100644 --- a/backend/hct_mis_api/apps/payment/tests/snapshots/snap_test_discard_verification_mutation.py +++ b/backend/hct_mis_api/apps/payment/tests/snapshots/snap_test_discard_verification_mutation.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestDiscardVerificationMutation::test_discard_active_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/payment/tests/test_chart_total_transferred_cash_by_country.py b/backend/hct_mis_api/apps/payment/tests/test_chart_total_transferred_cash_by_country.py index a002501952..365de2a0e7 100644 --- a/backend/hct_mis_api/apps/payment/tests/test_chart_total_transferred_cash_by_country.py +++ b/backend/hct_mis_api/apps/payment/tests/test_chart_total_transferred_cash_by_country.py @@ -1,6 +1,7 @@ from datetime import datetime from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory diff --git a/backend/hct_mis_api/apps/payment/tests/test_discard_verification_mutation.py b/backend/hct_mis_api/apps/payment/tests/test_discard_verification_mutation.py index bb809d3f6a..253bc33c78 100644 --- a/backend/hct_mis_api/apps/payment/tests/test_discard_verification_mutation.py +++ b/backend/hct_mis_api/apps/payment/tests/test_discard_verification_mutation.py @@ -1,23 +1,27 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase -from hct_mis_api.apps.core.models import BusinessArea, AdminArea -from hct_mis_api.apps.household.fixtures import ( - create_household, - EntitlementCardFactory, -) +from hct_mis_api.apps.core.models import AdminArea, BusinessArea +from hct_mis_api.apps.household.fixtures import EntitlementCardFactory, create_household from hct_mis_api.apps.payment.fixtures import ( - PaymentRecordFactory, CashPlanPaymentVerificationFactory, + PaymentRecordFactory, PaymentVerificationFactory, ) -from hct_mis_api.apps.payment.models import PaymentVerification, CashPlanPaymentVerification -from hct_mis_api.apps.program.fixtures import ProgramFactory, CashPlanFactory +from hct_mis_api.apps.payment.models import ( + CashPlanPaymentVerification, + PaymentVerification, +) +from hct_mis_api.apps.program.fixtures import CashPlanFactory, ProgramFactory from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory -from hct_mis_api.apps.targeting.fixtures import TargetingCriteriaFactory, TargetPopulationFactory +from hct_mis_api.apps.targeting.fixtures import ( + TargetingCriteriaFactory, + TargetPopulationFactory, +) class TestDiscardVerificationMutation(APITestCase): diff --git a/backend/hct_mis_api/apps/payment/views.py b/backend/hct_mis_api/apps/payment/views.py index 1f717ae1f8..c7f7691f42 100644 --- a/backend/hct_mis_api/apps/payment/views.py +++ b/backend/hct_mis_api/apps/payment/views.py @@ -4,12 +4,15 @@ from django.core.exceptions import PermissionDenied from django.http import HttpResponse from django.shortcuts import get_object_or_404 + from openpyxl.writer.excel import save_virtual_workbook from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.utils import decode_id_string from hct_mis_api.apps.payment.models import CashPlanPaymentVerification -from hct_mis_api.apps.payment.xlsx.XlsxVerificationExportService import XlsxVerificationExportService +from hct_mis_api.apps.payment.xlsx.XlsxVerificationExportService import ( + XlsxVerificationExportService, +) logger = logging.getLogger(__name__) diff --git a/backend/hct_mis_api/apps/payment/xlsx/XlsxVerificationImportService.py b/backend/hct_mis_api/apps/payment/xlsx/XlsxVerificationImportService.py index d966ce60f4..c79482f86a 100644 --- a/backend/hct_mis_api/apps/payment/xlsx/XlsxVerificationImportService.py +++ b/backend/hct_mis_api/apps/payment/xlsx/XlsxVerificationImportService.py @@ -4,8 +4,13 @@ from graphql import GraphQLError from hct_mis_api.apps.payment.models import PaymentVerification -from hct_mis_api.apps.payment.utils import from_received_yes_no_to_status, float_to_decimal -from hct_mis_api.apps.payment.xlsx.XlsxVerificationExportService import XlsxVerificationExportService +from hct_mis_api.apps.payment.utils import ( + float_to_decimal, + from_received_yes_no_to_status, +) +from hct_mis_api.apps.payment.xlsx.XlsxVerificationExportService import ( + XlsxVerificationExportService, +) class XlsxVerificationImportService: diff --git a/backend/hct_mis_api/apps/power_query/mixin.py b/backend/hct_mis_api/apps/power_query/mixin.py index 4662f477ae..6791191344 100644 --- a/backend/hct_mis_api/apps/power_query/mixin.py +++ b/backend/hct_mis_api/apps/power_query/mixin.py @@ -3,16 +3,15 @@ from admin_extra_urls.decorators import button from admin_extra_urls.mixins import ExtraUrlMixin + from hct_mis_api.apps.power_query.models import Query class PowerQueryMixin(ExtraUrlMixin): - @button(permission='power_query_query_add') + @button(permission="power_query_query_add") def power_query(self, request): ct = ContentType.objects.get_for_model(self.model) - context = self.get_common_context(request, - title='Power Queries', - ct=ct, - entries=Query.objects.filter(target=ct) - ) - return render(request, 'power_query/list.html', context) + context = self.get_common_context( + request, title="Power Queries", ct=ct, entries=Query.objects.filter(target=ct) + ) + return render(request, "power_query/list.html", context) diff --git a/backend/hct_mis_api/apps/power_query/utils.py b/backend/hct_mis_api/apps/power_query/utils.py index cfe87329fd..098dcdc7b6 100644 --- a/backend/hct_mis_api/apps/power_query/utils.py +++ b/backend/hct_mis_api/apps/power_query/utils.py @@ -60,7 +60,7 @@ def wrap(request, *args, **kwargs): return view(request, *args, **kwargs) if "HTTP_AUTHORIZATION" in request.META: - auth = request.META["HTTP_AUTHORIZATION"].split() + auth = request.headers["Authorization"].split() if len(auth) == 2: if auth[0].lower() == "basic": uname, passwd = base64.b64decode(auth[1].encode()).decode().split(":") diff --git a/backend/hct_mis_api/apps/power_query/views.py b/backend/hct_mis_api/apps/power_query/views.py index da38e43590..e44b5459aa 100644 --- a/backend/hct_mis_api/apps/power_query/views.py +++ b/backend/hct_mis_api/apps/power_query/views.py @@ -27,7 +27,7 @@ def fetch(request, pk): report: Report = get_object_or_404(Report, pk=pk) if request.user.is_superuser or report.available_to.filter(pk=request.user.pk): if report.result is None: - content_types = request.META.get("HTTP_ACCEPT", "*/*").split(",") + content_types = request.headers.get("Accept", "*/*").split(",") if "text/html" in content_types: return HttpResponse("This report is not currently available", status=400) elif "application/json" in content_types: diff --git a/backend/hct_mis_api/apps/program/fixtures.py b/backend/hct_mis_api/apps/program/fixtures.py index 88523c209d..7343def621 100644 --- a/backend/hct_mis_api/apps/program/fixtures.py +++ b/backend/hct_mis_api/apps/program/fixtures.py @@ -8,7 +8,7 @@ from hct_mis_api.apps.core.fixtures import AdminAreaFactory from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.payment.models import PaymentRecord -from hct_mis_api.apps.program.models import Program, CashPlan +from hct_mis_api.apps.program.models import CashPlan, Program class ProgramFactory(factory.DjangoModelFactory): diff --git a/backend/hct_mis_api/apps/program/mutations.py b/backend/hct_mis_api/apps/program/mutations.py index a50ee69b8b..36a4912863 100644 --- a/backend/hct_mis_api/apps/program/mutations.py +++ b/backend/hct_mis_api/apps/program/mutations.py @@ -1,19 +1,23 @@ -import graphene from django.core.exceptions import ValidationError from django.db import transaction +import graphene + from hct_mis_api.apps.account.permissions import PermissionMutation, Permissions from hct_mis_api.apps.activity_log.models import log_create from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.core.permissions import is_authenticated -from hct_mis_api.apps.core.utils import decode_id_string, check_concurrency_version_in_mutation from hct_mis_api.apps.core.scalars import BigInt +from hct_mis_api.apps.core.utils import ( + check_concurrency_version_in_mutation, + decode_id_string, +) from hct_mis_api.apps.core.validators import CommonValidator from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.program.schema import ProgramNode from hct_mis_api.apps.program.validators import ( - ProgramValidator, ProgramDeletionValidator, + ProgramValidator, ) from hct_mis_api.apps.utils.mutations import ValidationErrorMutationMixin diff --git a/backend/hct_mis_api/apps/program/schema.py b/backend/hct_mis_api/apps/program/schema.py index 74e6327893..fe31c35dda 100644 --- a/backend/hct_mis_api/apps/program/schema.py +++ b/backend/hct_mis_api/apps/program/schema.py @@ -1,6 +1,7 @@ -import graphene -from django.db.models import Case, IntegerField, Q, Sum, Value, When, Count +from django.db.models import Case, Count, IntegerField, Q, Sum, Value, When from django.db.models.functions import Coalesce, Lower + +import graphene from django_filters import ( CharFilter, DateFilter, @@ -12,22 +13,22 @@ from graphene_django import DjangoObjectType from hct_mis_api.apps.account.permissions import ( + ALL_GRIEVANCES_CREATE_MODIFY, BaseNodePermissionMixin, DjangoPermissionFilterConnectionField, - hopePermissionClass, Permissions, hopeOneOfPermissionClass, - ALL_GRIEVANCES_CREATE_MODIFY, + hopePermissionClass, ) from hct_mis_api.apps.core.extended_connection import ExtendedConnection from hct_mis_api.apps.core.filters import DecimalRangeFilter, IntegerRangeFilter from hct_mis_api.apps.core.schema import ChoiceObject from hct_mis_api.apps.core.utils import ( - to_choice_object, CustomOrderingFilter, + chart_filters_decoder, chart_map_choices, chart_permission_decorator, - chart_filters_decoder, + to_choice_object, ) from hct_mis_api.apps.payment.models import CashPlanPaymentVerification, PaymentRecord from hct_mis_api.apps.payment.utils import get_payment_records_for_dashboard diff --git a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_cash_plan_choices.py b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_cash_plan_choices.py index b96cc7cb57..ae849085c2 100644 --- a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_cash_plan_choices.py +++ b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_cash_plan_choices.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestCashPlanChoices::test_status_choices_query 1'] = { diff --git a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_cash_plan_queries.py b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_cash_plan_queries.py index 6586924512..90a20b6eec 100644 --- a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_cash_plan_queries.py +++ b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_cash_plan_queries.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestCashPlanQueries::test_cash_plans_0_all_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_change_program_status.py b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_change_program_status.py index 6a9046be22..89fb34b30a 100644 --- a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_change_program_status.py +++ b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_change_program_status.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestChangeProgramStatus::test_status_change_0_draft_to_active_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_create_program.py b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_create_program.py index 0f6bf0ac92..ba47d4d5d2 100644 --- a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_create_program.py +++ b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_create_program.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestCreateProgram::test_create_program_not_authenticated 1'] = { diff --git a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_delete_program.py b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_delete_program.py index b13b855bec..1833ae9b97 100644 --- a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_delete_program.py +++ b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_delete_program.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestDeleteProgram::test_delete_program_not_authenticated 1'] = { diff --git a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_program_choices.py b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_program_choices.py index 0e1903b5ee..51163814f1 100644 --- a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_program_choices.py +++ b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_program_choices.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestProgramChoices::test_program_frequency_of_payments_choices 1'] = { diff --git a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_update_program.py b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_update_program.py index 26f2e8bb5e..929e924272 100644 --- a/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_update_program.py +++ b/backend/hct_mis_api/apps/program/tests/snapshots/snap_test_update_program.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestUpdateProgram::test_update_program_not_authenticated 1'] = { diff --git a/backend/hct_mis_api/apps/program/tests/test_cash_plan_queries.py b/backend/hct_mis_api/apps/program/tests/test_cash_plan_queries.py index 371fb95147..86814241d5 100644 --- a/backend/hct_mis_api/apps/program/tests/test_cash_plan_queries.py +++ b/backend/hct_mis_api/apps/program/tests/test_cash_plan_queries.py @@ -1,13 +1,14 @@ from datetime import datetime -from parameterized import parameterized from django.core.management import call_command +from parameterized import parameterized + from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions -from hct_mis_api.apps.payment.models import PaymentRecord from hct_mis_api.apps.core.base_test_case import APITestCase from hct_mis_api.apps.core.models import BusinessArea +from hct_mis_api.apps.payment.models import PaymentRecord from hct_mis_api.apps.program.fixtures import CashPlanFactory, ProgramFactory QUERY_SINGLE_CASH_PLAN = """ diff --git a/backend/hct_mis_api/apps/program/tests/test_change_program_status.py b/backend/hct_mis_api/apps/program/tests/test_change_program_status.py index b77933d593..da5b967004 100644 --- a/backend/hct_mis_api/apps/program/tests/test_change_program_status.py +++ b/backend/hct_mis_api/apps/program/tests/test_change_program_status.py @@ -1,4 +1,5 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory diff --git a/backend/hct_mis_api/apps/program/tests/test_create_program.py b/backend/hct_mis_api/apps/program/tests/test_create_program.py index 270c51ae2b..448f36b519 100644 --- a/backend/hct_mis_api/apps/program/tests/test_create_program.py +++ b/backend/hct_mis_api/apps/program/tests/test_create_program.py @@ -1,4 +1,5 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory diff --git a/backend/hct_mis_api/apps/program/tests/test_delete_program.py b/backend/hct_mis_api/apps/program/tests/test_delete_program.py index a1eb87ba5b..774bc52f18 100644 --- a/backend/hct_mis_api/apps/program/tests/test_delete_program.py +++ b/backend/hct_mis_api/apps/program/tests/test_delete_program.py @@ -1,4 +1,5 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory diff --git a/backend/hct_mis_api/apps/program/tests/test_update_program.py b/backend/hct_mis_api/apps/program/tests/test_update_program.py index 75f08453b2..a3586db2b7 100644 --- a/backend/hct_mis_api/apps/program/tests/test_update_program.py +++ b/backend/hct_mis_api/apps/program/tests/test_update_program.py @@ -1,4 +1,5 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory diff --git a/backend/hct_mis_api/apps/program/validators.py b/backend/hct_mis_api/apps/program/validators.py index 8969b21821..f97bcdc30b 100644 --- a/backend/hct_mis_api/apps/program/validators.py +++ b/backend/hct_mis_api/apps/program/validators.py @@ -1,4 +1,5 @@ import logging + from django.core.exceptions import ValidationError from hct_mis_api.apps.core.validators import BaseValidator diff --git a/backend/hct_mis_api/apps/registration_data/schema.py b/backend/hct_mis_api/apps/registration_data/schema.py index c2d191bfd9..1d4289d39f 100644 --- a/backend/hct_mis_api/apps/registration_data/schema.py +++ b/backend/hct_mis_api/apps/registration_data/schema.py @@ -1,18 +1,24 @@ -import graphene from django.db.models.functions import Lower -from django_filters import FilterSet, DateFilter, CharFilter + +import graphene +from django_filters import CharFilter, DateFilter, FilterSet from graphene_django import DjangoObjectType from hct_mis_api.apps.account.permissions import ( + BaseNodePermissionMixin, DjangoPermissionFilterConnectionField, - hopePermissionClass, Permissions, - BaseNodePermissionMixin, + hopePermissionClass, ) from hct_mis_api.apps.core.extended_connection import ExtendedConnection from hct_mis_api.apps.core.schema import ChoiceObject -from hct_mis_api.apps.core.utils import get_count_and_percentage, CustomOrderingFilter -from hct_mis_api.apps.household.models import DUPLICATE, NEEDS_ADJUDICATION, UNIQUE, DUPLICATE_IN_BATCH +from hct_mis_api.apps.core.utils import CustomOrderingFilter, get_count_and_percentage +from hct_mis_api.apps.household.models import ( + DUPLICATE, + DUPLICATE_IN_BATCH, + NEEDS_ADJUDICATION, + UNIQUE, +) from hct_mis_api.apps.registration_data.models import RegistrationDataImport from hct_mis_api.apps.registration_datahub.models import UNIQUE_IN_BATCH diff --git a/backend/hct_mis_api/apps/registration_data/tests/snapshots/snap_test_registration_data_import_query.py b/backend/hct_mis_api/apps/registration_data/tests/snapshots/snap_test_registration_data_import_query.py index dca318bcc6..ad72a5464a 100644 --- a/backend/hct_mis_api/apps/registration_data/tests/snapshots/snap_test_registration_data_import_query.py +++ b/backend/hct_mis_api/apps/registration_data/tests/snapshots/snap_test_registration_data_import_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestRegistrationDataImportQuery::test_registration_data_import_datahub_query_all_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/registration_data/tests/test_registration_data_import_query.py b/backend/hct_mis_api/apps/registration_data/tests/test_registration_data_import_query.py index ecf4497274..316f392bb7 100644 --- a/backend/hct_mis_api/apps/registration_data/tests/test_registration_data_import_query.py +++ b/backend/hct_mis_api/apps/registration_data/tests/test_registration_data_import_query.py @@ -1,15 +1,16 @@ -from parameterized import parameterized from django.core.management import call_command +from parameterized import parameterized + from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase -from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory from hct_mis_api.apps.core.models import BusinessArea +from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory class TestRegistrationDataImportQuery(APITestCase): - multi_db = True + databases = "__all__" ALL_REGISTRATION_DATA_IMPORT_DATAHUB_QUERY = """ query AllRegistrationDataImports { diff --git a/backend/hct_mis_api/apps/registration_datahub/migrations/0033_migration.py b/backend/hct_mis_api/apps/registration_datahub/migrations/0033_migration.py index f276684c85..86f2e17e5f 100644 --- a/backend/hct_mis_api/apps/registration_datahub/migrations/0033_migration.py +++ b/backend/hct_mis_api/apps/registration_datahub/migrations/0033_migration.py @@ -13,27 +13,27 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='importedhousehold', name='child_hoh', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='importedhousehold', name='consent', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='importedhousehold', name='fchild_hoh', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='importedhousehold', name='returnee', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.AlterField( model_name='importedindividual', name='pregnant', - field=models.NullBooleanField(), + field=models.BooleanField(null=True), ), migrations.DeleteModel( name='ImportedHouseholdIdentity', diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_imported_household_query.py b/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_imported_household_query.py index ae4400d6eb..02d24d8027 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_imported_household_query.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_imported_household_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestImportedHouseholdQuery::test_imported_household_query_all_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_imported_individuals_query.py b/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_imported_individuals_query.py index 9cfd739c35..325a6640ec 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_imported_individuals_query.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_imported_individuals_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestImportedIndividualQuery::test_imported_individual_query_0_all_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_registration_data_import_datahub_mutations.py b/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_registration_data_import_datahub_mutations.py index 23b53da495..1d6df6867b 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_registration_data_import_datahub_mutations.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_registration_data_import_datahub_mutations.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestRegistrationDataImportDatahubMutations::test_registration_data_import_datahub_upload_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_registration_data_import_datahub_query.py b/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_registration_data_import_datahub_query.py index 1d33cb165a..3a6b7400dd 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_registration_data_import_datahub_query.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/snapshots/snap_test_registration_data_import_datahub_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestRegistrationDataImportDatahubQuery::test_registration_data_import_datahub_query_all 1'] = { diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/tasks/test_mark_submissions.py b/backend/hct_mis_api/apps/registration_datahub/tests/tasks/test_mark_submissions.py index 446ea70d58..f853552b8d 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/tasks/test_mark_submissions.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/tasks/test_mark_submissions.py @@ -22,7 +22,7 @@ class TestMarkSubmissions(TestCase): - multi_db = True + databases = "__all__" def setUp(self) -> None: call_command("loadbusinessareas") diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_deduplication.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_deduplication.py index 7bf0f9fffb..98de6f34df 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_deduplication.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_deduplication.py @@ -29,7 +29,7 @@ class TestBatchDeduplication(BaseElasticSearchTestCase): - multi_db = True + databases = "__all__" @classmethod def setUpTestData(cls): @@ -283,7 +283,7 @@ def test_batch_deduplication(self): class TestGoldenRecordDeduplication(BaseElasticSearchTestCase): - multi_db = True + databases = "__all__" @classmethod def setUpTestData(cls): diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_handling_documents_duplicates.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_handling_documents_duplicates.py index f0b390851d..a855f8d7f6 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_handling_documents_duplicates.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_handling_documents_duplicates.py @@ -8,15 +8,15 @@ DUPLICATE, FEMALE, HEAD, + IDENTIFICATION_TYPE_NATIONAL_ID, MALE, NEEDS_ADJUDICATION, SON_DAUGHTER, UNIQUE, WIFE_HUSBAND, - Individual, - DocumentType, - IDENTIFICATION_TYPE_NATIONAL_ID, Document, + DocumentType, + Individual, ) from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory from hct_mis_api.apps.registration_datahub.fixtures import ( @@ -33,7 +33,7 @@ class TestGoldenRecordDeduplication(BaseElasticSearchTestCase): - multi_db = True + databases = "__all__" @classmethod def setUpTestData(cls): diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_document_type_models.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_document_type_models.py index f644759aef..27244b5630 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_document_type_models.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_document_type_models.py @@ -7,7 +7,7 @@ class TestImportedDocumentTypeModel(TestCase): - multi_db = True + databases = "__all__" def test_create_document_type_with_specific_country(self): document_type = ImportedDocumentType.objects.create( diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_household_query.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_household_query.py index 2348966daf..98d135bee0 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_household_query.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_household_query.py @@ -1,15 +1,16 @@ -from parameterized import parameterized from django.core.management import call_command +from parameterized import parameterized + from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase -from hct_mis_api.apps.registration_datahub.fixtures import ImportedHouseholdFactory from hct_mis_api.apps.core.models import BusinessArea +from hct_mis_api.apps.registration_datahub.fixtures import ImportedHouseholdFactory class TestImportedHouseholdQuery(APITestCase): - multi_db = True + databases = "__all__" ALL_IMPORTED_HOUSEHOLD_QUERY = """ query AllImportedHouseholds{ diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_individuals_query.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_individuals_query.py index 25ef8161ad..f943ffeb15 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_individuals_query.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_imported_individuals_query.py @@ -1,11 +1,12 @@ -from parameterized import parameterized from django.core.management import call_command +from parameterized import parameterized + from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase -from hct_mis_api.apps.registration_datahub.fixtures import ImportedIndividualFactory from hct_mis_api.apps.core.models import BusinessArea +from hct_mis_api.apps.registration_datahub.fixtures import ImportedIndividualFactory ALL_IMPORTED_INDIVIDUALS_QUERY = """ query AllImportedIndividuals { @@ -66,7 +67,7 @@ class TestImportedIndividualQuery(APITestCase): - multi_db = True + databases = "__all__" # IMPORTANT! # FREEZGUN doesn't work this snapshot have to be updated once a year diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_rdi_create.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_rdi_create.py index a5f1677cd1..2211d7f6cb 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_rdi_create.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_rdi_create.py @@ -57,7 +57,7 @@ def __init__(self, value, coordinate): class TestRdiCreateTask(TestCase): - multi_db = True + databases = "__all__" @classmethod def setUpTestData(cls): @@ -348,7 +348,7 @@ def test_store_row_id(self): class TestRdiKoboCreateTask(TestCase): - multi_db = True + databases = "__all__" @staticmethod def _return_test_image(*args, **kwargs): diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_refuse_rdi_mutation.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_refuse_rdi_mutation.py index dec6c9527b..cc0bca339b 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_refuse_rdi_mutation.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_refuse_rdi_mutation.py @@ -10,7 +10,7 @@ class TestRefuseRdiMutation(APITestCase): - multi_db = True + databases = "__all__" QUERY = """ mutation RefuseRegistrationDataImportMutation( diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_registration_data_import_datahub_mutations.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_registration_data_import_datahub_mutations.py index 41f36c021a..5708389d0c 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_registration_data_import_datahub_mutations.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_registration_data_import_datahub_mutations.py @@ -1,14 +1,12 @@ import io -from parameterized import parameterized -from PIL import Image from django.conf import settings -from django.core.files.uploadedfile import ( - InMemoryUploadedFile, - SimpleUploadedFile, -) +from django.core.files.uploadedfile import InMemoryUploadedFile, SimpleUploadedFile from django.core.management import call_command +from parameterized import parameterized +from PIL import Image + from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase @@ -17,7 +15,7 @@ class TestRegistrationDataImportDatahubMutations(APITestCase): - multi_db = True + databases = "__all__" UPLOAD_REGISTRATION_DATA_IMPORT_DATAHUB = """ mutation UploadImportDataXLSXFile( diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_registration_data_import_datahub_query.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_registration_data_import_datahub_query.py index 06e81ee29a..4322424710 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_registration_data_import_datahub_query.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_registration_data_import_datahub_query.py @@ -1,10 +1,12 @@ from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.core.base_test_case import APITestCase -from hct_mis_api.apps.registration_datahub.fixtures import RegistrationDataImportDatahubFactory +from hct_mis_api.apps.registration_datahub.fixtures import ( + RegistrationDataImportDatahubFactory, +) class TestRegistrationDataImportDatahubQuery(APITestCase): - multi_db = True + databases = "__all__" ALL_REGISTRATION_DATA_IMPORT_DATAHUB_QUERY = """ query AllRegistrationDataImportsDatahub { diff --git a/backend/hct_mis_api/apps/registration_datahub/tests/test_template_file_generator.py b/backend/hct_mis_api/apps/registration_datahub/tests/test_template_file_generator.py index 1f25ce4c9b..6e4f44bc03 100644 --- a/backend/hct_mis_api/apps/registration_datahub/tests/test_template_file_generator.py +++ b/backend/hct_mis_api/apps/registration_datahub/tests/test_template_file_generator.py @@ -1,6 +1,8 @@ from unittest import TestCase, mock -from hct_mis_api.apps.registration_datahub.template_generator import TemplateFileGenerator +from hct_mis_api.apps.registration_datahub.template_generator import ( + TemplateFileGenerator, +) class TestTemplateFileGenerator(TestCase): diff --git a/backend/hct_mis_api/apps/registration_datahub/views.py b/backend/hct_mis_api/apps/registration_datahub/views.py index 89f5693d46..b968829885 100644 --- a/backend/hct_mis_api/apps/registration_datahub/views.py +++ b/backend/hct_mis_api/apps/registration_datahub/views.py @@ -1,7 +1,10 @@ from django.http import HttpResponse + from openpyxl.writer.excel import save_virtual_workbook -from hct_mis_api.apps.registration_datahub.template_generator import TemplateFileGenerator +from hct_mis_api.apps.registration_datahub.template_generator import ( + TemplateFileGenerator, +) def download_template(request): diff --git a/backend/hct_mis_api/apps/reporting/admin.py b/backend/hct_mis_api/apps/reporting/admin.py index 6a44c66275..3f8e333b8f 100644 --- a/backend/hct_mis_api/apps/reporting/admin.py +++ b/backend/hct_mis_api/apps/reporting/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import Report, DashboardReport +from .models import DashboardReport, Report @admin.register(Report) diff --git a/backend/hct_mis_api/apps/reporting/fixtures.py b/backend/hct_mis_api/apps/reporting/fixtures.py index 4f417bccc3..a2c343e1fa 100644 --- a/backend/hct_mis_api/apps/reporting/fixtures.py +++ b/backend/hct_mis_api/apps/reporting/fixtures.py @@ -5,8 +5,8 @@ from factory import fuzzy from pytz import utc -from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.account.fixtures import UserFactory +from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.reporting.models import Report diff --git a/backend/hct_mis_api/apps/reporting/schema.py b/backend/hct_mis_api/apps/reporting/schema.py index 461f2511d6..bc07b55869 100644 --- a/backend/hct_mis_api/apps/reporting/schema.py +++ b/backend/hct_mis_api/apps/reporting/schema.py @@ -1,22 +1,30 @@ +from datetime import datetime + +from django.db.models.functions import ExtractYear + import graphene +from django_filters import ( + CharFilter, + DateTimeFilter, + FilterSet, + MultipleChoiceFilter, + OrderingFilter, +) from graphene import relay from graphene_django import DjangoObjectType -from django.db.models.functions import ExtractYear -from django_filters import CharFilter, FilterSet, MultipleChoiceFilter, OrderingFilter, DateTimeFilter -from datetime import datetime from hct_mis_api.apps.account.permissions import ( BaseNodePermissionMixin, - hopePermissionClass, - Permissions, DjangoPermissionFilterConnectionField, + Permissions, + hopePermissionClass, ) from hct_mis_api.apps.core.extended_connection import ExtendedConnection from hct_mis_api.apps.core.schema import ChoiceObject from hct_mis_api.apps.core.utils import to_choice_object -from hct_mis_api.apps.reporting.models import Report, DashboardReport -from hct_mis_api.apps.payment.models import PaymentRecord from hct_mis_api.apps.grievance.models import GrievanceTicket +from hct_mis_api.apps.payment.models import PaymentRecord +from hct_mis_api.apps.reporting.models import DashboardReport, Report class ReportFilter(FilterSet): diff --git a/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reporting_choices.py b/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reporting_choices.py index d921420ca9..c389da782b 100644 --- a/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reporting_choices.py +++ b/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reporting_choices.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestProgramChoices::test_report_types_choices 1'] = { diff --git a/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reporting_mutations.py b/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reporting_mutations.py index 63094b2cb6..71f78749e9 100644 --- a/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reporting_mutations.py +++ b/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reporting_mutations.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestReportingMutation::test_create_report_with_no_extra_filters_0_with_permission_individuals_report_with_earlier_dateTo 1'] = { diff --git a/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reports_query.py b/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reports_query.py index 46de720d45..9d0f56de03 100644 --- a/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reports_query.py +++ b/backend/hct_mis_api/apps/reporting/tests/snapshots/snap_test_reports_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestReportsQuery::test_reports_query_all_0_all_with_permissions 1'] = { diff --git a/backend/hct_mis_api/apps/reporting/tests/test_report_service.py b/backend/hct_mis_api/apps/reporting/tests/test_report_service.py index 218caadb10..9bdbf4e79d 100644 --- a/backend/hct_mis_api/apps/reporting/tests/test_report_service.py +++ b/backend/hct_mis_api/apps/reporting/tests/test_report_service.py @@ -1,26 +1,29 @@ -from parameterized import parameterized from django.core.management import call_command from django.test import TestCase -from hct_mis_api.apps.core.models import BusinessArea +from parameterized import parameterized + from hct_mis_api.apps.account.fixtures import UserFactory -from hct_mis_api.apps.reporting.fixtures import ReportFactory -from hct_mis_api.apps.reporting.models import Report +from hct_mis_api.apps.core.fixtures import AdminAreaFactory, AdminAreaLevelFactory +from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.household.fixtures import create_household_and_individuals -from hct_mis_api.apps.core.fixtures import AdminAreaLevelFactory, AdminAreaFactory -from hct_mis_api.apps.program.fixtures import CashPlanFactory, ProgramFactory from hct_mis_api.apps.payment.fixtures import ( CashPlanPaymentVerificationFactory, PaymentRecordFactory, PaymentVerificationFactory, ) +from hct_mis_api.apps.program.fixtures import CashPlanFactory, ProgramFactory +from hct_mis_api.apps.reporting.fixtures import ReportFactory +from hct_mis_api.apps.reporting.models import Report class TestGenerateReportService(TestCase): @classmethod def setUpTestData(self): call_command("loadbusinessareas") - from hct_mis_api.apps.reporting.generate_report_service import GenerateReportService + from hct_mis_api.apps.reporting.generate_report_service import ( + GenerateReportService, + ) self.GenerateReportService = GenerateReportService diff --git a/backend/hct_mis_api/apps/reporting/tests/test_reporting_mutations.py b/backend/hct_mis_api/apps/reporting/tests/test_reporting_mutations.py index 9a5d90edac..94baab937c 100644 --- a/backend/hct_mis_api/apps/reporting/tests/test_reporting_mutations.py +++ b/backend/hct_mis_api/apps/reporting/tests/test_reporting_mutations.py @@ -1,16 +1,17 @@ -from parameterized import parameterized from django.core.management import call_command +from parameterized import parameterized + from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase +from hct_mis_api.apps.core.fixtures import AdminAreaFactory, AdminAreaLevelFactory from hct_mis_api.apps.core.models import BusinessArea -from hct_mis_api.apps.household.fixtures import create_household_and_individuals -from hct_mis_api.apps.reporting.validators import ReportValidator -from hct_mis_api.apps.reporting.models import Report -from hct_mis_api.apps.core.fixtures import AdminAreaLevelFactory, AdminAreaFactory from hct_mis_api.apps.core.utils import encode_id_base64 +from hct_mis_api.apps.household.fixtures import create_household_and_individuals from hct_mis_api.apps.program.fixtures import ProgramFactory +from hct_mis_api.apps.reporting.models import Report +from hct_mis_api.apps.reporting.validators import ReportValidator class TestReportingMutation(APITestCase): diff --git a/backend/hct_mis_api/apps/reporting/tests/test_reports_query.py b/backend/hct_mis_api/apps/reporting/tests/test_reports_query.py index 0f83bde6bc..a529eae413 100644 --- a/backend/hct_mis_api/apps/reporting/tests/test_reports_query.py +++ b/backend/hct_mis_api/apps/reporting/tests/test_reports_query.py @@ -1,4 +1,5 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory diff --git a/backend/hct_mis_api/apps/sanction_list/celery_tasks.py b/backend/hct_mis_api/apps/sanction_list/celery_tasks.py index 0210e9b2c3..5c83c3fa63 100644 --- a/backend/hct_mis_api/apps/sanction_list/celery_tasks.py +++ b/backend/hct_mis_api/apps/sanction_list/celery_tasks.py @@ -10,7 +10,9 @@ def sync_sanction_list_task(): logger.info("sync_sanction_list_task start") try: - from hct_mis_api.apps.sanction_list.tasks.load_xml import LoadSanctionListXMLTask + from hct_mis_api.apps.sanction_list.tasks.load_xml import ( + LoadSanctionListXMLTask, + ) LoadSanctionListXMLTask().execute() except Exception as e: diff --git a/backend/hct_mis_api/apps/sanction_list/schema.py b/backend/hct_mis_api/apps/sanction_list/schema.py index 99cadeffce..d1aae38d2f 100644 --- a/backend/hct_mis_api/apps/sanction_list/schema.py +++ b/backend/hct_mis_api/apps/sanction_list/schema.py @@ -1,5 +1,6 @@ -import graphene from django.db.models.functions import Lower + +import graphene from django_filters import FilterSet from graphene import relay from graphene_django import DjangoObjectType @@ -9,11 +10,11 @@ from hct_mis_api.apps.core.utils import CustomOrderingFilter from hct_mis_api.apps.sanction_list.models import ( SanctionListIndividual, - SanctionListIndividualDocument, - SanctionListIndividualNationalities, - SanctionListIndividualCountries, SanctionListIndividualAliasName, + SanctionListIndividualCountries, SanctionListIndividualDateOfBirth, + SanctionListIndividualDocument, + SanctionListIndividualNationalities, ) diff --git a/backend/hct_mis_api/apps/sanction_list/tasks/check_against_sanction_list.py b/backend/hct_mis_api/apps/sanction_list/tasks/check_against_sanction_list.py index 026f194993..130fed516d 100644 --- a/backend/hct_mis_api/apps/sanction_list/tasks/check_against_sanction_list.py +++ b/backend/hct_mis_api/apps/sanction_list/tasks/check_against_sanction_list.py @@ -1,16 +1,20 @@ -from datetime import datetime, date +from datetime import date, datetime from itertools import permutations -import dateutil.parser from django.conf import settings from django.core.mail import EmailMultiAlternatives from django.db.models import Q from django.template.loader import render_to_string -from openpyxl import load_workbook, Workbook + +import dateutil.parser +from openpyxl import Workbook, load_workbook from openpyxl.utils import get_column_letter from openpyxl.writer.excel import save_virtual_workbook -from hct_mis_api.apps.sanction_list.models import UploadedXLSXFile, SanctionListIndividual +from hct_mis_api.apps.sanction_list.models import ( + SanctionListIndividual, + UploadedXLSXFile, +) class CheckAgainstSanctionListTask: diff --git a/backend/hct_mis_api/apps/sanction_list/tests/test_check_against_sanction_list_pre_merge.py b/backend/hct_mis_api/apps/sanction_list/tests/test_check_against_sanction_list_pre_merge.py index 410557280e..8f3d153885 100644 --- a/backend/hct_mis_api/apps/sanction_list/tests/test_check_against_sanction_list_pre_merge.py +++ b/backend/hct_mis_api/apps/sanction_list/tests/test_check_against_sanction_list_pre_merge.py @@ -25,7 +25,7 @@ @override_config(SANCTION_LIST_MATCH_SCORE=3.5) class TestSanctionListPreMerge(BaseElasticSearchTestCase): - multi_db = True + databases = "__all__" TEST_FILES_PATH = f"{settings.PROJECT_ROOT}/apps/sanction_list/tests/test_files" diff --git a/backend/hct_mis_api/apps/sanction_list/views.py b/backend/hct_mis_api/apps/sanction_list/views.py index d3b65df60b..d61e4ea726 100644 --- a/backend/hct_mis_api/apps/sanction_list/views.py +++ b/backend/hct_mis_api/apps/sanction_list/views.py @@ -1,5 +1,6 @@ from django.contrib.auth.decorators import login_required from django.http import HttpResponse + from openpyxl.writer.excel import save_virtual_workbook from hct_mis_api.apps.sanction_list.template_generator import TemplateFileGenerator diff --git a/backend/hct_mis_api/apps/steficon/tests/test_rules.py b/backend/hct_mis_api/apps/steficon/tests/test_rules.py index d43d48128a..86536762fc 100644 --- a/backend/hct_mis_api/apps/steficon/tests/test_rules.py +++ b/backend/hct_mis_api/apps/steficon/tests/test_rules.py @@ -105,8 +105,8 @@ def test_release(self): release2 = rule.release() release1.refresh_from_db() self.assertEqual(release2.version, 2) - self.assertNotEquals(release1, release2) - self.assertNotEquals(release1, release2) + self.assertNotEqual(release1, release2) + self.assertNotEqual(release1, release2) def test_nested_rule(self): rule1 = Rule.objects.create(name="Rule1", definition="result.value=101", enabled=True) diff --git a/backend/hct_mis_api/apps/targeting/fixtures.py b/backend/hct_mis_api/apps/targeting/fixtures.py index 4c4de2d0ba..fcc9e2a429 100644 --- a/backend/hct_mis_api/apps/targeting/fixtures.py +++ b/backend/hct_mis_api/apps/targeting/fixtures.py @@ -9,10 +9,10 @@ from hct_mis_api.apps.household.fixtures import HouseholdFactory from hct_mis_api.apps.household.models import RESIDENCE_STATUS_CHOICE from hct_mis_api.apps.targeting.models import ( - TargetPopulation, - TargetingCriteriaRuleFilter, - TargetingCriteriaRule, TargetingCriteria, + TargetingCriteriaRule, + TargetingCriteriaRuleFilter, + TargetPopulation, ) diff --git a/backend/hct_mis_api/apps/targeting/services/xlsx_export_targeting_service.py b/backend/hct_mis_api/apps/targeting/services/xlsx_export_targeting_service.py index 9cec95ddc7..da16b2af8f 100644 --- a/backend/hct_mis_api/apps/targeting/services/xlsx_export_targeting_service.py +++ b/backend/hct_mis_api/apps/targeting/services/xlsx_export_targeting_service.py @@ -1,11 +1,12 @@ from functools import cached_property -import openpyxl from django.db.models import Q + +import openpyxl from openpyxl.utils import get_column_letter from hct_mis_api.apps.core.utils import nested_getattr -from hct_mis_api.apps.household.models import Individual, Document +from hct_mis_api.apps.household.models import Document, Individual from hct_mis_api.apps.targeting.models import TargetPopulation diff --git a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_candidate_households_by_targeting_criteria_query.py b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_candidate_households_by_targeting_criteria_query.py index 0353622456..d140a23ed2 100644 --- a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_candidate_households_by_targeting_criteria_query.py +++ b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_candidate_households_by_targeting_criteria_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['CandidateListTargetingCriteriaQueryTestCase::test_candidate_households_list_by_targeting_criteria_approved_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_copy_target_population_mutation.py b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_copy_target_population_mutation.py index 663187d2ad..f98ddfe57b 100644 --- a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_copy_target_population_mutation.py +++ b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_copy_target_population_mutation.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestCopyTargetPopulationMutation::test_copy_empty_target_1_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_create_target_population_mutation.py b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_create_target_population_mutation.py index 1c565b6b0e..b2100601e1 100644 --- a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_create_target_population_mutation.py +++ b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_create_target_population_mutation.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestCreateTargetPopulationMutation::test_create_mutation_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_golden_record_by_targeting_criteria_query.py b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_golden_record_by_targeting_criteria_query.py index 19db18b146..56cbee8354 100644 --- a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_golden_record_by_targeting_criteria_query.py +++ b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_golden_record_by_targeting_criteria_query.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['GoldenRecordTargetingCriteriaQueryTestCase::test_golden_record_by_targeting_criteria_flex_field_0_with_permission 1'] = { diff --git a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_status_change_target_population_mutation.py b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_status_change_target_population_mutation.py index fec66fa334..a6975171ba 100644 --- a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_status_change_target_population_mutation.py +++ b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_status_change_target_population_mutation.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestUnapproveTargetPopulationMutation::test_unapprove_fail_target_population 1'] = { diff --git a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_update_target_population_mutation.py b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_update_target_population_mutation.py index 2ca1d4aec2..ea06fd3b59 100644 --- a/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_update_target_population_mutation.py +++ b/backend/hct_mis_api/apps/targeting/tests/snapshots/snap_test_update_target_population_mutation.py @@ -4,7 +4,6 @@ from snapshottest import Snapshot - snapshots = Snapshot() snapshots['TestUpdateTargetPopulationMutation::test_fail_update_0_wrong_args_count 1'] = { diff --git a/backend/hct_mis_api/apps/targeting/tests/test_create_target_population_mutation.py b/backend/hct_mis_api/apps/targeting/tests/test_create_target_population_mutation.py index 2d5d12f9b7..432dfedecc 100644 --- a/backend/hct_mis_api/apps/targeting/tests/test_create_target_population_mutation.py +++ b/backend/hct_mis_api/apps/targeting/tests/test_create_target_population_mutation.py @@ -1,4 +1,5 @@ from django.core.management import call_command + from parameterized import parameterized from hct_mis_api.apps.account.fixtures import UserFactory diff --git a/backend/hct_mis_api/apps/targeting/tests/test_golden_record_by_targeting_criteria_query.py b/backend/hct_mis_api/apps/targeting/tests/test_golden_record_by_targeting_criteria_query.py index 9a56af620c..0c203b1499 100644 --- a/backend/hct_mis_api/apps/targeting/tests/test_golden_record_by_targeting_criteria_query.py +++ b/backend/hct_mis_api/apps/targeting/tests/test_golden_record_by_targeting_criteria_query.py @@ -1,12 +1,13 @@ from django.core.management import call_command + from parameterized import parameterized +from hct_mis_api.apps.account.fixtures import UserFactory from hct_mis_api.apps.account.permissions import Permissions from hct_mis_api.apps.core.base_test_case import APITestCase from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.household.fixtures import create_household from hct_mis_api.apps.program.fixtures import ProgramFactory -from hct_mis_api.apps.account.fixtures import UserFactory class GoldenRecordTargetingCriteriaQueryTestCase(APITestCase): diff --git a/backend/hct_mis_api/apps/targeting/tests/test_individual_block_filters.py b/backend/hct_mis_api/apps/targeting/tests/test_individual_block_filters.py index 25cbe7b8e0..555c35ea1a 100644 --- a/backend/hct_mis_api/apps/targeting/tests/test_individual_block_filters.py +++ b/backend/hct_mis_api/apps/targeting/tests/test_individual_block_filters.py @@ -3,14 +3,14 @@ from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.household.fixtures import create_household_and_individuals -from hct_mis_api.apps.household.models import Household, MALE, FEMALE +from hct_mis_api.apps.household.models import FEMALE, MALE, Household from hct_mis_api.apps.targeting.models import ( TargetingCriteria, + TargetingCriteriaQueryingMixin, TargetingCriteriaRule, + TargetingCriteriaRuleQueryingMixin, TargetingIndividualBlockRuleFilter, TargetingIndividualRuleFilterBlock, - TargetingCriteriaQueryingMixin, - TargetingCriteriaRuleQueryingMixin, TargetingIndividualRuleFilterBlockMixin, ) diff --git a/backend/hct_mis_api/apps/targeting/views.py b/backend/hct_mis_api/apps/targeting/views.py index 3f18261afd..b4448d9421 100644 --- a/backend/hct_mis_api/apps/targeting/views.py +++ b/backend/hct_mis_api/apps/targeting/views.py @@ -3,10 +3,13 @@ from django.contrib.admin.views.decorators import staff_member_required from django.http import HttpResponse from django.shortcuts import get_object_or_404 + from openpyxl.writer.excel import save_virtual_workbook from hct_mis_api.apps.targeting.models import TargetPopulation -from hct_mis_api.apps.targeting.services.xlsx_export_targeting_service import XlsxExportTargetingService +from hct_mis_api.apps.targeting.services.xlsx_export_targeting_service import ( + XlsxExportTargetingService, +) logger = logging.getLogger(__name__) diff --git a/backend/hct_mis_api/apps/utils/mutations.py b/backend/hct_mis_api/apps/utils/mutations.py index 91824d64ce..ffe1d90b04 100644 --- a/backend/hct_mis_api/apps/utils/mutations.py +++ b/backend/hct_mis_api/apps/utils/mutations.py @@ -1,8 +1,9 @@ import logging -import graphene from django.core.exceptions import ValidationError +import graphene + from hct_mis_api.apps.utils.schema import Arg logger = logging.getLogger(__name__) diff --git a/backend/hct_mis_api/apps/utils/schema.py b/backend/hct_mis_api/apps/utils/schema.py index 547deec07a..c115bd5b12 100644 --- a/backend/hct_mis_api/apps/utils/schema.py +++ b/backend/hct_mis_api/apps/utils/schema.py @@ -1,7 +1,9 @@ -import graphene import logging + from django.core.files.storage import default_storage +import graphene + from hct_mis_api.apps.core.core_fields_attributes import TYPE_IMAGE from hct_mis_api.apps.core.models import FlexibleAttribute diff --git a/backend/hct_mis_api/apps/utils/validators.py b/backend/hct_mis_api/apps/utils/validators.py index 596f2b4612..c4dd9a7c66 100644 --- a/backend/hct_mis_api/apps/utils/validators.py +++ b/backend/hct_mis_api/apps/utils/validators.py @@ -1,7 +1,6 @@ from django.core.validators import RegexValidator from django.utils.translation import gettext_lazy as _ - DoubleSpaceValidator = RegexValidator( r"\s{2,}", _("Double spaces characters are not allowed."), diff --git a/backend/hct_mis_api/middlewares/version.py b/backend/hct_mis_api/middlewares/version.py index 83168141e7..a216d8406f 100644 --- a/backend/hct_mis_api/middlewares/version.py +++ b/backend/hct_mis_api/middlewares/version.py @@ -1,6 +1,7 @@ import sys from django.conf import settings + from sentry_sdk import configure_scope diff --git a/backend/hct_mis_api/schema.py b/backend/hct_mis_api/schema.py index d9f7f8812a..d3d850621e 100644 --- a/backend/hct_mis_api/schema.py +++ b/backend/hct_mis_api/schema.py @@ -1,31 +1,29 @@ import graphene - -# DO NOT DELETE THIS IMPORT -import hct_mis_api.apps.core.converters - from graphene_django.debug import DjangoDebug import hct_mis_api.apps.account.schema -import hct_mis_api.apps.core.schema +import hct_mis_api.apps.activity_log.schema -import hct_mis_api.apps.grievance.schema +# DO NOT DELETE THIS IMPORT +import hct_mis_api.apps.core.converters +import hct_mis_api.apps.core.schema import hct_mis_api.apps.grievance.mutations +import hct_mis_api.apps.grievance.schema import hct_mis_api.apps.household.schema import hct_mis_api.apps.payment.mutations import hct_mis_api.apps.payment.schema import hct_mis_api.apps.program.mutations import hct_mis_api.apps.program.schema import hct_mis_api.apps.registration_data.schema -import hct_mis_api.apps.registration_datahub.schema import hct_mis_api.apps.registration_datahub.mutations -import hct_mis_api.apps.reporting.schema +import hct_mis_api.apps.registration_datahub.schema import hct_mis_api.apps.reporting.mutations +import hct_mis_api.apps.reporting.schema import hct_mis_api.apps.sanction_list.mutations +import hct_mis_api.apps.sanction_list.schema +import hct_mis_api.apps.steficon.schema import hct_mis_api.apps.targeting.mutations import hct_mis_api.apps.targeting.schema -import hct_mis_api.apps.steficon.schema -import hct_mis_api.apps.sanction_list.schema -import hct_mis_api.apps.activity_log.schema class Query( diff --git a/backend/hct_mis_api/settings/base.py b/backend/hct_mis_api/settings/base.py index b7e170a22b..2f0de9d2e3 100644 --- a/backend/hct_mis_api/settings/base.py +++ b/backend/hct_mis_api/settings/base.py @@ -20,7 +20,7 @@ PROJECT_NAME = "hct_mis_api" # project root and add "apps" to the path -PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__)) from .config import env # domains/hosts etc.