Skip to content

Commit

Permalink
Updated tests and migrations folders for Django 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
srugano committed Feb 4, 2022
1 parent 5ac1d9b commit c17fd4a
Show file tree
Hide file tree
Showing 130 changed files with 348 additions and 250 deletions.
3 changes: 2 additions & 1 deletion backend/hct_mis_api/apps/account/authentication.py
Original file line number Diff line number Diff line change
@@ -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__)
Expand Down
2 changes: 1 addition & 1 deletion backend/hct_mis_api/apps/account/tests/test_user_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions backend/hct_mis_api/apps/account/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 8 additions & 3 deletions backend/hct_mis_api/apps/activity_log/schema.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions backend/hct_mis_api/apps/cash_assist_datahub/celery_tasks.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions backend/hct_mis_api/apps/cash_assist_datahub/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_pull_data(self, mocker):


class TestSessionsPullDataFromDatahub(TestCase):
multi_db = True
databases = "__all__"

@classmethod
def setUpTestData(cls):
Expand Down
4 changes: 3 additions & 1 deletion backend/hct_mis_api/apps/core/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
5 changes: 3 additions & 2 deletions backend/hct_mis_api/apps/core/converters.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 3 additions & 2 deletions backend/hct_mis_api/apps/core/filters.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion backend/hct_mis_api/apps/core/management/commands/init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.management import call_command, BaseCommand
from django.core.management import BaseCommand, call_command


class Command(BaseCommand):
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
1 change: 1 addition & 0 deletions backend/hct_mis_api/apps/core/storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf import settings

from storages.backends.azure_storage import AzureStorage


Expand Down
17 changes: 9 additions & 8 deletions backend/hct_mis_api/apps/core/tests/test_exchange_rates.py
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 6 additions & 1 deletion backend/hct_mis_api/apps/core/tests/test_flexibles.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 3 additions & 2 deletions backend/hct_mis_api/apps/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion backend/hct_mis_api/apps/erp_datahub/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions backend/hct_mis_api/apps/erp_datahub/fixtures.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class TestSyncToMisDatahubTask(TestCase):
multi_db = True
databases = "__all__"
bosnia_and_herzegovina = None
bosnia = None
herzegovina = None
Expand Down
Loading

0 comments on commit c17fd4a

Please sign in to comment.