Esempio n. 1
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]))
Esempio n. 2
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)
Esempio n. 3
0
    def test_import_new_participant(self):
        PersonImporter.process_source_course('participant', self.course1,
                                             False, self.course2)

        self.assertEqual(self.course1.participants.count(), 2)
        self.assertEqual(set(self.course1.participants.all()),
                         set([self.participant1, self.participant2]))
Esempio n. 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]))
Esempio n. 5
0
    def test_import_existing_participant(self):
        success_messages, warnings, errors = PersonImporter.process_source_course(
            'participant',
            self.course1,
            test_run=True,
            source_course=self.course1)
        self.assertIn("0 participants would be added to the course",
                      "".join(success_messages))
        self.assertIn(
            "The following 1 user(s) are already course participants in course",
            warnings[ExcelImporter.W_GENERAL][0])

        success_messages, warnings, errors = PersonImporter.process_source_course(
            'participant',
            self.course1,
            test_run=False,
            source_course=self.course1)
        self.assertIn("0 participants added to the course",
                      "".join(success_messages))
        self.assertIn(
            "The following 1 user(s) are already course participants in course",
            warnings[ExcelImporter.W_GENERAL][0])

        self.assertEqual(self.course1.participants.count(), 1)
        self.assertEqual(self.course1.participants.get(), self.participant1)
Esempio n. 6
0
    def test_import_new_contributor(self):
        self.assertEqual(self.course1.contributions.count(), 2)

        success_messages, warnings, errors = PersonImporter.process_source_course(
            'contributor',
            self.course1,
            test_run=True,
            source_course=self.course2)
        self.assertIn("1 contributors would be added to the course",
                      "".join(success_messages))
        self.assertIn("{}".format(self.contributor2.full_name),
                      "".join(success_messages))

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

        success_messages, warnings, errors = PersonImporter.process_source_course(
            'contributor',
            self.course1,
            test_run=False,
            source_course=self.course2)
        self.assertIn("1 contributors added to the course",
                      "".join(success_messages))
        self.assertIn("{}".format(self.contributor2.full_name),
                      "".join(success_messages))

        self.assertEqual(self.course1.contributions.count(), 3)
        self.assertEqual(
            set(UserProfile.objects.filter(
                contributions__course=self.course1)),
            set([self.contributor1, self.contributor2]))
Esempio n. 7
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]),
        )
Esempio n. 8
0
    def test_import_existing_contributor(self):
        self.assertEqual(self.course1.contributions.count(), 2)
        PersonImporter.process_source_course('contributor', self.course1,
                                             False, self.course1)

        self.assertEqual(self.course1.contributions.count(), 2)
        self.assertEqual(
            set(UserProfile.objects.filter(
                contributions__course=self.course1)), set([self.contributor1]))
Esempio n. 9
0
    def test_import_new_participant(self):
        success_messages, warnings, errors = PersonImporter.process_source_course('participant', self.course1, test_run=True, source_course=self.course2)
        self.assertIn("1 participants would be added to the course", "".join(success_messages))
        self.assertIn("{}".format(self.participant2.full_name), "".join(success_messages))

        success_messages, warnings, errors = PersonImporter.process_source_course('participant', self.course1, test_run=False, source_course=self.course2)
        self.assertIn("1 participants added to the course", "".join(success_messages))
        self.assertIn("{}".format(self.participant2.full_name), "".join(success_messages))

        self.assertEqual(self.course1.participants.count(), 2)
        self.assertEqual(set(self.course1.participants.all()), set([self.participant1, self.participant2]))
Esempio n. 10
0
    def test_import_existing_participant(self):
        success_messages, warnings, errors = PersonImporter.process_source_course('participant', self.course1, test_run=True, source_course=self.course1)
        self.assertIn("0 participants would be added to the course", "".join(success_messages))
        self.assertIn("The following 1 user(s) are already course participants in course", warnings[ExcelImporter.W_GENERAL][0])

        success_messages, warnings, errors = PersonImporter.process_source_course('participant', self.course1, test_run=False, source_course=self.course1)
        self.assertIn("0 participants added to the course", "".join(success_messages))
        self.assertIn("The following 1 user(s) are already course participants in course", warnings[ExcelImporter.W_GENERAL][0])

        self.assertEqual(self.course1.participants.count(), 1)
        self.assertEqual(self.course1.participants.get(), self.participant1)
Esempio n. 11
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]))
Esempio n. 12
0
    def test_import_existing_contributor(self):
        self.assertEqual(self.course1.contributions.count(), 2)

        success_messages, warnings, errors = PersonImporter.process_source_course('contributor', self.course1, test_run=True, source_course=self.course1)
        self.assertIn("0 contributors would be added to the course", "".join(success_messages))
        self.assertIn("The following 1 user(s) are already contributing to course", warnings[ExcelImporter.W_GENERAL][0])

        success_messages, warnings, errors = PersonImporter.process_source_course('contributor', self.course1, test_run=False, source_course=self.course1)
        self.assertIn("0 contributors added to the course", "".join(success_messages))
        self.assertIn("The following 1 user(s) are already contributing to course", warnings[ExcelImporter.W_GENERAL][0])

        self.assertEqual(self.course1.contributions.count(), 2)
        self.assertEqual(set(UserProfile.objects.filter(contributions__course=self.course1)), set([self.contributor1]))
Esempio n. 13
0
    def test_import_new_contributor(self):
        self.assertEqual(self.course1.contributions.count(), 2)

        success_messages, warnings, errors = PersonImporter.process_source_course('contributor', self.course1, test_run=True, source_course=self.course2)
        self.assertIn("1 contributors would be added to the course", "".join(success_messages))
        self.assertIn("{}".format(self.contributor2.full_name), "".join(success_messages))

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

        success_messages, warnings, errors = PersonImporter.process_source_course('contributor', self.course1, test_run=False, source_course=self.course2)
        self.assertIn("1 contributors added to the course", "".join(success_messages))
        self.assertIn("{}".format(self.contributor2.full_name), "".join(success_messages))

        self.assertEqual(self.course1.contributions.count(), 3)
        self.assertEqual(set(UserProfile.objects.filter(contributions__course=self.course1)), set([self.contributor1, self.contributor2]))
Esempio n. 14
0
    def test_import_new_participant(self):
        success_messages, warnings, errors = PersonImporter.process_source_course(
            'participant',
            self.course1,
            test_run=True,
            source_course=self.course2)
        self.assertIn("1 participants would be added to the course",
                      "".join(success_messages))
        self.assertIn("{}".format(self.participant2.full_name),
                      "".join(success_messages))

        success_messages, warnings, errors = PersonImporter.process_source_course(
            'participant',
            self.course1,
            test_run=False,
            source_course=self.course2)
        self.assertIn("1 participants added to the course",
                      "".join(success_messages))
        self.assertIn("{}".format(self.participant2.full_name),
                      "".join(success_messages))

        self.assertEqual(self.course1.participants.count(), 2)
        self.assertEqual(set(self.course1.participants.all()),
                         set([self.participant1, self.participant2]))
Esempio n. 15
0
    def test_import_existing_participant(self):
        PersonImporter.process_source_course('participant', self.course1,
                                             False, self.course1)

        self.assertEqual(self.course1.participants.count(), 1)
        self.assertEqual(self.course1.participants.get(), self.participant1)