예제 #1
0
    def check_or_create(self, token, auth_type):
        if auth_type == 'github':
            github = Github()
            user_info = github.get_user_info(token)
            user = User.objects(github_id=user_info['id']).first()

            if not user:
                user = User()
                email_github = github.get_email(token)

                user.token_github = token
                user.github = user_info['html_url']
                user.email = email_github[0]
                user.name = user_info['name']
                user.username = user_info['login']
                user.city = user_info['location']
                user.gravatar_id = user_info['gravatar_id']
                user.github_id = user_info['id']

                user.save()
                self.create_auth_session(user.id, token, auth_type)

            return self.create_auth_session(user.id, token, auth_type)
        else:
            return False
예제 #2
0
    def check_or_create(self, token, auth_type):
        if auth_type == 'github':
            github = Github()
            user_info = github.get_user_info(token)
            user = User.objects(github_id=user_info['id']).first()
            
            if not user:
                user = User()
                email_github = github.get_email(token)
                
                user.token_github = token
                user.github = user_info['html_url']
                user.email = email_github[0]
                user.name = user_info['name']
                user.username = user_info['login']
                user.city     = user_info['location']
                user.gravatar_id = user_info['gravatar_id']
                user.github_id =user_info['id']

                user.save()
                self.create_auth_session(user.id, token, auth_type)

            return self.create_auth_session(user.id, token, auth_type)
        else:
            return False
예제 #3
0
    def testUserSettingSave(self):
        with app.test_client() as c:
            with c.session_transaction() as sess:
                sess['user_id'] = self.id

            post = dict(
                username='******',
                email='*****@*****.**',
                job='Test Job 2',
                city='Test City 2',
                name='Test Name 2',
                github='Test github 2',
                twitter='Test twitter 2',
                linkedin='Test linkedin 2',
                facebook='Test facebook 2',
                googleplus='Test googleplus 2',
                foursquare='Test foursquare 2',
                personal_web='Test personal web 2',
            )
            rv = c.post('/user/settings', data=post)

            self.assertEquals(rv.status_code, 200)
            self.assertTrue('Test username 2' in rv.data)
            self.assertTrue('*****@*****.**' in rv.data)
            self.assertTrue('Test Job 2' in rv.data)
            self.assertTrue('Test City 2' in rv.data)
            self.assertTrue('Test Name 2' in rv.data)
            self.assertTrue('Test github 2' in rv.data)
            self.assertTrue('Test twitter 2' in rv.data)
            self.assertTrue('Test linkedin 2' in rv.data)
            self.assertTrue('Test facebook 2' in rv.data)
            self.assertTrue('Test googleplus 2' in rv.data)
            self.assertTrue('Test foursquare 2' in rv.data)
            self.assertTrue('Test personal web 2' in rv.data)

            user = User.objects(id=self.id).first()

            self.assertEquals(post['username'], user.username)
            self.assertEquals(post['email'], user.email)
            self.assertEquals(post['job'], user.job)
            self.assertEquals(post['city'], user.city)
            self.assertEquals(post['name'], user.name)
            self.assertEquals(post['github'], user.github)
            self.assertEquals(post['twitter'], user.twitter)
            self.assertEquals(post['linkedin'], user.linkedin)
            self.assertEquals(post['facebook'], user.facebook)
            self.assertEquals(post['googleplus'], user.googleplus)
            self.assertEquals(post['foursquare'], user.foursquare)
            self.assertEquals(post['personal_web'], user.personal_web)
예제 #4
0
 def testFoursquare(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.foursquare, 'Test foursquare')
예제 #5
0
 def testGooglePlus(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.googleplus, 'Test googleplus')
예제 #6
0
 def testFaceBook(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.facebook, 'Test facebook')
예제 #7
0
 def testLinkedin(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.linkedin, 'Test linkedin')
예제 #8
0
 def testTwitter(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.twitter, 'Test twitter')
예제 #9
0
 def testGithub(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.github, 'Test github')
예제 #10
0
 def testName(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.name, 'Test Name')
예제 #11
0
 def testCity(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.city, 'Test City')
예제 #12
0
 def testJob(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.job, 'Test Job')
예제 #13
0
 def testGithubID(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.github_id, 12345)
예제 #14
0
 def testGravatarID(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.gravatar_id, 'test gravatar id')
예제 #15
0
 def testGithubToken(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.token_github, 'test github token')
예제 #16
0
 def testPersonalWeb(self):
     user = User.objects(id=self.id).first()
     self.assertEquals(user.personal_web, 'Test personal web')