Exemplo n.º 1
0
    def test_the_manifest_can_be_populated_from_a_dictionary(self):
        path = os.path.join(STATIC_ROOT, 'test_populate_dict_manifest_file.json')

        mock_settings = Conf()
        mock_settings.configure(
            **dict(
                WEBPACK,
                USE_MANIFEST=True,
                MANIFEST_PATH=path,
                MANIFEST={
                    ConfigFiles.BASIC_CONFIG: (),
                }
            )
        )

        with mock.patch('webpack.conf.settings', mock_settings):
            populate_manifest_file()

            with open(path, 'r') as manifest_file:
                content = manifest_file.read()
            manifest = json.loads(content)

            expected = generate_manifest({
                ConfigFiles.BASIC_CONFIG: (),
            })

            self.assertEqual(manifest, expected)
Exemplo n.º 2
0
    def test_the_manifest_can_be_populated_from_settings(self):
        path = os.path.join(STATIC_ROOT, 'test_populate_manifest_file.json')

        mock_settings = Conf()
        mock_settings.configure(**dict(WEBPACK,
                                       USE_MANIFEST=True,
                                       MANIFEST_PATH=path,
                                       MANIFEST=(ConfigFiles.BASIC_CONFIG, )))

        with mock.patch('webpack.conf.settings', mock_settings):
            populate_manifest_file()

            with open(path, 'r') as manifest_file:
                content = manifest_file.read()
            manifest = json.loads(content)

            expected = generate_manifest((ConfigFiles.BASIC_CONFIG, ))

            self.assertEqual(manifest, expected)
Exemplo n.º 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])
Exemplo n.º 4
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])