Skip to content

Commit

Permalink
Create + unregister non-abstract models for tests
Browse files Browse the repository at this point in the history
Prevents other test failures:
- corehq.apps.domain.tests.test_deletion_models:test_deletion_sql_models
  AssertionError: Not all Django models are covered by domain deletion.
- corehq.sql_db.tests.test_model_partitioning:TestPartitionedModelsWithMultipleDBs.test_models_are_located_in_correct_dbs('scheduling', False)
  UndefinedTable: relation "scheduling_content" does not exist
  • Loading branch information
millerdev committed Mar 24, 2022
1 parent 4958353 commit ea91b87
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
21 changes: 13 additions & 8 deletions corehq/messaging/scheduling/tests/test_content.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest.mock import Mock

from django.apps import apps
from django.test import TestCase, override_settings

from corehq.apps.domain.shortcuts import create_domain
Expand Down Expand Up @@ -45,6 +46,18 @@ def setUpClass(cls):
cls.sms_translations.set_translations('es', {})
cls.sms_translations.save()

global Content, Schedule

class Content(AbstractContent):
pass

class Schedule(AbstractSchedule):
pass

# unregister test models to prevent other test failures
del apps.get_app_config("scheduling").models["content"]
del apps.get_app_config("scheduling").models["schedule"]

@classmethod
def tearDownClass(cls):
cls.sms_translations.delete()
Expand Down Expand Up @@ -210,11 +223,3 @@ def test_sms_language_fallback(self):
content.get_translation_from_message_dict(self.domain_obj, message_dict, user_lang),
message_dict['*']
)


class Content(AbstractContent):
pass


class Schedule(AbstractSchedule):
pass
13 changes: 9 additions & 4 deletions corehq/messaging/scheduling/tests/test_recipients.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid
from datetime import time

from django.apps import apps
from django.test import TestCase, override_settings

from unittest.mock import patch
Expand Down Expand Up @@ -128,6 +129,14 @@ def setUpClass(cls):
cls.process_pillow_changes = process_pillow_changes('DefaultChangeFeedPillow')
cls.process_pillow_changes.add_pillow(get_case_messaging_sync_pillow())

global ScheduleInstance

class ScheduleInstance(AbstractScheduleInstance):
pass

# unregister test model to prevent other test failures
del apps.get_app_config("scheduling").models["scheduleinstance"]

@classmethod
def tearDownClass(cls):
cls.domain_obj.delete()
Expand Down Expand Up @@ -844,7 +853,3 @@ def test_phone_number_preference(self):
self.assertPhoneEntryCount(3)
self.assertPhoneEntryCount(1, only_count_two_way=True)
self.assertTwoWayEntry(Content.get_two_way_entry_or_phone_number(user), '23456')


class ScheduleInstance(AbstractScheduleInstance):
pass

0 comments on commit ea91b87

Please sign in to comment.