ref #711
Showing 2 of 2 files from the diff.
mep/accounts/models.py
changed.
@@ -695,11 +695,26 @@
Loading
695 | 695 | # creating new subscription for same account & date should error |
|
696 | 696 | with pytest.raises(ValidationError): |
|
697 | 697 | subscr = Subscription(account=self.account, |
|
698 | - | start_date=self.subscription.start_date) |
|
698 | + | start_date=self.subscription.start_date) |
|
699 | 699 | subscr.validate_unique() |
|
700 | 700 | ||
701 | - | # same account + date with different subtype should be fine |
|
701 | + | # creating new subscription for same account with same |
|
702 | + | # start date AND end date should error |
|
703 | + | with pytest.raises(ValidationError): |
|
704 | + | subscr = Subscription(account=self.account, |
|
705 | + | start_date=self.subscription.start_date, |
|
706 | + | end_date=self.subscription.end_date) |
|
707 | + | subscr.validate_unique() |
|
708 | + | ||
709 | + | # same account, type, start date but different end date is valid |
|
702 | 710 | subscr = Subscription(account=self.account, |
|
711 | + | start_date=self.subscription.start_date, |
|
712 | + | end_date=datetime.date(1931, 3, 6)) |
|
713 | + | subscr.validate_unique() |
|
714 | + | ||
715 | + | # same account + date with different subtype should be fine |
|
716 | + | subscr = Subscription( |
|
717 | + | account=self.account, |
|
703 | 718 | start_date=self.subscription.start_date, subtype='ren') |
|
704 | 719 | subscr.validate_unique() |
|
705 | 720 |
@@ -464,7 +464,8 @@
Loading
464 | 464 | # (can't use unique_together because of multi-table inheritance) |
|
465 | 465 | ||
466 | 466 | # adapted from https://stackoverflow.com/questions/7366363/adding-custom-django-model-validation |
|
467 | - | qs = Subscription.objects.filter(start_date=self.start_date, |
|
467 | + | qs = Subscription.objects.filter( |
|
468 | + | start_date=self.start_date, end_date=self.end_date, |
|
468 | 469 | account=self.account, subtype=self.subtype) |
|
469 | 470 | ||
470 | 471 | # if current work is already saved, exclude it from the queryset |
Files | Coverage |
---|---|
mep | 98.44% |
srcmedia/ts | 86.55% |
Project Totals (223 files) | 98.01% |
2528.1
TRAVIS_PYTHON_VERSION=3.5 TRAVIS_OS_NAME=linux
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.