File: test_stackoverflow.py

package info (click to toggle)
python-social-auth 0.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,828 kB
  • ctags: 3,245
  • sloc: python: 12,867; makefile: 119; sh: 3
file content (52 lines) | stat: -rw-r--r-- 1,677 bytes parent folder | download | duplicates (2)
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
import json

from social.p3 import urlencode
from social.tests.backends.oauth import OAuth2Test


class StackoverflowOAuth2Test(OAuth2Test):
    backend_path = 'social.backends.stackoverflow.StackoverflowOAuth2'
    user_data_url = 'https://api.stackexchange.com/2.1/me'
    expected_username = 'foobar'
    access_token_body = urlencode({
        'access_token': 'foobar',
        'token_type': 'bearer'
    })
    user_data_body = json.dumps({
        'items': [{
            'user_id': 101010,
            'user_type': 'registered',
            'creation_date': 1278525551,
            'display_name': 'foobar',
            'profile_image': 'http: //www.gravatar.com/avatar/'
                             '5280f15cedf540b544eecc30fcf3027c?'
                             'd=identicon&r=PG',
            'reputation': 547,
            'reputation_change_day': 0,
            'reputation_change_week': 0,
            'reputation_change_month': 0,
            'reputation_change_quarter': 65,
            'reputation_change_year': 65,
            'age': 22,
            'last_access_date': 1363544705,
            'last_modified_date': 1354035327,
            'is_employee': False,
            'link': 'http: //stackoverflow.com/users/101010/foobar',
            'location': 'Fooland',
            'account_id': 101010,
            'badge_counts': {
                'gold': 0,
                'silver': 3,
                'bronze': 6
            }
        }],
        'quota_remaining': 9997,
        'quota_max': 10000,
        'has_more': False
    })

    def test_login(self):
        self.do_login()

    def test_partial_pipeline(self):
        self.do_partial_pipeline()