@@ -63,9 +63,9 @@ def test_simple_and_css_extract(self):
63
63
self .assertIn ('main' , chunks )
64
64
self .assertEqual (len (chunks ), 1 )
65
65
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 ' ))
69
69
70
70
def test_js_gzip_extract (self ):
71
71
self .compile_bundles ('webpack.config.gzipTest.js' )
@@ -77,9 +77,9 @@ def test_js_gzip_extract(self):
77
77
self .assertIn ('main' , chunks )
78
78
self .assertEqual (len (chunks ), 1 )
79
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 ' ))
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 ' ))
83
83
84
84
def test_static_url (self ):
85
85
self .compile_bundles ('webpack.config.publicPath.js' )
@@ -95,30 +95,28 @@ def test_code_spliting(self):
95
95
96
96
chunks = assets ['chunks' ]
97
97
self .assertIn ('main' , chunks )
98
- self .assertEquals (len (chunks ), 2 )
98
+ self .assertEquals (len (chunks ), 1 )
99
99
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' ))
105
103
106
104
def test_templatetags (self ):
107
105
self .compile_bundles ('webpack.config.simple.js' )
108
106
self .compile_bundles ('webpack.config.app2.js' )
109
107
view = TemplateView .as_view (template_name = 'home.html' )
110
108
request = self .factory .get ('/' )
111
109
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 )
113
111
self .assertIn ('<script type="text/javascript" src="/static/bundles/main.js" async charset="UTF-8"></script>' , result .rendered_content )
114
112
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 )
116
114
self .assertIn ('<script type="text/javascript" src="/static/bundles/app2.js" ></script>' , result .rendered_content )
117
115
self .assertIn ('<img src="/static/my-image.png"/>' , result .rendered_content )
118
116
119
117
view = TemplateView .as_view (template_name = 'only_files.html' )
120
118
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 )
122
120
self .assertIn ("var contentJS = '/static/bundles/main.js'" , result .rendered_content )
123
121
124
122
self .compile_bundles ('webpack.config.publicPath.js' )
@@ -158,15 +156,15 @@ def test_jinja2(self):
158
156
with self .settings (** settings ):
159
157
request = self .factory .get ('/' )
160
158
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 )
162
160
self .assertIn ('<script type="text/javascript" src="/static/bundles/main.js" async charset="UTF-8"></script>' , result .rendered_content )
163
161
164
162
def test_reporting_errors (self ):
165
163
self .compile_bundles ('webpack.config.error.js' )
166
164
try :
167
165
get_loader (DEFAULT_CONFIG ).get_bundle ('main' )
168
166
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 ))
170
168
171
169
def test_missing_bundle (self ):
172
170
missing_bundle_name = 'missing_bundle'
@@ -219,7 +217,7 @@ def test_request_blocking(self):
219
217
# FIXME: This will work 99% time but there is no garauntee with the
220
218
# 4 second thing. Need a better way to detect if request was blocked on
221
219
# not.
222
- wait_for = 3
220
+ wait_for = 4
223
221
view = TemplateView .as_view (template_name = 'home.html' )
224
222
225
223
with self .settings (DEBUG = True ):
0 commit comments