def test_agent_output(capsys): responses.add( responses.GET, URL, json={'random_answer': 'foo-bar'}, status=200, ) sys.argv = ["agent_salesforce", "--section_url", "salesforce_instances,%s" % URL] main() assert capsys.readouterr() == ( '<<<salesforce_instances>>>\n{"random_answer": "foo-bar"}\n\n', '', )
def test_agent_output(capsys, monkeypatch): responses.add( responses.GET, URL, json={"random_answer": "foo-bar"}, status=200, ) monkeypatch.setattr( "sys.argv", ["agent_salesforce", "--section_url", f"salesforce_instances,{URL}"]) main() assert capsys.readouterr() == ( '<<<salesforce_instances>>>\n{"random_answer": "foo-bar"}\n\n', "", )
def test_wrong_arguments(capsys): with pytest.raises(SystemExit): main() assert capsys.readouterr().out == ''