Example #1
0
    def test_export_import(self):
        """
        Test export then import.
        """
        bundle = XBundle()
        cxmls = input_data.COURSE

        pxmls = input_data.POLICIES

        bundle.set_course(etree.XML(cxmls))
        bundle.add_policies(etree.XML(pxmls))
        bundle.add_about_file("overview.html", "hello overview")

        xbin = str(bundle)

        tdir = mkdtemp()
        try:
            bundle.export_to_directory(tdir)

            # Test round- trip.
            xb2 = XBundle()
            xb2.import_from_directory(os.path.join(tdir, 'mitx.01'))

            xbreloaded = str(xb2)

            self.assertEqual(clean_xml(xbin), clean_xml(xbreloaded))
        finally:
            rmtree(tdir)
Example #2
0
    def test_export_import(self):
        """
        Test export then import.
        """
        bundle = XBundle()
        cxmls = input_data.COURSE

        pxmls = input_data.POLICIES

        bundle.set_course(etree.XML(cxmls))
        bundle.add_policies(etree.XML(pxmls))
        bundle.add_about_file("overview.html", "hello overview")

        xbin = str(bundle)

        tdir = mkdtemp()
        try:
            bundle.export_to_directory(tdir)

            # Test round- trip.
            xb2 = XBundle()
            xb2.import_from_directory(os.path.join(tdir, 'mitx.01'))

            xbreloaded = str(xb2)

            self.assertEqual(clean_xml(xbin), clean_xml(xbreloaded))
        finally:
            rmtree(tdir)
Example #3
0
    def test_unicode_in_html(self):
        """
        Test that unicode doesn't cause problems in overview file.
        """
        bundle = XBundle()
        bundle.import_from_directory(os.path.join("input_testdata", "mitx.01"))
        bundle.add_about_file("overview.html", "\u2e18 interrobang \u203d")

        expected = expected_data.ESCAPED_UNICODE
        self.assertEqual(clean_xml(str(bundle)), clean_xml(expected))

        # Reimport to start from a clean slate. This time use bytes.
        bundle = XBundle()
        bundle.import_from_directory(os.path.join("input_testdata", "mitx.01"))

        bundle.add_about_file("overview.html",
                              "\u2e18 interrobang \u203d".encode('utf-8'))
        self.assertEqual(clean_xml(str(bundle)), clean_xml(expected))
Example #4
0
    def test_unicode_in_html(self):
        """
        Test that unicode doesn't cause problems in overview file.
        """
        bundle = XBundle()
        bundle.import_from_directory(os.path.join("input_testdata", "mitx.01"))
        bundle.add_about_file("overview.html",
                              "\u2e18 interrobang \u203d")

        expected = expected_data.ESCAPED_UNICODE
        self.assertEqual(clean_xml(str(bundle)), clean_xml(expected))

        # Reimport to start from a clean slate. This time use bytes.
        bundle = XBundle()
        bundle.import_from_directory(os.path.join("input_testdata", "mitx.01"))

        bundle.add_about_file(
            "overview.html", "\u2e18 interrobang \u203d".encode('utf-8'))
        self.assertEqual(clean_xml(str(bundle)), clean_xml(expected))