|
@@ -46,7 +46,7 @@ def test_post_with_json_body(MockClient, capsys):
|
|
|
|
|
|
|
|
cli.main(['post', '/foo', '-j', '{"a":1,"b":"x"}'])
|
|
cli.main(['post', '/foo', '-j', '{"a":1,"b":"x"}'])
|
|
|
|
|
|
|
|
- inst.post.assert_called_once_with('/foo', json_body={'a': 1, 'b': 'x'})
|
|
|
|
|
|
|
+ inst.post.assert_called_once_with('/foo', json_body={'a': 1, 'b': 'x'}, form_data=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
@patch('dw_base.ds.cli.DSClient')
|
|
@patch('dw_base.ds.cli.DSClient')
|
|
@@ -57,7 +57,24 @@ def test_post_no_body(MockClient, capsys):
|
|
|
|
|
|
|
|
cli.main(['post', '/foo'])
|
|
cli.main(['post', '/foo'])
|
|
|
|
|
|
|
|
- inst.post.assert_called_once_with('/foo', json_body=None)
|
|
|
|
|
|
|
+ inst.post.assert_called_once_with('/foo', json_body=None, form_data=None)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@patch('dw_base.ds.cli.DSClient')
|
|
|
|
|
+def test_post_with_form_data(MockClient, capsys):
|
|
|
|
|
+ inst = MagicMock()
|
|
|
|
|
+ inst.post.return_value = {'ok': True}
|
|
|
|
|
+ MockClient.return_value = inst
|
|
|
|
|
+
|
|
|
|
|
+ cli.main(['post', '/foo', '-d', 'name=x', '-d', 'desc=hi'])
|
|
|
|
|
+
|
|
|
|
|
+ inst.post.assert_called_once_with(
|
|
|
|
|
+ '/foo', json_body=None, form_data={'name': 'x', 'desc': 'hi'})
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def test_post_j_and_d_mutex_exits():
|
|
|
|
|
+ with pytest.raises(SystemExit):
|
|
|
|
|
+ cli.main(['post', '/foo', '-j', '{}', '-d', 'k=v'])
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_no_subcommand_exits():
|
|
def test_no_subcommand_exits():
|