mirror of
https://github.com/httpie/cli.git
synced 2025-06-30 14:21:16 +02:00
updated tests
This commit is contained in:
@ -190,10 +190,32 @@ class TestSession(SessionTestBase):
|
|||||||
|
|
||||||
def test_expired_cookies(self, httpbin):
|
def test_expired_cookies(self, httpbin):
|
||||||
self.start_session(httpbin)
|
self.start_session(httpbin)
|
||||||
session_path = self.config_dir / 'session-by-path.json'
|
orig_session = {
|
||||||
http('--session', str(session_path), httpbin.url + '/cookies/set?hello=100')
|
'cookies': {
|
||||||
r1 = http('--session', str(session_path), httpbin.url + '/cookies/delete?hello=100')
|
'to_expire': {
|
||||||
with open(self.config_dir / 'session-by-path.json', 'r') as myfile:
|
'value': 'foo'
|
||||||
data=myfile.read()
|
},
|
||||||
obj = json.loads(data)
|
'to_stay': {
|
||||||
assert len(obj['cookies']) == 0
|
'value': 'foo'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session_path = mk_config_dir() / 'test-session.json'
|
||||||
|
session_path.write_text(json.dumps(orig_session))
|
||||||
|
|
||||||
|
r = http(
|
||||||
|
'--session', str(session_path),
|
||||||
|
'--print=H',
|
||||||
|
httpbin.url + '/cookies/delete?to_expire',
|
||||||
|
)
|
||||||
|
|
||||||
|
assert 'Cookie: to_expire=foo; to_stay=foo' in r
|
||||||
|
|
||||||
|
updated_session = json.loads(session_path.read_text())
|
||||||
|
|
||||||
|
assert 'to_stay' in updated_session['cookies']
|
||||||
|
|
||||||
|
# Verify `to_expire` is gone
|
||||||
|
assert 'to_expire' not in updated_session['cookies']
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user