# Path: webpack/bundle.py
# class WebpackBundle(object):
#     def __init__(self, data, options=None):
#         self.data = data
#         self.options = options
# 
#     def render_css(self):
#         urls = []
#         for entry in self.get_urls().values():
#             urls += entry['css']
#         rendered = ['<link rel="stylesheet" href="{}">'.format(url) for url in urls]
#         return '\n'.join(rendered)
# 
#     def render_js(self):
#         urls = []
#         for entry in self.get_urls().values():
#             urls += entry['js']
#         rendered = ['<script src="{}"></script>'.format(url) for url in urls]
#         return '\n'.join(rendered)
# 
#     def get_assets(self):
#         return self.data['assets']
# 
#     def get_output(self):
#         return self.data['output']
# 
#     def get_urls(self):
#         return self.data['urls']
# 
#     def get_output_options(self):
#         return self.data['outputOptions']
# 
#     def get_library(self):
#         return self.get_output_options().get('library', None)
# 
# Path: webpack/compiler.py
# def webpack(config_file, context=None, settings=None, manifest=manifest_reader, compiler=build_server):
#     use_manifest = conf.settings.USE_MANIFEST
# 
#     # Allow the USE_MANIFEST setting to be overridden when populating the manifest
#     if settings:
#         use_manifest = settings.get('USE_MANIFEST', use_manifest)
# 
#     if use_manifest:
#         return manifest.read(config_file, context)
# 
#     return compiler.build(
#         config_file=config_file,
#         extra_context=context,
#         setting_overrides=settings,
#     )
# 
# Path: webpack/exceptions.py
# class ConfigFileNotFound(Exception):
#     pass
# 
# Path: webpack/conf.py
# class Conf(conf.Conf):
#     OUTPUT_ROOT = None
#     STATIC_URL = None
#     OUTPUT_DIR = 'webpack_assets'
#     CONFIG_DIRS = None
#     CONTEXT = None
#     BUILD_URL = 'http://127.0.0.1:9009/build'
#     WATCH = False
#     AGGREGATE_TIMEOUT = 200
#     POLL = None
#     HMR = False
#     CACHE = True
#     CACHE_DIR = None
#     MANIFEST = None
#     USE_MANIFEST = False
#     MANIFEST_PATH = None
#     MANIFEST_SETTINGS = {
#         # Force the compiler to connect to the build server
#         'USE_MANIFEST': False,
#         # Ensure that the server does not add a hmr runtime
#         'HMR': False,
#     }
#     def get_path_to_output_dir(self):
#     def get_public_path(self):
# 
# Path: tests/settings.py
# class ConfigFiles(object):
#     BASIC_CONFIG = os.path.join('basic', 'webpack.config.js')
#     LIBRARY_CONFIG = os.path.join('library', 'webpack.config.js')
#     MULTIPLE_BUNDLES_CONFIG = os.path.join('multiple_bundles', 'webpack.config.js')
#     MULTIPLE_ENTRY_CONFIG = os.path.join('multiple_entry', 'webpack.config.js')
#     CACHED_CONFIG = os.path.join('cached', 'webpack.config.js')
# 
# Path: tests/utils.py
# def clean_output_root():
#     # Clean out any files generated from previous test runs
#     if os.path.exists(settings.OUTPUT_ROOT):
#         shutil.rmtree(settings.OUTPUT_ROOT)
# 
# def read_file(file_name):
#     with open(file_name, 'r') as _file:
#         return _file.read()


import os
import unittest
from webpack.bundle import WebpackBundle
from webpack.compiler import webpack
from webpack.exceptions import ConfigFileNotFound
from webpack.conf import settings
from .settings import ConfigFiles
from .utils import clean_output_root, read_file
        self.assertEqual(asset, output)
        self.assertEqual(
            asset,
            os.path.join(
                settings.get_path_to_output_dir(),
                bundle.options['__python_webpack_hash__'],
                'bundle-{}.js'.format(bundle.data['stats']['hash'])
            )
        )
        self.assertTrue(os.path.exists(asset))
        self.assertEqual(
            bundle.get_urls()['main']['js'][0],
            (
                settings.STATIC_URL +
                settings.OUTPUT_DIR +
                '/' +
                bundle.options['__python_webpack_hash__'] +
                '/' +
                'bundle-{}.js'.format(bundle.data['stats']['hash'])
            ).replace('\\', '/'),
        )
        contents = read_file(asset)
        self.assertIn('__DJANGO_WEBPACK_ENTRY_TEST__', contents)
        self.assertIn('__DJANGO_WEBPACK_REQUIRE_TEST__', contents)

    def test_webpack_returns_webpack_bundle_instances(self):
        bundle = webpack(ConfigFiles.BASIC_CONFIG)
        self.assertIsInstance(bundle, WebpackBundle)

    def test_webpack_bundles_can_return_urls_to_assets(self):

