示例#1
0
    def test_delete_inactive_user(self, mock_logging):
        """
        Check if the account is removed as activation_code of the account is expired and the account is inactive
        and there is not any domain, balance or payment belongs to the account.
        """
        activations_cleanup()

        assert len(Account.objects.all()) == 0
        assert len(Activation.objects.all()) == 0
        mock_logging.assert_called_once()
示例#2
0
    def test_delete_expired_activation_code_of_active_account(self):
        """
        The account is active but activation code is still there after the expiring time.
        Check if the expired activation is removed but the account is still there.
        """
        self.account.is_active = True
        self.account.save()
        activations_cleanup()

        assert len(Activation.objects.all()) == 0

        accounts = Account.objects.all()
        assert len(accounts) == 1
        assert accounts[0].email == "*****@*****.**"
示例#3
0
    def test_do_not_delete_any_activation_code_or_account(self):
        """
        The activation code is not expired yet.
        Check if the activation and the account is still there.
        """
        self.activation.created_at = datetime.datetime.now()
        self.activation.save()
        activations_cleanup()

        assert len(Activation.objects.all()) == 1

        accounts = Account.objects.all()
        assert len(accounts) == 1
        assert accounts[0].email == "*****@*****.**"
示例#4
0
    def test_do_not_delete_inactive_user_with_balance(self):
        """
        The account is inactive but there is a balance in user's account.
        Check if the expired activation is removed but the account is still there.
        """

        self.account.balance = 100.0
        self.account.save()
        activations_cleanup()

        assert len(Activation.objects.all()) == 0

        accounts = Account.objects.all()
        assert len(accounts) == 1
        assert accounts[0].email == "*****@*****.**"
        assert accounts[0].balance == 100.0
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    def test_do_not_delete_inactive_user_with_domain(self):
        """
        The account is inactive but there is a domain belongs to the user.
        Check if the expired activation is removed but the account is still there.
        """
        Domain.domains.create(
            owner=self.account,
            name="test.ai",
            zone=Zone.zones.create(name="ai"),
        )
        activations_cleanup()

        assert len(Activation.objects.all()) == 0

        accounts = Account.objects.all()
        assert len(accounts) == 1
        assert accounts[0].email == "*****@*****.**"

        domains = accounts[0].domains.all()
        assert len(domains) == 1
        assert domains[0].name == "test.ai"
示例#8
0
    def test_do_not_delete_inactive_user_with_payment(self):
        """
        The account is inactive but there is a domain belongs to the user.
        Check if the expired activation is removed but the account is still there.
        """
        Payment.payments.create(
            owner=self.account,
            amount=100,
            method="pay_btcpay",
            transaction_id="12345",
            started_at=datetime.datetime(2019, 3, 23),
            status="paid",
        )
        activations_cleanup()

        assert len(Activation.objects.all()) == 0

        accounts = Account.objects.all()
        assert len(accounts) == 1
        assert accounts[0].email == "*****@*****.**"

        payments = accounts[0].payments.all()
        assert len(payments) == 1
        assert payments[0].transaction_id == "12345"