def register(fb_token): uid = Utility.hash_to_key(fb_token) token = Utility.generate_token() try: user = User.objects.create(user_id=uid, access_token=token, fb_token=fb_token) except IntegrityError: raise FbTokenExistedError() return user
def test_register(self): fb_token = Utility.generate_token() user = self._user_manager.register(fb_token) self.assertEqual(fb_token, user.fb_token, "fb token error")