From 20aa75af801179f2df19dc0255f183802736eb66 Mon Sep 17 00:00:00 2001 From: Piotr Banaszkiewicz Date: Sat, 7 Sep 2019 22:31:12 +0200 Subject: [PATCH] Add Chemistry to auto scored domains for Instructor Training Requests This fixes #1505. Tests were adjust. --- .../tests/test_training_request.py | 24 +++++++++++++++++++ amy/workshops/models.py | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/amy/extrequests/tests/test_training_request.py b/amy/extrequests/tests/test_training_request.py index 2d0d35eb1..27b85ed14 100644 --- a/amy/extrequests/tests/test_training_request.py +++ b/amy/extrequests/tests/test_training_request.py @@ -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.""" diff --git a/amy/workshops/models.py b/amy/workshops/models.py index 566db415b..1951fb01e 100644 --- a/amy/workshops/models.py +++ b/amy/workshops/models.py @@ -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: