Esempio n. 1
0
    def test_manage_user(self):
        """Test FACEBOOK manage_user without e-mail works."""
        with self.app.test_request_context('/'):
            # First with a new user
            user_data = dict(id=1, username='******', name='name')
            token = 't'
            user = facebook.manage_user(token, user_data, None)
            assert user.email_addr == user_data['email'], user
            assert user.name == user_data['username'], user
            assert user.fullname == user_data['name'], user
            assert user.facebook_user_id == user_data['id'], user

            # Second with the same user
            user = facebook.manage_user(token, user_data, None)
            assert user.email_addr == user_data['email'], user
            assert user.name == user_data['username'], user
            assert user.fullname == user_data['name'], user
            assert user.facebook_user_id == user_data['id'], user

            # Finally with a user that already is in the system
            user_data = dict(id=10,
                             username=Fixtures.name,
                             email=Fixtures.email_addr,
                             name=Fixtures.fullname)
            token = 'tA'
            user = facebook.manage_user(token, user_data, None)
            assert user is None
Esempio n. 2
0
    def test_manage_user(self):
        """Test FACEBOOK manage_user without e-mail works."""
        with self.app.test_request_context('/'):
            # First with a new user
            user_data = dict(id=1, username='******', name='name')
            token = 't'
            user = facebook.manage_user(token, user_data, None)
            assert user.email_addr == user_data['email'], user
            assert user.name == user_data['username'], user
            assert user.fullname == user_data['name'], user
            assert user.facebook_user_id == user_data['id'], user

            # Second with the same user
            user = facebook.manage_user(token, user_data, None)
            assert user.email_addr == user_data['email'], user
            assert user.name == user_data['username'], user
            assert user.fullname == user_data['name'], user
            assert user.facebook_user_id == user_data['id'], user

            # Finally with a user that already is in the system
            user_data = dict(id=10, username=Fixtures.name,
                             email=Fixtures.email_addr, name=Fixtures.fullname)
            token = 'tA'
            user = facebook.manage_user(token, user_data, None)
            assert user is None
Esempio n. 3
0
    def test_manage_user_without_email(self):
        """Test FACEBOOK manage_user without e-mail works."""
        # First with a new user
        user_data = dict(id=1, username='******', name='name')
        token = 't'
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['username'], user
        assert user.fullname == user_data['name'], user
        assert user.facebook_user_id == user_data['id'], user

        # Second with the same user
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['username'], user
        assert user.fullname == user_data['name'], user
        assert user.facebook_user_id == user_data['id'], user

        # Finally with a user that already is in the system
        user_data = dict(id=10, username=self.name,
                         email=self.email_addr, name=self.fullname)
        token = 'tA'
        user = manage_user(token, user_data, None)
        err_msg = "It should return the same user"
        assert user.facebook_user_id == 10, err_msg
Esempio n. 4
0
    def test_manage_user_without_email(self):
        """Test FACEBOOK manage_user without e-mail works."""
        # First with a new user
        user_data = dict(id=1, username='******', name='name')
        token = 't'
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['username'], user
        assert user.fullname == user_data['name'], user
        assert user.facebook_user_id == user_data['id'], user

        # Second with the same user
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['username'], user
        assert user.fullname == user_data['name'], user
        assert user.facebook_user_id == user_data['id'], user

        # Finally with a user that already is in the system
        user_data = dict(id=10, username=self.name,
                         email=self.email_addr, name=self.fullname)
        token = 'tA'
        user = manage_user(token, user_data, None)
        err_msg = "It should return the same user"
        assert user.facebook_user_id == 10, err_msg
 def test_manage_user_with_email_facebook_account_user_registered(self):
     """Test FACEBOOK manage_user works for a user already registered with Facebook."""
     token = 't'
     manage_user(token, self.user_data)
     new_token = 'new_token'
     user = manage_user(new_token, self.user_data)
     assert user.email_addr == self.user_data['email'], user
     assert user.name == self.name, user
     assert user.fullname == self.user_data['name'], user
     assert user.facebook_user_id == self.user_data['id'], user
     assert user.info['facebook_token'] == dict(oauth_token=new_token), user
Esempio n. 6
0
 def test_manage_user_with_email_facebook_account_user_registered(self):
     """Test FACEBOOK manage_user works for a user already registered with Facebook."""
     token = 't'
     manage_user(token, self.user_data)
     new_token = 'new_token'
     user = manage_user(new_token, self.user_data)
     assert user.email_addr == self.user_data['email'], user
     assert user.name == self.name, user
     assert user.fullname == self.user_data['name'], user
     assert user.facebook_user_id == self.user_data['id'], user
     assert user.info['facebook_token'] == dict(oauth_token=new_token), user
