mirror of
https://github.com/httpie/cli.git
synced 2024-11-09 01:15:04 +01:00
11be041e06
Close #621
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from httpie import __version__
|
|
from utils import MockEnvironment, http
|
|
from httpie.context import Environment
|
|
|
|
|
|
def test_default_options(httpbin):
|
|
env = MockEnvironment()
|
|
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):
|
|
env = MockEnvironment()
|
|
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():
|
|
config = MockEnvironment().config
|
|
|
|
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']
|
|
|
|
|
|
def test_current_version():
|
|
version = Environment().config['__meta__']['httpie']
|
|
assert version == __version__
|