2017-11-18 14:31:26 +01:00
|
|
|
from httpie import __version__
|
2019-08-29 14:05:00 +02:00
|
|
|
from utils import MockEnvironment, http, HTTP_OK
|
2017-11-18 14:31:26 +01:00
|
|
|
from httpie.context import Environment
|
2016-03-03 10:14:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_default_options(httpbin):
|
2017-12-28 18:17:48 +01:00
|
|
|
env = MockEnvironment()
|
2016-03-03 10:14:39 +01:00
|
|
|
env.config['default_options'] = ['--form']
|
|
|
|
env.config.save()
|
|
|
|
r = http(httpbin.url + '/post', 'foo=bar', env=env)
|
|
|
|
assert r.json['form'] == {"foo": "bar"}
|
|
|
|
|
|
|
|
|
2019-08-29 14:05:00 +02:00
|
|
|
def test_config_dir_not_writeable(httpbin):
|
|
|
|
r = http(httpbin + '/get', env=MockEnvironment(
|
|
|
|
config_dir='/',
|
|
|
|
create_temp_config_dir=False,
|
|
|
|
))
|
|
|
|
assert HTTP_OK in r
|
|
|
|
|
|
|
|
|
2016-03-03 10:14:39 +01:00
|
|
|
def test_default_options_overwrite(httpbin):
|
2017-12-28 18:17:48 +01:00
|
|
|
env = MockEnvironment()
|
2016-03-03 10:14:39 +01:00
|
|
|
env.config['default_options'] = ['--form']
|
|
|
|
env.config.save()
|
|
|
|
r = http('--json', httpbin.url + '/post', 'foo=bar', env=env)
|
|
|
|
assert r.json['json'] == {"foo": "bar"}
|
|
|
|
|
|
|
|
|
2017-11-18 14:31:26 +01:00
|
|
|
def test_current_version():
|
2019-08-30 11:32:14 +02:00
|
|
|
version = MockEnvironment().config['__meta__']['httpie']
|
2017-11-18 14:31:26 +01:00
|
|
|
assert version == __version__
|