2017-11-18 14:31:26 +01:00
|
|
|
from httpie import __version__
|
2017-12-28 18:17:48 +01:00
|
|
|
from utils import MockEnvironment, http
|
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"}
|
|
|
|
|
|
|
|
|
|
|
|
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"}
|
|
|
|
|
|
|
|
|
|
|
|
def test_migrate_implicit_content_type():
|
2017-12-28 18:17:48 +01:00
|
|
|
config = MockEnvironment().config
|
2016-03-03 10:14:39 +01:00
|
|
|
|
|
|
|
config['implicit_content_type'] = 'json'
|
|
|
|
config.save()
|
|
|
|
config.load()
|
|
|
|
assert 'implicit_content_type' not in config
|
|
|
|
assert not config['default_options']
|
|
|
|
|
|
|
|
config['implicit_content_type'] = 'form'
|
|
|
|
config.save()
|
|
|
|
config.load()
|
|
|
|
assert 'implicit_content_type' not in config
|
|
|
|
assert config['default_options'] == ['--form']
|
2017-11-18 14:31:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_current_version():
|
|
|
|
version = Environment().config['__meta__']['httpie']
|
|
|
|
assert version == __version__
|