Skip to content

Commit

Permalink
Update delinquent flag default value (#12)
Browse files Browse the repository at this point in the history
* Update delinquent flag default value

* Fix tests

* Fix comment
  • Loading branch information
bertini36 authored Jan 19, 2021
1 parent ad2d29d commit b63a968
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
18 changes: 18 additions & 0 deletions billing/migrations/0019_update_delinquent_flag_default_value.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
4 changes: 3 additions & 1 deletion billing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 2 additions & 0 deletions tests/actions/test_accounts_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b63a968

Please sign in to comment.