def test_get_combo_view_loads_from_disk(self):
test_file_contents = factory.make_string()
# Create a valid file with a proper extension (the combo loader only
# serves JS or CSS files)
test_file_name = "%s.js" % factory.make_string()
test_file = self.make_file(
name=test_file_name, contents=test_file_contents)
directory = os.path.dirname(test_file)
view = get_combo_view(directory)
# Create a request for test file.
rf = RequestFactory()
request = rf.get("/test/?%s" % test_file_name)
response = view(request)
expected_content = '/* %s */\n%s\n' % (
test_file_name, test_file_contents)
self.assertEqual(
(http.client.OK, expected_content.encode(
settings.DEFAULT_CHARSET)),
(response.status_code, response.content))
评论列表
文章目录