def test_statuses_user_timeline(samp_auth): """ Test the statuses/user_timeline method. """ for user_id, screen_name in TEST_USERS: params = {"user_id": user_id, "count": 10} tweets, meta = rest.statuses_user_timeline(samp_auth, **params) assert meta["code"] == 200 assert all(t["user"]["id"] == user_id for t in tweets) assert all(t["user"]["screen_name"] == screen_name for t in tweets) params = {"screen_name": screen_name, "count": 10} tweets, meta = rest.statuses_user_timeline(samp_auth, **params) assert meta["code"] == 200 assert all(t["user"]["id"] == user_id for t in tweets) assert all(t["user"]["screen_name"] == screen_name for t in tweets)
def test_statuses_user_timeline(samp_auth): """ Test the statuses/user_timeline method. """ for user_id, screen_name in TEST_USERS: params = {"user_id": user_id, "count": 10} tweets, meta = rest.statuses_user_timeline(samp_auth, **params) assert meta["code"] == 200 assert all(t["user"]["id"] == user_id for t in tweets) assert all(t["user"]["screen_name"] == screen_name for t in tweets) params = {"screen_name": screen_name, "count": 10} tweets, meta = rest.statuses_user_timeline(samp_auth, **params) assert meta["code"] == 200 assert all(t["user"]["id"] == user_id for t in tweets) assert all(t["user"]["screen_name"] == screen_name for t in tweets)
def test_statuses_user_timeline_iter(samp_auth): """ Test the statuses/user_timeline method using id_iter. """ for user_id, screen_name in TEST_USERS: params = {"user_id": user_id, "count": 10, "maxitems": 20} results = [] for tweets, meta in rest.statuses_user_timeline(samp_auth, **params): assert meta["code"] == 200 results.extend(tweets) assert all(t["user"]["id"] == user_id for t in results) assert all(t["user"]["screen_name"] == screen_name for t in results) assert len(results) >= 20 assert len(set(r["id"] for r in results)) >= 20
def test_statuses_user_timeline_iter(samp_auth): """ Test the statuses/user_timeline method using id_iter. """ for user_id, screen_name in TEST_USERS: params = {"user_id": user_id, "count": 10, "maxitems": 20} results = [] for tweets, meta in rest.statuses_user_timeline(samp_auth, **params): assert meta["code"] == 200 results.extend(tweets) assert all(t["user"]["id"] == user_id for t in results) assert all(t["user"]["screen_name"] == screen_name for t in results) assert len(results) >= 20 assert len(set(r["id"] for r in results)) >= 20
def test_statuses_lookup(samp_auth): """ Test the statuses/lookup method. """ for user_id, _ in TEST_USERS: # First get the last 10 tweet ids for a test user params = {"user_id": user_id, "count": 10} tweets, meta = rest.statuses_user_timeline(samp_auth, **params) assert meta["code"] == 200 assert all(t["user"]["id"] == user_id for t in tweets) # Create the list of tweet ids tids = [t["id"] for t in tweets] # Next get the same tweets using statues lookup nparams = {"id": tids} ntweets, nmeta = rest.statuses_lookup(samp_auth, **nparams) assert nmeta["code"] == 200 assert set(tids) == set(t["id"] for t in ntweets)
def test_statuses_show(samp_auth): """ Test the statuses/show method. """ for user_id, _ in TEST_USERS: # First get the last tweet id for a test user params = {"user_id": user_id, "count": 1} tweet, meta = rest.statuses_user_timeline(samp_auth, **params) assert meta["code"] == 200 tweet = tweet[0] assert tweet["user"]["id"] == user_id # Next get the same tweet with statuses show nparams = {"id": tweet["id"]} ntweet, nmeta = rest.statuses_show(samp_auth, **nparams) assert nmeta["code"] == 200 assert tweet["id"] == ntweet["id"] assert tweet["text"] == ntweet["text"]
def test_statuses_lookup(samp_auth): """ Test the statuses/lookup method. """ for user_id, _ in TEST_USERS: # First get the last 10 tweet ids for a test user params = {"user_id": user_id, "count": 10} tweets, meta = rest.statuses_user_timeline(samp_auth, **params) assert meta["code"] == 200 assert all(t["user"]["id"] == user_id for t in tweets) # Create the list of tweet ids tids = [t["id"] for t in tweets] # Next get the same tweets using statues lookup nparams = {"id": tids} ntweets, nmeta = rest.statuses_lookup(samp_auth, **nparams) assert nmeta["code"] == 200 assert set(tids) == set(t["id"] for t in ntweets)
def test_statuses_show(samp_auth): """ Test the statuses/show method. """ for user_id, _ in TEST_USERS: # First get the last tweet id for a test user params = {"user_id": user_id, "count": 1} tweet, meta = rest.statuses_user_timeline(samp_auth, **params) assert meta["code"] == 200 tweet = tweet[0] assert tweet["user"]["id"] == user_id # Next get the same tweet with statuses show nparams = {"id": tweet["id"]} ntweet, nmeta = rest.statuses_show(samp_auth, **nparams) assert nmeta["code"] == 200 assert tweet["id"] == ntweet["id"] assert tweet["text"] == ntweet["text"]