def test_500(self): api = JiveApi('http://jive.example.com/', 'jiveuser', 'jivepass') req_t = namedtuple('MockRequest', ['method', 'url']) req = req_t(method='POST', url='http://jive.example.com/') with patch('%s._post_json' % pb) as mock_post: mock_post.side_effect = RequestFailedException( MockResponse(500, 'Conflict', request=req)) with pytest.raises(RequestFailedException): api.create_content({'foo': 'bar'})
def test_publish_date(self): api = JiveApi('http://jive.example.com/', 'jiveuser', 'jivepass') tz = FixedOffset(-60, 'foo') with patch('%s._post_json' % pb, autospec=True) as mock_post: mock_post.return_value = {'return': 'value'} res = api.create_content({'foo': 'bar'}, publish_date=datetime(2018, 2, 13, 11, 23, 52, tzinfo=tz)) assert res == {'return': 'value'} assert mock_post.mock_calls == [ call( api, 'core/v3/contents?published=2018-02-13T11%3A23%3A52.000-0100&' 'updated=2018-02-13T11%3A23%3A52.000-0100', {'foo': 'bar'}) ]