From b63a9685809c01f3798ecbf28c8db0f0be6863a4 Mon Sep 17 00:00:00 2001 From: Alberto Pou Date: Tue, 19 Jan 2021 09:33:10 +0100 Subject: [PATCH] Update delinquent flag default value (#12) * Update delinquent flag default value * Fix tests * Fix comment --- ...019_update_delinquent_flag_default_value.py | 18 ++++++++++++++++++ billing/models.py | 4 +++- tests/actions/test_accounts_actions.py | 2 ++ tests/test_views.py | 4 ++-- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 billing/migrations/0019_update_delinquent_flag_default_value.py diff --git a/billing/migrations/0019_update_delinquent_flag_default_value.py b/billing/migrations/0019_update_delinquent_flag_default_value.py new file mode 100644 index 0000000..1ac034d --- /dev/null +++ b/billing/migrations/0019_update_delinquent_flag_default_value.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.12 on 2021-01-19 08:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('billing', '0018_delinquent_flag_and_event_log_model'), + ] + + operations = [ + migrations.AlterField( + model_name='account', + name='delinquent', + field=models.BooleanField(db_index=True, default=True), + ), + ] diff --git a/billing/models.py b/billing/models.py index 47cfaf4..4934d4f 100644 --- a/billing/models.py +++ b/billing/models.py @@ -86,7 +86,9 @@ class Account(Model): owner = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='billing_account', on_delete=PROTECT) currency = CurrencyField(db_index=True) status = FSMField(max_length=20, choices=STATUS_CHOICES, default=OPEN, db_index=True) - delinquent = models.BooleanField(default=False, db_index=True) + # An account is marked as delinquent when it is registered then when the user + # registers a valid credit card it will be marked as compliant + delinquent = models.BooleanField(default=True, db_index=True) objects = AccountQuerySet.as_manager() diff --git a/tests/actions/test_accounts_actions.py b/tests/actions/test_accounts_actions.py index 443f089..c3e327b 100644 --- a/tests/actions/test_accounts_actions.py +++ b/tests/actions/test_accounts_actions.py @@ -17,6 +17,8 @@ class AccountActionsTest(TestCase): def setUp(self): user = User.objects.create_user('a-username') self.account = Account.objects.create(owner=user, currency='CHF') + self.account.delinquent = False + self.account.save() expiry_date = date.today() + timedelta(days=365) self.credit_card = CreditCard.objects.create( account=self.account, diff --git a/tests/test_views.py b/tests/test_views.py index 9288b88..a45644c 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -10,7 +10,7 @@ class AccountViewTest(TestCase): fixtures = ['tests/sample-data'] - def test_it_should_retrieve_user111s_account(self): + def test_it_should_retrieve_users_account(self): user111 = User.objects.get(id=111) client = APIClient() client.force_authenticate(user111) @@ -72,7 +72,7 @@ def test_it_should_retrieve_user111s_account(self): 'due': [] } ], - 'delinquent': False, + 'delinquent': True, } def test_it_should_retrieve_charge_product_attributes(self):