def test_ticket_request_invalid_ticket(self, _vimeo_request): """ If the request fails with a 702 error code, raise VimeoTicketInvalid. """ _vimeo_request.return_value = {'stat': 'fail', 'err': {'code': '702'}} with self.assertRaises(vimeo.VimeoTicketInvalid): vimeo._ticket_request('method', 'POST', some='data')
def test_ticket_request_error(self, logger, _vimeo_request): """ If the request fails with an error code besides 702, log it and raise VimeoServiceError. """ _vimeo_request.return_value = { 'stat': 'fail', 'err': {'code': '701', 'msg': 'test msg', 'expl': 'test_expl'} } with self.assertRaises(vimeo.VimeoServiceError): vimeo._ticket_request('method', 'POST', ticket_id='test', error_msg='{ticket_id} {code} {msg} {expl}') logger.error.assert_called_with('test 701 test msg test_expl')
def test_ticket_request_basic(self, _vimeo_request): return_response = {'stat': 'ok', 'ticket': 'blah'} _vimeo_request.return_value = return_response response = vimeo._ticket_request('method', 'POST', some='data') _vimeo_request.assert_called_with('method', 'POST', some='data') eq_(response, return_response)
def test_ticket_request_error(self, logger, _vimeo_request): """ If the request fails with an error code besides 702, log it and raise VimeoServiceError. """ _vimeo_request.return_value = { 'stat': 'fail', 'err': { 'code': '701', 'msg': 'test msg', 'expl': 'test_expl' } } with self.assertRaises(vimeo.VimeoServiceError): vimeo._ticket_request('method', 'POST', ticket_id='test', error_msg='{ticket_id} {code} {msg} {expl}') logger.error.assert_called_with('test 701 test msg test_expl')