Statistics
| Branch: | Tag: | Revision:

root / social / tests / backends / test_facebook.py @ a0a04c0a

History | View | Annotate | Download (1.2 kB)

1
import json
2

    
3
from social.p3 import urlencode
4
from social.exceptions import AuthUnknownError
5

    
6
from social.tests.backends.oauth import OAuth2Test
7

    
8

    
9
class FacebookOAuth2Test(OAuth2Test):
10
    backend_path = 'social.backends.facebook.FacebookOAuth2'
11
    user_data_url = 'https://graph.facebook.com/me'
12
    expected_username = 'foobar'
13
    access_token_body = urlencode({
14
        'access_token': 'foobar',
15
        'token_type': 'bearer'
16
    })
17
    user_data_body = json.dumps({
18
        'username': 'foobar',
19
        'first_name': 'Foo',
20
        'last_name': 'Bar',
21
        'verified': True,
22
        'name': 'Foo Bar',
23
        'gender': 'male',
24
        'updated_time': '2013-02-13T14:59:42+0000',
25
        'link': 'http://www.facebook.com/foobar',
26
        'id': '110011001100010'
27
    })
28

    
29
    def test_login(self):
30
        self.do_login()
31

    
32
    def test_partial_pipeline(self):
33
        self.do_partial_pipeline()
34

    
35

    
36
class FacebookOAuth2WrongUserDataTest(FacebookOAuth2Test):
37
    user_data_body = 'null'
38

    
39
    def test_login(self):
40
        self.do_login.when.called_with().should.throw(AuthUnknownError)
41

    
42
    def test_partial_pipeline(self):
43
        self.do_partial_pipeline.when.called_with().should.throw(
44
            AuthUnknownError
45
        )