Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backward-compatible Django 2.2 updates (part 2) #28126

Merged
merged 4 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions corehq/apps/dump_reload/tests/test_sql_dump_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from django.core import serializers
from django.db.models.signals import post_delete, post_save
from django.test import TestCase
from django.test.utils import override_settings

from nose.plugins.attrib import attr

from casexml.apps.case.mock import CaseFactory, CaseIndex, CaseStructure

Expand Down Expand Up @@ -48,6 +45,7 @@
from corehq.form_processor.tests.utils import (
FormProcessorTestUtils,
create_form_for_test,
use_sql_backend,
)
from corehq.messaging.scheduling.scheduling_partitioned.models import AlertScheduleInstance

Expand Down Expand Up @@ -140,8 +138,7 @@ def _check_signals_handle_raw(self, models):
self.assertIn('raw', args, message)


@attr(sql_backend=True)
@override_settings(TESTS_SHOULD_USE_SQL_BACKEND=True)
@use_sql_backend
class TestSQLDumpLoadShardedModels(BaseDumpLoadTest):
maxDiff = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,10 @@ def __init__(self, fileobj):
def __getattr__(self, name):
return getattr(self.fileobj, name)

def open(self, *args, **kw):
# compatible with django.core.files.base.File.open()
obj = self.fileobj.open(*args, **kw)
return self if obj is self.fileobj else obj

def close(self):
pass
1 change: 1 addition & 0 deletions corehq/form_processor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def open(self):
return BytesIO(self.content)
fileobj = self.raw_content.open()

# TODO remove when Django 1 is no longer supported
if fileobj is None:
assert not isinstance(self.raw_content, BlobMeta), repr(self)
# work around Django 1.11 bug, fixed in 2.0
Expand Down
4 changes: 2 additions & 2 deletions corehq/sql_db/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def get_django_shard_map(self):
def from_settings(cls):
assert settings.USE_PARTITIONED_DATABASE
return (
PlProxyConfig.from_dict(settings.DATABASES) or
PlProxyConfig.from_legacy_dict(getattr(settings, 'PARTITION_DATABASE_CONFIG'))
PlProxyConfig.from_dict(settings.DATABASES)
or PlProxyConfig.from_legacy_dict(settings.PARTITION_DATABASE_CONFIG)
)

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def today(cls):


class TestAWCReport(TestCase):
maxDiff = None

def test_beneficiary_details_recorded_weight_none(self):
data = get_beneficiary_details(
case_id='6b234c5b-883c-4849-9dfd-b1571af8717b',
Expand Down