예제 #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)
예제 #2
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)
예제 #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])
예제 #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])