def _model_caller_wrapper(caller_class): if not issubclass(caller_class, ModelCaller): raise ValueError('Wrapped class must subclass ModelCaller.') site_model_callers.register(model, caller_class=caller_class) return caller_class
def test_locator_not_found_for_log(self): site_model_callers.reset_registry() site_model_callers.register(TestStartModel, LocatorTestModelCaller) TestStartModel.objects.create(subject_identifier='1111111') call = Call.objects.get( subject_identifier='1111111', call_status=NEW) log = Log.objects.get(call=call) self.assertEqual(log.locator_information, 'locator not found.')
def test_locator_as_string_for_log(self): site_model_callers.reset_registry() site_model_callers.register(TestStartModel, LocatorTestModelCaller) locator = Locator.objects.create( subject_identifier='1111111', home_visit_permission=YES, physical_address='Near General Dealer with black steel gate', may_follow_up=YES, subject_cell='723333333', may_call_work=NO, may_contact_someone=NO) TestStartModel.objects.create(subject_identifier='1111111') call = Call.objects.get( subject_identifier='1111111', call_status=NEW) log = Log.objects.get(call=call) self.assertEqual(log.locator_information, locator.to_string()) self.assertIn('723333333', log.locator_information)
def setUp(self): site_model_callers.reset_registry() site_model_callers.register(TestModel, TestModelCaller) site_model_callers.register(TestStartModel, RepeatingTestModelCaller) site_model_callers.register(TestRegisteredSubjectReferenceModel, RepeatingTestModelCaller)