From 9e1daa42cabd3b535f80707049f3fc9cb96e7e1a Mon Sep 17 00:00:00 2001 From: Maximilien Cuony Date: Mon, 31 Jul 2017 14:49:39 +0200 Subject: [PATCH] Add missing test for ETag feature --- tests/service_internal/test_views.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/service_internal/test_views.py b/tests/service_internal/test_views.py index c95c6f7..8c90f5b 100644 --- a/tests/service_internal/test_views.py +++ b/tests/service_internal/test_views.py @@ -6,6 +6,7 @@ import uuid from werkzeug.exceptions import NotFound +import copy class TestViews(TestBase): @@ -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'])