Esempio n. 7
0
 def test_manage_user_with_email_facebook_account_user_registered(self):
     """Test FACEBOOK manage_user works for a user already registered with Facebook."""
     token = "t"
     manage_user(token, self.user_data)
     new_token = "new_token"
     user = manage_user(new_token, self.user_data)
     assert user.email_addr == self.user_data["email"], user
     assert user.name == self.name, user
     assert user.fullname == self.user_data["name"], user
     assert user.facebook_user_id == self.user_data["id"], user
     assert user.info["facebook_token"] == dict(oauth_token=new_token), user
Esempio n. 8
0
 def test_manage_user_without_email_facebook_account_user_registered(self):
     """Test FACEBOOK manage_user works for a user already registered with
     Facebook without email on his FB account."""
     del self.user_data['email']
     token = 't'
     manage_user(token, self.user_data)
     new_token = 'new_token'
     user = manage_user(new_token, self.user_data)
     print(user.email_addr, self.user_data['email'])
     assert user.email_addr == self.user_data['email'], user
     assert user.name == self.name.decode('utf-8'), user
     assert user.fullname == self.user_data['name'], user
     assert user.facebook_user_id == self.user_data['id'], user
     assert user.info['facebook_token'] == dict(oauth_token=new_token), user
Esempio n. 9
0
    def test_manage_user_with_email(self):
        """Test FACEBOOK manage_user works."""
        # First with a new user
        token = 't'
        user = manage_user(token, self.user_data)
        assert user.email_addr == self.user_data['email'], user
        assert user.name == self.name, user
        assert user.fullname == self.user_data['name'], user
        assert user.facebook_user_id == self.user_data['id'], user

        # Second with the same user
        user = manage_user(token, self.user_data)
        assert user.email_addr == self.user_data['email'], user
        assert user.name == self.name, user
        assert user.fullname == self.user_data['name'], user
        assert user.facebook_user_id == self.user_data['id'], user
Esempio n. 10
0
    def test_manage_user_with_email(self):
        """Test FACEBOOK manage_user works."""
        # First with a new user
        token = 't'
        user = manage_user(token, self.user_data)
        assert user.email_addr == self.user_data['email'], user
        assert user.name == self.name, user
        assert user.fullname == self.user_data['name'], user
        assert user.facebook_user_id == self.user_data['id'], user

        # Second with the same user
        user = manage_user(token, self.user_data)
        assert user.email_addr == self.user_data['email'], user
        assert user.name == self.name, user
        assert user.fullname == self.user_data['name'], user
        assert user.facebook_user_id == self.user_data['id'], user
Esempio n. 11
0
 def test_manage_user_with_email_new_user(self):
     """Test FACEBOOK manage_user works for a new user."""
     token = "t"
     user = manage_user(token, self.user_data)
     assert user.email_addr == self.user_data["email"], user
     assert user.name == self.name, user
     assert user.fullname == self.user_data["name"], user
     assert user.facebook_user_id == self.user_data["id"], user
     assert user.info["facebook_token"] == dict(oauth_token=token), user
Esempio n. 12
0
 def test_manage_user_with_email_new_user(self):
     """Test FACEBOOK manage_user works for a new user."""
     token = 't'
     user = manage_user(token, self.user_data)
     assert user.email_addr == self.user_data['email'], user
     assert user.name == self.name, user
     assert user.fullname == self.user_data['name'], user
     assert user.facebook_user_id == self.user_data['id'], user
     assert user.info['facebook_token'] == dict(oauth_token=token), user
Esempio n. 13
0
 def test_manage_user_with_email_new_user(self):
     """Test FACEBOOK manage_user works for a new user."""
     token = 't'
     user = manage_user(token, self.user_data)
     assert user.email_addr == self.user_data['email'], user
     assert user.name == self.name, user
     assert user.fullname == self.user_data['name'], user
     assert user.facebook_user_id == self.user_data['id'], user
     assert user.info['facebook_token'] == dict(oauth_token=token), user
Esempio n. 14
0
 def test_manage_user_without_email_new_user(self):
     """Test FACEBOOK manage_user works for a new user without email in his
     FB account."""
     del self.user_data['email']
     token = 't'
     user = manage_user(token, self.user_data)
     assert user.email_addr == self.user_data['email'], user
     assert user.name == self.name.decode('utf-8'), user
     assert user.fullname == self.user_data['name'], user
     assert user.facebook_user_id == self.user_data['id'], user
     assert user.info['facebook_token'] == dict(oauth_token=token), user
