示例#1
0
    def test_a_manifest_can_be_written_to_and_read_from_disk(self):
        manifest = generate_manifest({
            ConfigFiles.BASIC_CONFIG: ({
                'foo': 'bar'
            }, ),
            ConfigFiles.LIBRARY_CONFIG: (
                {
                    'foo': 'bar'
                },
                {
                    'woz': 'woo'
                },
            ),
        })

        path = os.path.join(STATIC_ROOT, 'foo.json')

        write_manifest(path, manifest)

        # Manual check
        with open(path, 'r') as manifest_file:
            content = manifest_file.read()
        self.assertEqual(json.loads(content), manifest)

        # Convenience check
        self.assertEqual(read_manifest(path), manifest)
    def test_a_manifest_can_be_written_to_and_read_from_disk(self):
        manifest = generate_manifest({
            ConfigFiles.BASIC_CONFIG: (
                {'foo': 'bar'},
            ),
            ConfigFiles.LIBRARY_CONFIG: (
                {'foo': 'bar'},
                {'woz': 'woo'},
            ),
        })

        path = os.path.join(STATIC_ROOT, 'foo.json')

        write_manifest(path, manifest)

        # Manual check
        with open(path, 'r') as manifest_file:
            content = manifest_file.read()
        self.assertEqual(json.loads(content), manifest)

        # Convenience check
        self.assertEqual(read_manifest(path), manifest)
示例#3
0
    def test_the_manifest_is_used_by_the_compiler(self):
        manifest = generate_manifest({
            ConfigFiles.BASIC_CONFIG: (),
        })
        key = generate_key(ConfigFiles.BASIC_CONFIG)
        self.assertIn(key, manifest)

        path = os.path.join(STATIC_ROOT, 'test_manifest.json')
        write_manifest(path, manifest)

        with mock.patch('webpack.compiler.build_server.build',
                        self._raise_if_called):
            mock_settings = Conf()
            mock_settings.configure(**dict(
                WEBPACK,
                USE_MANIFEST=True,
                MANIFEST_PATH=path,
            ))

            with mock.patch('webpack.conf.settings', mock_settings):
                bundle = webpack(ConfigFiles.BASIC_CONFIG)
                self.assertEqual(bundle.data, manifest[key])
    def test_the_manifest_is_used_by_the_compiler(self):
        manifest = generate_manifest({
            ConfigFiles.BASIC_CONFIG: (),
        })
        key = generate_key(ConfigFiles.BASIC_CONFIG)
        self.assertIn(key, manifest)

        path = os.path.join(STATIC_ROOT, 'test_manifest.json')
        write_manifest(path, manifest)

        with mock.patch('webpack.compiler.build_server.build', self._raise_if_called):
            mock_settings = Conf()
            mock_settings.configure(
                **dict(
                    WEBPACK,
                    USE_MANIFEST=True,
                    MANIFEST_PATH=path,
                )
            )

            with mock.patch('webpack.conf.settings', mock_settings):
                bundle = webpack(ConfigFiles.BASIC_CONFIG)
                self.assertEqual(bundle.data, manifest[key])