예제 #1
0
 def test_get_document_content(self):
     req = RequestFactory().get(self.get_url() + '?path=/docs/')
     view = OnlineDocsView()
     view.dispatch(req)
     result = view.get_document_content('foobar.md')
     self.assertEqual(result, None, msg=(
         'Should return None if the given file could not be read'))
예제 #2
0
 def test_get_document_name(self):
     req = RequestFactory().get(self.get_url() + '?path=/docs/')
     view = OnlineDocsView()
     view.dispatch(req)
     result = view.get_document_name()
     self.assertEqual(result, 'online_docs_view.md', msg=(
         'Should resolve the given path and return the filename with the'
         ' format "<namespace>.<view_name>.md", but returned %s' % result))
예제 #3
0
 def test_get_document_file_path(self):
     req = RequestFactory().get(self.get_url() + '?path=/docs/')
     view = OnlineDocsView()
     view.dispatch(req)
     document_name = 'foo_bar.md'
     result = view.get_document_file_path(document_name)
     self.assertEqual(result, os.path.join(
         settings.STATIC_ROOT, 'online_docs', document_name), msg=(
             'Should append the given filename to STATIC_ROOT/online_docs'
             ' but returned %s' % result))
예제 #4
0
    def test_get_template_names(self):
        req = RequestFactory().get(self.get_url() + '?path=/docs/')
        view = OnlineDocsView()
        view.dispatch(req)
        result = view.get_template_names()
        self.assertEqual(result, ['online_docs/online_docs.html'], msg=(
            'Should return the template of this app'))

        req.is_ajax = lambda: True
        view.dispatch(req)
        result = view.get_template_names()
        self.assertEqual(result, ['online_docs/partials/online_docs.html'],
            msg=('Should return the patial template if the request is an'
                 ' ajax call'))
예제 #5
0
"""URLs for the ``online_docs`` app."""
from django.conf.urls.defaults import patterns, url

from online_docs.views import OnlineDocsView


urlpatterns = patterns('',
    url(r'^$',
        OnlineDocsView.as_view(),
        name='online_docs_view',
    )
)