forked from issa16/cogs3
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for Project.AP(); fix #152
- Loading branch information
Showing
5 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
"attribution_ptr": 1, | ||
"identifier": "scw0001", | ||
"pi_email": "[email protected]", | ||
"amount": 10000 | ||
"amount": 12000 | ||
} | ||
}, | ||
{ | ||
|
@@ -65,4 +65,4 @@ | |
"url": "https://cronfa.swansea.ac.uk/publication2" | ||
} | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from project.models import Project | ||
from funding.models import Attribution, FundingBody, FundingSource, Publication | ||
from institution.models import Institution | ||
from users.models import CustomUser | ||
|
||
|
||
class PriorityTests(TestCase): | ||
fixtures = [ | ||
'institution/fixtures/tests/institutions.json', | ||
'users/fixtures/tests/users.json', | ||
'funding/fixtures/tests/funding_bodies.json', | ||
'funding/fixtures/tests/attributions.json', | ||
'project/fixtures/tests/categories.json', | ||
'project/fixtures/tests/projects.json', | ||
'project/fixtures/tests/memberships.json', | ||
] | ||
|
||
|
||
class Priority_ProjectModelTests(PriorityTests): | ||
def setUp(self): | ||
self.project = Project.objects.get(code='scw0000') | ||
self.publication = Attribution.objects.get(title='Test publication') | ||
self.fundingsource = self.project.attributions.get().child | ||
self.tech_lead = self.project.tech_lead | ||
self.institution = self.tech_lead.profile.institution | ||
|
||
def test_AP_with_no_funding_approval(self): | ||
self.assertEqual(self.project.AP(), 62000) | ||
|
||
def test_AP_with_unapproved_funding(self): | ||
self.institution.needs_funding_approval = True | ||
self.assertEqual(self.project.AP(), 50000) | ||
|
||
def test_AP_with_approved_funding(self): | ||
self.institution.needs_funding_approval = True | ||
self.fundingsource.approved = True | ||
self.fundingsource.amount = 15000 | ||
self.fundingsource.save() | ||
self.assertEqual(self.project.AP(), 65000) | ||
|
||
def test_AP_with_publication(self): | ||
self.fundingsource.delete() | ||
self.project.attributions.add(self.publication) | ||
self.assertEqual(self.project.AP(), 60000) | ||
|
||
def test_AP_with_publication_and_fundingsource(self): | ||
self.project.attributions.add(self.publication) | ||
self.assertEqual(self.project.AP(), 72000) |