@@ -63,9 +63,9 @@ def test_simple_and_css_extract(self):
6363 self .assertIn ('main' , chunks )
6464 self .assertEqual (len (chunks ), 1 )
6565
66- main = chunks [ 'main ' ]
67- self .assertEqual (main [ 0 ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/main.js ' ))
68- self .assertEqual (main [ 1 ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/styles.css ' ))
66+ files = assets [ 'assets ' ]
67+ self .assertEqual (files [ 'main.css' ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/main.css ' ))
68+ self .assertEqual (files [ 'main.js' ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/main.js ' ))
6969
7070 def test_js_gzip_extract (self ):
7171 self .compile_bundles ('webpack.config.gzipTest.js' )
@@ -77,9 +77,9 @@ def test_js_gzip_extract(self):
7777 self .assertIn ('main' , chunks )
7878 self .assertEqual (len (chunks ), 1 )
7979
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 ' ))
80+ files = assets [ 'assets ' ]
81+ self .assertEqual (files [ 'main.css' ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/main.css ' ))
82+ self .assertEqual (files [ 'main.js.gz' ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/main.js.gz ' ))
8383
8484 def test_static_url (self ):
8585 self .compile_bundles ('webpack.config.publicPath.js' )
@@ -95,30 +95,28 @@ def test_code_spliting(self):
9595
9696 chunks = assets ['chunks' ]
9797 self .assertIn ('main' , chunks )
98- self .assertEquals (len (chunks ), 2 )
98+ self .assertEquals (len (chunks ), 1 )
9999
100- main = chunks ['main' ]
101- self .assertEqual (main [0 ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/main.js' ))
102-
103- vendor = chunks ['vendor' ]
104- self .assertEqual (vendor [0 ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/vendor.js' ))
100+ files = assets ['assets' ]
101+ self .assertEqual (files ['main.js' ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/main.js' ))
102+ self .assertEqual (files ['vendors.js' ]['path' ], os .path .join (settings .BASE_DIR , 'assets/bundles/vendors.js' ))
105103
106104 def test_templatetags (self ):
107105 self .compile_bundles ('webpack.config.simple.js' )
108106 self .compile_bundles ('webpack.config.app2.js' )
109107 view = TemplateView .as_view (template_name = 'home.html' )
110108 request = self .factory .get ('/' )
111109 result = view (request )
112- self .assertIn ('<link type="text/css" href="/static/bundles/styles .css" rel="stylesheet" />' , result .rendered_content )
110+ self .assertIn ('<link type="text/css" href="/static/bundles/main .css" rel="stylesheet" />' , result .rendered_content )
113111 self .assertIn ('<script type="text/javascript" src="/static/bundles/main.js" async charset="UTF-8"></script>' , result .rendered_content )
114112
115- self .assertIn ('<link type="text/css" href="/static/bundles/styles- app2.css" rel="stylesheet" />' , result .rendered_content )
113+ self .assertIn ('<link type="text/css" href="/static/bundles/app2.css" rel="stylesheet" />' , result .rendered_content )
116114 self .assertIn ('<script type="text/javascript" src="/static/bundles/app2.js" ></script>' , result .rendered_content )
117115 self .assertIn ('<img src="/static/my-image.png"/>' , result .rendered_content )
118116
119117 view = TemplateView .as_view (template_name = 'only_files.html' )
120118 result = view (request )
121- self .assertIn ("var contentCss = '/static/bundles/styles .css'" , result .rendered_content )
119+ self .assertIn ("var contentCss = '/static/bundles/main .css'" , result .rendered_content )
122120 self .assertIn ("var contentJS = '/static/bundles/main.js'" , result .rendered_content )
123121
124122 self .compile_bundles ('webpack.config.publicPath.js' )
@@ -158,15 +156,15 @@ def test_jinja2(self):
158156 with self .settings (** settings ):
159157 request = self .factory .get ('/' )
160158 result = view (request )
161- self .assertIn ('<link type="text/css" href="/static/bundles/styles .css" rel="stylesheet" />' , result .rendered_content )
159+ self .assertIn ('<link type="text/css" href="/static/bundles/main .css" rel="stylesheet" />' , result .rendered_content )
162160 self .assertIn ('<script type="text/javascript" src="/static/bundles/main.js" async charset="UTF-8"></script>' , result .rendered_content )
163161
164162 def test_reporting_errors (self ):
165163 self .compile_bundles ('webpack.config.error.js' )
166164 try :
167165 get_loader (DEFAULT_CONFIG ).get_bundle ('main' )
168166 except WebpackError as e :
169- self .assertIn ("Cannot resolve module 'the-library-that-did-not-exist'" , str (e ))
167+ self .assertIn ("Can't resolve 'the-library-that-did-not-exist'" , str (e ))
170168
171169 def test_missing_bundle (self ):
172170 missing_bundle_name = 'missing_bundle'
@@ -194,7 +192,7 @@ def test_timeouts(self):
194192 with open (
195193 settings .WEBPACK_LOADER [DEFAULT_CONFIG ]['STATS_FILE' ], 'w'
196194 ) as stats_file :
197- stats_file .write (json .dumps ({'status' : 'compiling ' }))
195+ stats_file .write (json .dumps ({'status' : 'compile ' }))
198196 loader = get_loader (DEFAULT_CONFIG )
199197 loader .config ['TIMEOUT' ] = 0.1
200198 with self .assertRaises (WebpackLoaderTimeoutError ):
@@ -216,14 +214,14 @@ def test_bad_status_in_production(self):
216214 ), str (e ))
217215
218216 def test_request_blocking (self ):
219- # FIXME: This will work 99% time but there is no garauntee with the
217+ # FIXME: This will work 99% time but there is no guarantee with the
220218 # 4 second thing. Need a better way to detect if request was blocked on
221219 # not.
222- wait_for = 3
220+ wait_for = 4
223221 view = TemplateView .as_view (template_name = 'home.html' )
224222
225223 with self .settings (DEBUG = True ):
226- open (settings .WEBPACK_LOADER [DEFAULT_CONFIG ]['STATS_FILE' ], 'w' ).write (json .dumps ({'status' : 'compiling ' }))
224+ open (settings .WEBPACK_LOADER [DEFAULT_CONFIG ]['STATS_FILE' ], 'w' ).write (json .dumps ({'status' : 'compile ' }))
227225 then = time .time ()
228226 request = self .factory .get ('/' )
229227 result = view (request )
0 commit comments