Example #1
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)
Example #2
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]))
Example #3
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]))
Example #4
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]))
Example #5
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]))
Example #6
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]))
Example #7
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)
Example #8
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]))
Example #9
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]))
Example #10
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]))
Example #11
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)