Ejemplo n.º 1
0
 def test_file(self):
     request = self.get_request({'name':'/resultat/2011/1/125_1_test.pdf'})
     request.context = Mock(code_compta=CODE)
     result = file_display(request)
     self.assertEqual(result.content_disposition,
             "attachment; filename=125_1_test.pdf")
     self.assertEqual(result.content_type, "application/pdf")
Ejemplo n.º 2
0
def test_file_view(get_csrf_request):
    request = get_csrf_request(
        post={'name': '/resultat/2011/1/125_1_test.pdf'})
    request.context = Mock(code_compta=CODE)
    result = file_display(request)
    assert (
        result.content_disposition == "attachment; filename=125_1_test.pdf")
    assert (result.content_type == "application/pdf")
def test_notfound(get_csrf_request):
    request = get_csrf_request(post={'name':'/resultat/2011/1/125_test2.pdf'})
    request.context = Mock(code_compta=CODE)
    result = file_display(request)
    assert(isinstance(result, HTTPNotFound))
def test_forbidden_notsubdir(get_csrf_request):
    request = get_csrf_request(post={'name':'../../test/125_test.pdf'})
    request.context = Mock(code_compta=CODE)
    result = file_display(request)
    assert(isinstance(result, HTTPForbidden))
def test_forbidden_wrond_code(get_csrf_request):
    request = get_csrf_request(post={'name':'/resultat/2011/1/125_test.pdf'})
    request.context = Mock(code_compta=CODE + "1")
    result = file_display(request)
    assert(isinstance(result, HTTPForbidden))
def test_file_view(get_csrf_request):
    request = get_csrf_request(post={'name':'/resultat/2011/1/125_1_test.pdf'})
    request.context = Mock(code_compta=CODE)
    result = file_display(request)
    assert(result.content_disposition == "attachment; filename=125_1_test.pdf")
    assert(result.content_type == "application/pdf")
Ejemplo n.º 7
0
 def test_notfound(self):
     request = self.get_request({'name':'/resultat/2011/1/125_test2.pdf'})
     request.context = Mock(code_compta=CODE)
     result = file_display(request)
     self.assertTrue(isinstance(result, HTTPNotFound))
Ejemplo n.º 8
0
 def test_forbidden_notsubdir(self):
     request = self.get_request({'name':'../../test/125_test.pdf'})
     request.context = Mock(code_compta=CODE)
     result = file_display(request)
     self.assertTrue(isinstance(result, HTTPForbidden))
Ejemplo n.º 9
0
 def test_forbidden_wrond_code(self):
     request = self.get_request({'name':'/resultat/2011/1/125_test.pdf'})
     request.context = Mock(code_compta=CODE + "1")
     result = file_display(request)
     self.assertTrue(isinstance(result, HTTPForbidden))
Ejemplo n.º 10
0
def test_notfound(get_csrf_request):
    request = get_csrf_request(post={'name': '/resultat/2011/1/125_test2.pdf'})
    request.context = Mock(code_compta=CODE)
    result = file_display(request)
    assert (isinstance(result, HTTPNotFound))
Ejemplo n.º 11
0
def test_forbidden_notsubdir(get_csrf_request):
    request = get_csrf_request(post={'name': '../../test/125_test.pdf'})
    request.context = Mock(code_compta=CODE)
    result = file_display(request)
    assert (isinstance(result, HTTPForbidden))
Ejemplo n.º 12
0
def test_forbidden_wrond_code(get_csrf_request):
    request = get_csrf_request(post={'name': '/resultat/2011/1/125_test.pdf'})
    request.context = Mock(code_compta=CODE + "1")
    result = file_display(request)
    assert (isinstance(result, HTTPForbidden))