Revision 3dce76b5 snf-pithos-app/pithos/api/test/views.py

b/snf-pithos-app/pithos/api/test/views.py
54 54
import random
55 55

  
56 56

  
57
class NotAllowedView(PithosAPITest):
58
    def head(self, url, *args, **kwargs):
59
        with patch("pithos.api.util.get_token_from_cookie") as m:
60
            m.return_value = 'token'
61
            return super(NotAllowedView, self).head(url, *args, **kwargs)
62

  
63
    def delete(self, url, *args, **kwargs):
64
        with patch("pithos.api.util.get_token_from_cookie") as m:
65
            m.return_value = 'token'
66
            return super(NotAllowedView, self).delete(url, *args, **kwargs)
67

  
68
    def post(self, url, *args, **kwargs):
69
        with patch("pithos.api.util.get_token_from_cookie") as m:
70
            m.return_value = 'token'
71
            return super(NotAllowedView, self).post(url, *args, **kwargs)
72

  
73
    def put(self, url, *args, **kwargs):
74
        with patch("pithos.api.util.get_token_from_cookie") as m:
75
            m.return_value = 'token'
76
            return super(NotAllowedView, self).put(url, *args, **kwargs)
77

  
78
    def copy(self, url, *args, **kwargs):
79
        with patch("pithos.api.util.get_token_from_cookie") as m:
80
            m.return_value = 'token'
81
            return super(NotAllowedView, self).copy(url, *args, **kwargs)
82

  
83
    def move(self, url, *args, **kwargs):
84
        with patch("pithos.api.util.get_token_from_cookie") as m:
85
            m.return_value = 'token'
86
            return super(NotAllowedView, self).move(url, *args, **kwargs)
87

  
88
    def test_not_allowed(self):
89
        self.view_path = join_urls(get_service_path(
90
            pithos_settings.pithos_services, 'pithos_ui'), 'view')
91
        self.view_url = join_urls(self.view_path, self.user, get_random_name(),
92
                                  get_random_name())
93

  
94
        r = self.head(self.view_url)
95
        self.assertEqual(r.status_code, 400)
96

  
97
        r = self.delete(self.view_url)
98
        self.assertEqual(r.status_code, 400)
99

  
100
        r = self.post(self.view_url)
101
        self.assertEqual(r.status_code, 400)
102

  
103
        r = self.put(self.view_url)
104
        self.assertEqual(r.status_code, 400)
105

  
106
        r = self.copy(self.view_url)
107
        self.assertEqual(r.status_code, 400)
108

  
109
        r = self.move(self.view_url)
110
        self.assertEqual(r.status_code, 400)
111

  
112

  
57 113
class ObjectGetView(PithosAPITest):
58 114
    def setUp(self):
59 115
        PithosAPITest.setUp(self)

Also available in: Unified diff