def handle(self, dry_run, delay, *args, **options): iteration = 0 while True: iteration += 1 account_tasks.check_notify_domain_expiring(dry_run=dry_run) back_tasks.sync_expired_domains(dry_run=dry_run) account_tasks.activations_cleanup() # TODO: other background periodical jobs to be placed here logger.info('finished iteration %d at %r', iteration, timezone.now().isoformat()) time.sleep(delay)
def handle(self, dry_run, delay, *args, **options): iteration = 0 while True: iteration += 1 logger.info('# %d', iteration) # billing_tasks.retry_failed_orders() back_tasks.sync_expired_domains(dry_run=dry_run) account_tasks.check_notify_domain_expiring( dry_run=dry_run, min_days_before_expire=0, max_days_before_expire=30, subject='domain_expire_soon', ) account_tasks.check_notify_domain_expiring( dry_run=dry_run, min_days_before_expire=31, max_days_before_expire=60, subject='domain_expiring', ) back_tasks.auto_renew_expiring_domains( dry_run=dry_run, min_days_before_expire=61, max_days_before_expire=90, ) account_tasks.activations_cleanup() # Remove all inactive domains. zdomains.remove_inactive_domains(days=1) # Remove started but not completed orders after a day. billing_tasks.remove_started_orders(older_than_days=365) # TODO: other background periodical jobs to be placed here time.sleep(delay)
def test_skip_not_active(self): tester = testsupport.prepare_tester_account() tester_domain = testsupport.prepare_tester_domain( domain_name='abcd.ai', tester=tester, domain_epp_id='aaa123', ) tester_domain.expiry_date = timezone.now() - datetime.timedelta(days=1) # already expired a day ago tester_domain.status = 'inactive' tester_domain.save() report = tasks.sync_expired_domains(dry_run=False) assert len(report) == 0
def test_ok(self, mock_domain_synchronize_from_backend): mock_domain_synchronize_from_backend.return_value = ['ok', ] tester = testsupport.prepare_tester_account() tester_domain = testsupport.prepare_tester_domain( domain_name='abcd.ai', tester=tester, domain_epp_id='aaa123', ) tester_domain.expiry_date = timezone.now() - datetime.timedelta(days=1) # already expired a day ago tester_domain.status = 'active' tester_domain.save() report = tasks.sync_expired_domains(dry_run=False) assert len(report) == 1 assert report[0] == (tester_domain, ['ok', ], )
def test_sync_expired_domains_dry_run(): tester = testsupport.prepare_tester_account() tester_domain = testsupport.prepare_tester_domain( domain_name='abcd.ai', tester=tester, domain_epp_id='aaa123', ) tester_domain.expiry_date = timezone.now() - datetime.timedelta( days=1) # already expired a day ago tester_domain.status = 'active' tester_domain.save() report = tasks.sync_expired_domains(dry_run=True) assert len(report) == 1 assert report[0] == ( tester_domain, [], )