|  | 
| 13 | 13 | from webpack_loader.exceptions import ( | 
| 14 | 14 |  WebpackError, | 
| 15 | 15 |  WebpackLoaderBadStatsError, | 
| 16 |  | - WebpackLoaderTimeoutError | 
|  | 16 | + WebpackLoaderTimeoutError, | 
|  | 17 | + WebpackBundleLookupError | 
| 17 | 18 | ) | 
| 18 | 19 | from webpack_loader.utils import get_loader | 
| 19 | 20 | 
 | 
| @@ -66,6 +67,20 @@ def test_simple_and_css_extract(self): | 
| 66 | 67 |  self.assertEqual(main[0]['path'], os.path.join(settings.BASE_DIR, 'assets/bundles/main.js')) | 
| 67 | 68 |  self.assertEqual(main[1]['path'], os.path.join(settings.BASE_DIR, 'assets/bundles/styles.css')) | 
| 68 | 69 | 
 | 
|  | 70 | + def test_js_gzip_extract(self): | 
|  | 71 | + self.compile_bundles('webpack.config.gzipTest.js') | 
|  | 72 | + assets = get_loader(DEFAULT_CONFIG).get_assets() | 
|  | 73 | + self.assertEqual(assets['status'], 'done') | 
|  | 74 | + self.assertIn('chunks', assets) | 
|  | 75 | + | 
|  | 76 | + chunks = assets['chunks'] | 
|  | 77 | + self.assertIn('main', chunks) | 
|  | 78 | + self.assertEqual(len(chunks), 1) | 
|  | 79 | + | 
|  | 80 | + main = chunks['main'] | 
|  | 81 | + self.assertEqual(main[0]['path'], os.path.join(settings.BASE_DIR, 'assets/bundles/main.js.gz')) | 
|  | 82 | + self.assertEqual(main[1]['path'], os.path.join(settings.BASE_DIR, 'assets/bundles/styles.css')) | 
|  | 83 | + | 
| 69 | 84 |  def test_static_url(self): | 
| 70 | 85 |  self.compile_bundles('webpack.config.publicPath.js') | 
| 71 | 86 |  assets = get_loader(DEFAULT_CONFIG).get_assets() | 
| @@ -153,6 +168,14 @@ def test_reporting_errors(self): | 
| 153 | 168 |  except WebpackError as e: | 
| 154 | 169 |  self.assertIn("Cannot resolve module 'the-library-that-did-not-exist'", str(e)) | 
| 155 | 170 | 
 | 
|  | 171 | + def test_missing_bundle(self): | 
|  | 172 | + missing_bundle_name = 'missing_bundle' | 
|  | 173 | + self.compile_bundles('webpack.config.simple.js') | 
|  | 174 | + try: | 
|  | 175 | + get_loader(DEFAULT_CONFIG).get_bundle(missing_bundle_name) | 
|  | 176 | + except WebpackBundleLookupError as e: | 
|  | 177 | + self.assertIn('Cannot resolve bundle {0}'.format(missing_bundle_name), str(e)) | 
|  | 178 | + | 
| 156 | 179 |  def test_missing_stats_file(self): | 
| 157 | 180 |  stats_file = settings.WEBPACK_LOADER[DEFAULT_CONFIG]['STATS_FILE'] | 
| 158 | 181 |  if os.path.exists(stats_file): | 
|  | 
0 commit comments