コード例 #1
0
 def test_config_get_new_datetime_for_delay_incremental(self):
     config = ErrorsHandleConfig(
         **{
             **self.normal_config,
             'retry_pause_strategy': const.DELAY_STRATEGY_INCREMENTAL,
         }
     )
     now = timezone.now().timestamp()
     new_date = config.get_new_datetime_for_retry(2)
     self.assertEqual(round(new_date.timestamp() - now), 10)
コード例 #2
0
 def test_config_get_new_datetime_for_delay_error(self):
     config = ErrorsHandleConfig(
         **{
             **self.normal_config,
             'retry_pause_strategy': const.DELAY_STRATEGY_INCREMENTAL,
         }
     )
     now = timezone.now().timestamp()
     with self.assertRaises(RuntimeError):
         new_date = config.get_new_datetime_for_retry(5)
コード例 #3
0
class ConfiguredFailingTestTaskProcessor(BaseTaskProcessor):
    RETRY_ON_ERROR_CONFIG = ErrorsHandleConfig(
        retry_on_errors=[
            ValueError,
        ],
        retries_count=5,
        retry_pause=0,
    )

    def run(self):
        raise ValueError()
コード例 #4
0
 def test_config_get_new_datetime_for_delay_constant(self):
     config = ErrorsHandleConfig(**self.normal_config)
     now = timezone.now().timestamp()
     new_date = config.get_new_datetime_for_retry(2)
     self.assertEqual(round(new_date.timestamp() - now), 5)
コード例 #5
0
 def test_config_should_be_retried(self):
     config = ErrorsHandleConfig(**self.normal_config)
     self.assertTrue(config.shoud_be_retried(1))
     self.assertFalse(config.shoud_be_retried(3))
コード例 #6
0
 def test_validation_bad_strategy(self):
     with self.assertRaises(ValueError):
         ErrorsHandleConfig(
             **{**self.normal_config, 'retry_pause_strategy': 'not strategy id'}
         )
コード例 #7
0
 def test_validation_negative_pause(self):
     with self.assertRaises(ValueError):
         ErrorsHandleConfig(**{**self.normal_config, 'retry_pause': -1})
コード例 #8
0
 def test_validation_zero_retries(self):
     with self.assertRaises(ValueError):
         ErrorsHandleConfig(**{**self.normal_config, 'retries_count': 0})
コード例 #9
0
 def test_validation_not_errors(self):
     with self.assertRaises(ValueError):
         ErrorsHandleConfig(
             **{**self.normal_config, 'retry_on_errors': ['not exception']}
         )