Example #1
0
    def test_import_existing_participant(self):
        success_messages, warnings, __ = PersonImporter.process_source_evaluation(
            'participant',
            self.evaluation1,
            test_run=True,
            source_evaluation=self.evaluation1)
        self.assertIn("0 participants would be added to the evaluation",
                      "".join(success_messages))
        self.assertIn(
            "The following 1 user(s) are already participants in evaluation",
            warnings[ExcelImporter.W_GENERAL][0])

        success_messages, warnings, __ = PersonImporter.process_source_evaluation(
            'participant',
            self.evaluation1,
            test_run=False,
            source_evaluation=self.evaluation1)
        self.assertIn("0 participants added to the evaluation",
                      "".join(success_messages))
        self.assertIn(
            "The following 1 user(s) are already participants in evaluation",
            warnings[ExcelImporter.W_GENERAL][0])

        self.assertEqual(self.evaluation1.participants.count(), 1)
        self.assertEqual(self.evaluation1.participants.get(),
                         self.participant1)
Example #2
0
    def test_import_new_contributor(self):
        self.assertEqual(self.evaluation1.contributions.count(), 2)

        success_messages, __, __ = PersonImporter.process_source_evaluation(
            'contributor',
            self.evaluation1,
            test_run=True,
            source_evaluation=self.evaluation2)
        self.assertIn("1 contributors would be added to the evaluation",
                      "".join(success_messages))
        self.assertIn("{}".format(self.contributor2.full_name),
                      "".join(success_messages))

        self.assertEqual(self.evaluation1.contributions.count(), 2)

        success_messages, __, __ = PersonImporter.process_source_evaluation(
            'contributor',
            self.evaluation1,
            test_run=False,
            source_evaluation=self.evaluation2)
        self.assertIn("1 contributors added to the evaluation",
                      "".join(success_messages))
        self.assertIn("{}".format(self.contributor2.full_name),
                      "".join(success_messages))

        self.assertEqual(self.evaluation1.contributions.count(), 3)
        self.assertEqual(
            set(
                UserProfile.objects.filter(
                    contributions__evaluation=self.evaluation1)),
            set([self.contributor1, self.contributor2]))
Example #3
0
    def test_import_new_contributor(self):
        self.assertEqual(self.evaluation1.contributions.count(), 2)

        success_messages, __, __ = PersonImporter.process_source_evaluation(
            ImportType.CONTRIBUTOR,
            self.evaluation1,
            test_run=True,
            source_evaluation=self.evaluation2)
        self.assertIn("1 contributors would be added to the evaluation",
                      "".join(success_messages))
        self.assertIn(f"{self.contributor2.email}", "".join(success_messages))

        self.assertEqual(self.evaluation1.contributions.count(), 2)

        success_messages, __, __ = PersonImporter.process_source_evaluation(
            ImportType.CONTRIBUTOR,
            self.evaluation1,
            test_run=False,
            source_evaluation=self.evaluation2)
        self.assertIn("1 contributors added to the evaluation",
                      "".join(success_messages))
        self.assertIn(f"{self.contributor2.email}", "".join(success_messages))

        self.assertEqual(self.evaluation1.contributions.count(), 3)
        self.assertEqual(
            set(
                UserProfile.objects.filter(
                    contributions__evaluation=self.evaluation1)),
            set([self.contributor1, self.contributor2]),
        )
Example #4
0
    def test_import_existing_contributor(self):
        self.assertEqual(self.evaluation1.contributions.count(), 2)

        success_messages, warnings, __ = PersonImporter.process_source_evaluation(
            'contributor',
            self.evaluation1,
            test_run=True,
            source_evaluation=self.evaluation1)
        self.assertIn("0 contributors would be added to the evaluation",
                      "".join(success_messages))
        self.assertIn(
            "The following 1 user(s) are already contributing to evaluation",
            warnings[ExcelImporter.W_GENERAL][0])

        success_messages, warnings, __ = PersonImporter.process_source_evaluation(
            'contributor',
            self.evaluation1,
            test_run=False,
            source_evaluation=self.evaluation1)
        self.assertIn("0 contributors added to the evaluation",
                      "".join(success_messages))
        self.assertIn(
            "The following 1 user(s) are already contributing to evaluation",
            warnings[ExcelImporter.W_GENERAL][0])

        self.assertEqual(self.evaluation1.contributions.count(), 2)
        self.assertEqual(
            set(
                UserProfile.objects.filter(
                    contributions__evaluation=self.evaluation1)),
            set([self.contributor1]))
Example #5
0
    def test_import_new_participant(self):
        success_messages, __, __ = PersonImporter.process_source_evaluation('participant', self.evaluation1, test_run=True, source_evaluation=self.evaluation2)
        self.assertIn("1 participants would be added to the evaluation", "".join(success_messages))
        self.assertIn("{}".format(self.participant2.email), "".join(success_messages))

        success_messages, __, __ = PersonImporter.process_source_evaluation('participant', self.evaluation1, test_run=False, source_evaluation=self.evaluation2)
        self.assertIn("1 participants added to the evaluation", "".join(success_messages))
        self.assertIn("{}".format(self.participant2.email), "".join(success_messages))

        self.assertEqual(self.evaluation1.participants.count(), 2)
        self.assertEqual(set(self.evaluation1.participants.all()), set([self.participant1, self.participant2]))