def test_regenerate(self): """If the bundle has expired, re-generate it.""" with patch.object(views, 'SnippetBundle') as SnippetBundle: bundle = SnippetBundle.return_value bundle.url = '/foo/bar' bundle.expired = True response = views.fetch_pregenerated_snippets(self.request, **self.client_kwargs) eq_(response.status_code, 302) eq_(response['Location'], '/foo/bar') # Since the bundle was expired, ensure it was re-generated. ok_(SnippetBundle.return_value.generate.called)
def test_regenerate(self): """If the bundle has expired, re-generate it.""" with patch.object(views, 'SnippetBundle') as SnippetBundle: bundle = SnippetBundle.return_value bundle.url = '/foo/bar' bundle.expired = True response = views.fetch_pregenerated_snippets( self.request, **self.client_kwargs) eq_(response.status_code, 302) eq_(response['Location'], '/foo/bar') # Since the bundle was expired, ensure it was re-generated. ok_(SnippetBundle.return_value.generate.called)
def test_normal(self): with patch.object(views, 'SnippetBundle') as SnippetBundle: bundle = SnippetBundle.return_value bundle.url = '/foo/bar' bundle.expired = False response = views.fetch_pregenerated_snippets(self.request, **self.client_kwargs) eq_(response.status_code, 302) eq_(response['Location'], '/foo/bar') # Check for correct client. eq_(SnippetBundle.call_args[0][0].locale, 'en-US') # Do not generate bundle when not expired. ok_(not SnippetBundle.return_value.generate.called)
def test_normal(self): with patch.object(views, 'SnippetBundle') as SnippetBundle: bundle = SnippetBundle.return_value bundle.url = '/foo/bar' bundle.expired = False response = views.fetch_pregenerated_snippets( self.request, **self.client_kwargs) eq_(response.status_code, 302) eq_(response['Location'], '/foo/bar') # Check for correct client. eq_(SnippetBundle.call_args[0][0].locale, 'en-US') # Do not generate bundle when not expired. ok_(not SnippetBundle.return_value.generate.called)