# Path: webpack/bundle.py
# class WebpackBundle(object):
#     def __init__(self, data, options=None):
#         self.data = data
#         self.options = options
# 
#     def render_css(self):
#         urls = []
#         for entry in self.get_urls().values():
#             urls += entry['css']
#         rendered = ['<link rel="stylesheet" href="{}">'.format(url) for url in urls]
#         return '\n'.join(rendered)
# 
#     def render_js(self):
#         urls = []
#         for entry in self.get_urls().values():
#             urls += entry['js']
#         rendered = ['<script src="{}"></script>'.format(url) for url in urls]
#         return '\n'.join(rendered)
# 
#     def get_assets(self):
#         return self.data['assets']
# 
#     def get_output(self):
#         return self.data['output']
# 
#     def get_urls(self):
#         return self.data['urls']
# 
#     def get_output_options(self):
#         return self.data['outputOptions']
# 
#     def get_library(self):
#         return self.get_output_options().get('library', None)
# 
# Path: webpack/compiler.py
# def webpack(config_file, context=None, settings=None, manifest=manifest_reader, compiler=build_server):
#     use_manifest = conf.settings.USE_MANIFEST
# 
#     # Allow the USE_MANIFEST setting to be overridden when populating the manifest
#     if settings:
#         use_manifest = settings.get('USE_MANIFEST', use_manifest)
# 
#     if use_manifest:
#         return manifest.read(config_file, context)
# 
#     return compiler.build(
#         config_file=config_file,
#         extra_context=context,
#         setting_overrides=settings,
#     )
# 
# Path: webpack/exceptions.py
# class ConfigFileNotFound(Exception):
#     pass
# 
# Path: webpack/conf.py
# class Conf(conf.Conf):
#     OUTPUT_ROOT = None
#     STATIC_URL = None
#     OUTPUT_DIR = 'webpack_assets'
#     CONFIG_DIRS = None
#     CONTEXT = None
#     BUILD_URL = 'http://127.0.0.1:9009/build'
#     WATCH = False
#     AGGREGATE_TIMEOUT = 200
#     POLL = None
#     HMR = False
#     CACHE = True
#     CACHE_DIR = None
#     MANIFEST = None
#     USE_MANIFEST = False
#     MANIFEST_PATH = None
#     MANIFEST_SETTINGS = {
#         # Force the compiler to connect to the build server
#         'USE_MANIFEST': False,
#         # Ensure that the server does not add a hmr runtime
#         'HMR': False,
#     }
#     def get_path_to_output_dir(self):
#     def get_public_path(self):
# 
# Path: tests/settings.py
# class ConfigFiles(object):
#     BASIC_CONFIG = os.path.join('basic', 'webpack.config.js')
#     LIBRARY_CONFIG = os.path.join('library', 'webpack.config.js')
#     MULTIPLE_BUNDLES_CONFIG = os.path.join('multiple_bundles', 'webpack.config.js')
#     MULTIPLE_ENTRY_CONFIG = os.path.join('multiple_entry', 'webpack.config.js')
#     CACHED_CONFIG = os.path.join('cached', 'webpack.config.js')
# 
# Path: tests/utils.py
# def clean_output_root():
#     # Clean out any files generated from previous test runs
#     if os.path.exists(settings.OUTPUT_ROOT):
#         shutil.rmtree(settings.OUTPUT_ROOT)
# 
# def read_file(file_name):
#     with open(file_name, 'r') as _file:
#         return _file.read()


# Path: tests/test_bundles.py
import os
import unittest
from webpack.bundle import WebpackBundle
from webpack.compiler import webpack
from webpack.exceptions import ConfigFileNotFound
from webpack.conf import settings
from .settings import ConfigFiles
from .utils import clean_output_root, read_file

        self.assertEqual(asset, output)
        self.assertEqual(
            asset,
            os.path.join(
                settings.get_path_to_output_dir(),
                bundle.options['__python_webpack_hash__'],
                'bundle-{}.js'.format(bundle.data['stats']['hash'])
            )
        )
        self.assertTrue(os.path.exists(asset))
        self.assertEqual(
            bundle.get_urls()['main']['js'][0],
            (
                settings.STATIC_URL +
                settings.OUTPUT_DIR +
                '/' +
                bundle.options['__python_webpack_hash__'] +
                '/' +
                'bundle-{}.js'.format(bundle.data['stats']['hash'])
            ).replace('\\', '/'),
        )
        contents = read_file(asset)
        self.assertIn('__DJANGO_WEBPACK_ENTRY_TEST__', contents)
        self.assertIn('__DJANGO_WEBPACK_REQUIRE_TEST__', contents)

    def test_webpack_returns_webpack_bundle_instances(self):
        bundle = webpack(ConfigFiles.BASIC_CONFIG)
        self.assertIsInstance(bundle, WebpackBundle)

    def test_webpack_bundles_can_return_urls_to_assets(self):

        bundle = webpack(ConfigFiles.BASIC_CONFIG)