Skip to content

Commit

Permalink
Add missing test for ETag feature
Browse files Browse the repository at this point in the history
  • Loading branch information
the-glu committed Jul 31, 2017
1 parent 370de2c commit 9e1daa4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/service_internal/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import uuid
from werkzeug.exceptions import NotFound
import copy


class TestViews(TestBase):
Expand Down Expand Up @@ -437,3 +438,32 @@ def _tmpa(__):
assert(response.data == file_content)
assert(response.headers['Content-Type'] == minetype)
assert(response.headers['Content-Disposition'] == "attachment; filename=" + atta_filename)

def test_action_send_etag(self):

self.patch_view(dont_jsonify=True)

data = {'a': str(uuid.uuid4()), '_plugit_etag': str(uuid.uuid4())}

def _tmpa(__):

data2 = copy.deepcopy(data)

class FakeResponse():
headers = {}
data = data2

def pop(self, k, d=None):
return data2.pop(k, d)

return FakeResponse()

_tmpa.pi_api_send_etag = True

mv = self.plugitviews.ActionView(_tmpa)
response = mv.dispatch_request()
self.unpatch_view()

assert(response.data['a'] == data['a'])
assert('_plugit_etag' not in response.data)
assert(response.headers['ETag'] == data['_plugit_etag'])

0 comments on commit 9e1daa4

Please sign in to comment.