Esempio n. 15
0
    def test_manage_user_with_email_newsletter(self, newsletter):
        """Test FACEBOOK manage_user newsletter works."""
        newsletter.app = True
        token = 't'
        user = manage_user(token, self.user_data)
        assert user.email_addr == self.user_data['email'], user
        assert user.name == self.name, user
        assert user.fullname == self.user_data['name'], user
        assert user.facebook_user_id == self.user_data['id'], user

        newsletter.subscribe_user.assert_called_once_with(user)
Esempio n. 16
0
    def test_manage_user_with_email_newsletter(self, newsletter):
        """Test FACEBOOK manage_user newsletter works."""
        newsletter.app = True
        token = 't'
        user = manage_user(token, self.user_data)
        assert user.email_addr == self.user_data['email'], user
        assert user.name == self.name, user
        assert user.fullname == self.user_data['name'], user
        assert user.facebook_user_id == self.user_data['id'], user

        newsletter.subscribe_user.assert_called_once_with(user)
Esempio n. 17
0
 def test_manage_user_without_email_newsletter(self, newsletter):
     """Test FACEBOOK manage_user without e-mail newsletter works."""
     newsletter.app = True
     del self.user_data['email']
     token = 't'
     user = manage_user(token, self.user_data)
     assert user.email_addr == self.user_data['email'], user
     assert user.name == self.name, user
     assert user.fullname == self.user_data['name'], user
     assert user.facebook_user_id == self.user_data['id'], user
     err_msg = "It should not be called."
     assert newsletter.subscribe_user.called is False, err_msg
Esempio n. 18
0
 def test_manage_user_without_email_newsletter(self, newsletter):
     """Test FACEBOOK manage_user without e-mail newsletter works."""
     newsletter.app = True
     del self.user_data['email']
     token = 't'
     user = manage_user(token, self.user_data)
     assert user.email_addr == self.user_data['email'], user
     assert user.name == self.name, user
     assert user.fullname == self.user_data['name'], user
     assert user.facebook_user_id == self.user_data['id'], user
     err_msg = "It should not be called."
     assert newsletter.subscribe_user.called is False, err_msg
Esempio n. 19
0
 def test_manage_user_without_email_newsletter(self, newsletter):
     """Test FACEBOOK manage_user without e-mail newsletter works."""
     newsletter.app = True
     # First with a new user
     user_data = dict(id=1, username='******', name='name')
     token = 't'
     user = manage_user(token, user_data, None)
     assert user.email_addr == user_data['email'], user
     assert user.name == user_data['username'], user
     assert user.fullname == user_data['name'], user
     assert user.facebook_user_id == user_data['id'], user
     err_msg = "It should not be called."
     assert newsletter.subscribe_user.called is False, err_msg
Esempio n. 20
0
 def test_manage_user_without_email_newsletter(self, newsletter):
     """Test FACEBOOK manage_user without e-mail newsletter works."""
     newsletter.app = True
     # First with a new user
     user_data = dict(id=1, username='******', name='name')
     token = 't'
     user = manage_user(token, user_data, None)
     assert user.email_addr == user_data['email'], user
     assert user.name == user_data['username'], user
     assert user.fullname == user_data['name'], user
     assert user.facebook_user_id == user_data['id'], user
     err_msg = "It should not be called."
     assert newsletter.subscribe_user.called is False, err_msg
Esempio n. 21
0
    def test_manage_user_with_email_newsletter(self, newsletter):
        """Test FACEBOOK manage_user newsletter works."""
        newsletter.app = True
        # First with a new user
        user_data = dict(id=1, username='******',
                         email='*****@*****.**', name='name')
        token = 't'
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['username'], user
        assert user.fullname == user_data['name'], user
        assert user.facebook_user_id == user_data['id'], user

        newsletter.subscribe_user.assert_called_once_with(user)
Esempio n. 22
0
    def test_manage_user_with_email_newsletter(self, newsletter):
        """Test FACEBOOK manage_user newsletter works."""
        newsletter.app = True
        # First with a new user
        user_data = dict(id=1,
                         username='******',
                         email='*****@*****.**',
                         name='name')
        token = 't'
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['username'], user
        assert user.fullname == user_data['name'], user
        assert user.facebook_user_id == user_data['id'], user

        newsletter.subscribe_user.assert_called_once_with(user)