def test_jobs_create(mock_url, replay_session): """Create should return JSON of the created Job.""" job_payload = {'id': 'app1'} resp_json = {'id': 'response'} exp_method = 'POST' exp_url = 'https://localhost:443/service/metronome/v1/jobs' replay_session.queue([MockResponse(resp_json, 201)]) j = Jobs(default_url=mock_url) assert j.create(job_payload) == resp_json assert len(replay_session.debug_cache) == 1 assert replay_session.debug_cache[0] == ((exp_method, exp_url), { 'json': job_payload })
def test_jobs_create_raise_error(mock_url, replay_session): replay_session.queue([MockResponse({}, 500)]) j = Jobs(default_url=mock_url) with pytest.raises(HTTPError): j.create({'id': 'app1'})