Skip to content
This repository has been archived by the owner on May 31, 2019. It is now read-only.

Commit

Permalink
Add set_cookie tests
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bata committed Dec 7, 2016
1 parent 1d807cf commit 586605a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
10 changes: 7 additions & 3 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ decorator==4.0.10
docopt==0.6.2
docutils==0.12
flake8==3.2.1
freezegun==0.3.8
gnureadline==6.3.3
gunicorn==19.6.0
imagesize==0.7.1
ipdb==0.10.1
ipython==5.1.0
ipython-genutils==0.1.0
Jinja2==2.8
-e git+git@github.com:c-bata/kobin.git@acc882e77eba4af46a01bd034e7bf28587a77347#egg=kobin
-e git+git@github.com:c-bata/kobin.git@1d807cfa3d60d37a27299f8e3ff8ac75359cda4c#egg=kobin
MarkupSafe==0.23
mccabe==0.5.2
mypy-lang==0.4.6
Expand All @@ -34,20 +35,23 @@ pyflakes==1.3.0
Pygments==2.1.3
pytest==3.0.4
pytest-cov==2.4.0
python-dateutil==2.6.0
pytz==2016.7
requests==2.12.2
redis==2.10.5
requests==2.12.3
requests-toolbelt==0.7.0
simplegeneric==0.8.1
six==1.10.0
snowballstemmer==1.2.1
solar-theme==1.3.2
Sphinx==1.4.9
Sphinx==1.5
sphinx-intl==0.9.9
sphinx-rtd-theme==0.1.9
tox==2.5.0
traitlets==4.3.1
transifex-client==0.12.2
twine==1.8.1
typed-ast==0.6.1
urllib3==1.19.1
virtualenv==15.1.0
wcwidth==0.1.7
Expand Down
1 change: 1 addition & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ flake8
mypy-lang
pytest
tox
freezegun
19 changes: 18 additions & 1 deletion tests/test_environs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import timedelta, datetime
import freezegun
from jinja2 import Environment, FileSystemLoader
import os
from unittest import TestCase
Expand Down Expand Up @@ -177,10 +179,25 @@ def test_set_cookie(self):
expected_set_cookie = ('Set-Cookie', 'foo=bar')
self.assertIn(expected_set_cookie, response.headerlist)

def test_set_cookie_with_max_age(self):
response = Response()
response.set_cookie('foo', 'bar', max_age=timedelta(seconds=10))
expected_set_cookie = ('Set-Cookie', 'foo=bar; Max-Age=10')
self.assertIn(expected_set_cookie, response.headerlist)

def test_set_cookie_with_expires(self):
response = Response()
response.set_cookie('foo', 'bar', expires=datetime(2017, 1, 1, 0, 0, 0))
expected_set_cookie = ('Set-Cookie', 'foo=bar; expires=Sun, 01 Jan 2017 00:00:00 GMT')
self.assertIn(expected_set_cookie, response.headerlist)

@freezegun.freeze_time('2017-01-01 00:00:00')
def test_delete_cookie(self):
response = Response()
response.delete_cookie('foo')
expected_set_cookie = ('Set-Cookie', 'foo=""; Max-Age=-1')
expected_set_cookie = (
'Set-Cookie',
'foo=""; expires=Sun, 01 Jan 2017 00:00:00 GMT; Max-Age=-1')
self.assertIn(expected_set_cookie, response.headerlist)

def test_constructor_headerlist_has_already_content_type(self):
Expand Down

0 comments on commit 586605a

Please sign in to comment.