X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/4a803760de93e6bafbc2154e6d92606b03f9931d..454fc9c0555c2995f0b231cfe5b760164989c4f7:/tests/test_sanity.py diff --git a/tests/test_sanity.py b/tests/test_sanity.py index 06cefaf..880edc9 100644 --- a/tests/test_sanity.py +++ b/tests/test_sanity.py @@ -2,8 +2,11 @@ from random import choice import time +import pickle +import json from twitter import Twitter, NoAuth, OAuth, read_token_file, TwitterHTTPError +from twitter.api import TwitterDictResponse, TwitterListResponse from twitter.cmdline import CONSUMER_KEY, CONSUMER_SECRET noauth = NoAuth() @@ -51,6 +54,7 @@ def test_get_trends_3(): # Of course they broke it all again in 1.1... assert twitter11.trends.place(_id=1) + def test_TwitterHTTPError_raised_for_invalid_oauth(): test_passed = False try: @@ -59,3 +63,31 @@ def test_TwitterHTTPError_raised_for_invalid_oauth(): # this is the error we are looking for :) test_passed = True assert test_passed + + +def test_picklability(): + res = TwitterDictResponse({'a': 'b'}) + p = pickle.dumps(res) + res2 = pickle.loads(p) + assert res == res2 + assert res2['a'] == 'b' + + res = TwitterListResponse([1, 2, 3]) + p = pickle.dumps(res) + res2 = pickle.loads(p) + assert res == res2 + assert res2[2] == 3 + + +def test_jsonifability(): + res = TwitterDictResponse({'a': 'b'}) + p = json.dumps(res) + res2 = json.loads(p) + assert res == res2 + assert res2['a'] == 'b' + + res = TwitterListResponse([1, 2, 3]) + p = json.dumps(res) + res2 = json.loads(p) + assert res == res2 + assert res2[2] == 3