Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Commit

Permalink
Add Chemistry to auto scored domains for Instructor Training Requests
Browse files Browse the repository at this point in the history
This fixes carpentries#1505. Tests were adjust.
  • Loading branch information
pbanaszkiewicz committed Sep 7, 2019
1 parent fb137ac commit 20aa75a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions amy/extrequests/tests/test_training_request.py
Expand Up @@ -148,10 +148,34 @@ def test_domains(self):
domains = KnowledgeDomain.objects.filter(name__in=[
'Humanities', 'Library and information science',
'Economics/business', 'Social sciences',
'Chemistry',
])
self.tr.domains.set(domains)
self.assertEqual(self.tr.score_auto, 1)

def test_each_domain(self):
"Ensure each domain from the list counts for +1 score_auto."
domain_names = [
'Humanities',
'Library and information science',
'Economics/business',
'Social sciences',
'Chemistry',
]

last_domain = None

for name in domain_names:
# we need to remove last domain added, but we can't use `.clear`
# because it doesn't trigger the m2m_changed signal
if last_domain:
self.tr.domains.remove(last_domain)

self.assertEqual(self.tr.score_auto, 0, name)
last_domain = KnowledgeDomain.objects.get(name=name)
self.tr.domains.add(last_domain)
self.assertEqual(self.tr.score_auto, 1, name)

def test_underrepresented(self):
"""With change in https://github.com/swcarpentry/amy/issues/1468,
we start automatically scoring underrepresented field."""
Expand Down
4 changes: 3 additions & 1 deletion amy/workshops/models.py
Expand Up @@ -1779,10 +1779,12 @@ def recalculate_score_auto(self):
if self.underresourced:
score += 1

# economics or social sciences, arts, humanities, or library science
# economics or social sciences, arts, humanities, library science, or
# chemistry
scoring_domains = [
'Humanities', 'Library and information science',
'Economics/business', 'Social sciences',
'Chemistry',
]
for domain in self.domains.all():
if domain.name in scoring_domains:
Expand Down

0 comments on commit 20aa75a

Please sign in to comment.