Example #1
0
 def test_fixup(self):
     with patch('celery.fixups.django.DjangoFixup') as Fixup:
         with patch.dict(os.environ, DJANGO_SETTINGS_MODULE=''):
             fixup(self.app)
             self.assertFalse(Fixup.called)
         with patch.dict(os.environ, DJANGO_SETTINGS_MODULE='settings'):
             with mock.mask_modules('django'):
                 with self.assertWarnsRegex(UserWarning, 'but Django is'):
                     fixup(self.app)
                     self.assertFalse(Fixup.called)
             with mock.patch_modules('django'):
                 fixup(self.app)
                 self.assertTrue(Fixup.called)
Example #2
0
 def test_oracle_errors(self):
     with mock.patch_modules('cx_Oracle'):
         import cx_Oracle as mod
         mod.DatabaseError = Mock()
         mod.InterfaceError = Mock()
         mod.OperationalError = Mock()
         with self.fixup_context(self.app) as (f, _, _):
             self.assertIn(mod.DatabaseError, f.database_errors)
             self.assertIn(mod.InterfaceError, f.database_errors)
             self.assertIn(mod.OperationalError, f.database_errors)
     with mock.mask_modules('cx_Oracle'):
         with self.fixup_context(self.app):
             pass