Example #1
0
    def test_valid_data(self):
        test_resources = """\
            content_key|parent_content_key|title|resource_type
            1||Parent page|resource/x-bb-document
            2|1|Child page|resource/x-bb-document
        """

        importer = BlackboardImport('ignore.zip', self.offering)

        csv_data = io.StringIO(dedent(test_resources))
        resources_data = csv.DictReader(csv_data, delimiter='|')
        importer._process_resources(resources_data)

        self.assertTrue(
            Page.objects.filter(content_id=1,
                                parent__isnull=True,
                                title='Parent page',
                                content_type='resource/x-bb-document',
                                is_forum=False,
                                course_offering=self.offering).exists())
        self.assertTrue(
            Page.objects.filter(content_id=2,
                                parent__isnull=True,
                                title='Child page',
                                content_type='resource/x-bb-document',
                                is_forum=False,
                                course_offering=self.offering).exists())
Example #2
0
    def test_invalid_column_names(self):
        test_resources = """\
            content_key|parent_content_key|invalid_col
            1|2|value
        """

        csv_data = io.StringIO(dedent(test_resources))
        resources_data = csv.DictReader(csv_data, delimiter='|')

        importer = BlackboardImport('ignore.zip', self.offering)

        with self.assertRaises(LMSImportFileError):
            importer._process_resources(resources_data)