def test_id_from_url__invalid_urls(self): urls = [ "", "1", "/", "my.it/2gmzqe", "http://my.it/_", "https://redd.it/_/", "http://reddit.com/comments/_/2gmzqe", "http://my.it/2gmzqe", "https://redd.it/2gmzqe", "http://reddit.com/comments/2gmzqe", "https://www.reddit.com/r/redditdev/comments/2gmzqe/", ] for url in urls: with pytest.raises(ClientException): Comment.id_from_url(url)
def test_id_from_url(self): urls = [ "http://reddit.com/comments/2gmzqe/_/cklhv0f/", "https://reddit.com/comments/2gmzqe/_/cklhv0f", "http://www.reddit.com/r/redditdev/comments/2gmzqe/_/cklhv0f/", "https://www.reddit.com/r/redditdev/comments/2gmzqe/_/cklhv0f", ] for url in urls: assert Comment.id_from_url(url) == "cklhv0f", url