forked from bear/python-twitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_tweet_changes.py
62 lines (49 loc) · 2.3 KB
/
test_tweet_changes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# encoding: utf-8
from __future__ import unicode_literals, print_function
import json
import re
import sys
import unittest
import warnings
import twitter
import responses
from responses import GET
warnings.filterwarnings('ignore', category=DeprecationWarning)
DEFAULT_URL = re.compile(r'https?://.*\.twitter.com/1\.1/.*')
class ModelsChangesTest(unittest.TestCase):
"""Test how changes to tweets affect model creation"""
def setUp(self):
self.api = twitter.Api(
consumer_key='test',
consumer_secret='test',
access_token_key='test',
access_token_secret='test',
sleep_on_rate_limit=False)
@responses.activate
def test_extended_in_compat_mode(self):
"""API is in compatibility mode, but we call GetStatus on a tweet that
was written in extended mode.
The tweet in question is exactly 140 characters and attaches a photo.
"""
with open('testdata/3.2/extended_tweet_in_compat_mode.json') as f:
resp_data = f.read()
status = twitter.Status.NewFromJsonDict(json.loads(resp_data))
self.assertTrue(status)
self.assertEqual(status.id, 782737772490600448)
self.assertEqual(status.text, "has more details about these changes. Thanks for making more expressive!writing requirements to python_twitt pytho… https://t.co/et3OTOxWSa")
self.assertEqual(status.tweet_mode, 'compatibility')
self.assertTrue(status.truncated)
@responses.activate
def test_extended_in_extended_mode(self):
"""API is in extended mode, and we call GetStatus on a tweet that
was written in extended mode.
The tweet in question is exactly 140 characters and attaches a photo.
"""
with open('testdata/3.2/extended_tweet_in_extended_mode.json') as f:
resp_data = f.read()
status = twitter.Status.NewFromJsonDict(json.loads(resp_data))
self.assertTrue(status)
self.assertEqual(status.id, 782737772490600448)
self.assertEqual(status.full_text, "has more details about these changes. Thanks for making more expressive!writing requirements to python_twitt python_twitter.egg-info/SOURCE https://t.co/JWSPztfoyt")
self.assertEqual(status.tweet_mode, 'extended')
self.assertFalse(status.truncated)