コード例 #1
0
    def test_extra_email_map(self):
        usr = UserModel().create_or_update(username=u'test_user',
                                           password=u'qweqwe',
                                     email=u'*****@*****.**',
                                     firstname=u'u1', lastname=u'u1')
        Session().commit()

        m = UserEmailMap()
        m.email = u'*****@*****.**'
        m.user = usr
        Session().add(m)
        Session().commit()

        u = User.get_by_email(email='*****@*****.**')
        assert usr.user_id == u.user_id
        assert usr.username == u.username

        u = User.get_by_email(email='*****@*****.**')
        assert usr.user_id == u.user_id
        assert usr.username == u.username

        u = User.get_by_email(email='*****@*****.**')
        assert usr.user_id == u.user_id
        assert usr.username == u.username
        u = User.get_by_email(email='*****@*****.**')
        assert None == u

        u = User.get_by_email(email='*****@*****.**')
        assert None == u
        u = User.get_by_email(email='*****@*****.**')
        assert None == u


        UserModel().delete(usr.user_id)
        Session().commit()
コード例 #2
0
    def test_extra_email_map(self):
        usr = UserModel().create_or_update(username=u'test_user',
                                           password=u'qweqwe',
                                     email=u'*****@*****.**',
                                     firstname=u'u1', lastname=u'u1')
        Session().commit()

        m = UserEmailMap()
        m.email = u'*****@*****.**'
        m.user = usr
        Session().add(m)
        Session().commit()

        u = User.get_by_email(email='*****@*****.**')
        self.assertEqual(usr.user_id, u.user_id)
        self.assertEqual(usr.username, u.username)

        u = User.get_by_email(email='*****@*****.**')
        self.assertEqual(usr.user_id, u.user_id)
        self.assertEqual(usr.username, u.username)
        u = User.get_by_email(email='*****@*****.**')
        self.assertEqual(None, u)

        UserModel().delete(usr.user_id)
        Session().commit()
コード例 #3
0
    def test_additional_email_as_main(self):
        usr = UserModel().create_or_update(username=u'test_user',
                                           password=u'qweqwe',
                                     email=u'*****@*****.**',
                                     firstname=u'u1', lastname=u'u1')
        Session().commit()

        with pytest.raises(AttributeError):
            m = UserEmailMap()
            m.email = u'*****@*****.**'
            m.user = usr
            Session().add(m)
            Session().commit()

        UserModel().delete(usr.user_id)
        Session().commit()
コード例 #4
0
ファイル: user.py プロジェクト: NexMirror/Kallithea
    def add_extra_email(self, user, email):
        """
        Adds email address to UserEmailMap

        :param user:
        :param email:
        """
        from kallithea.model import forms
        form = forms.UserExtraEmailForm()()
        data = form.to_python(dict(email=email))
        user = User.guess_instance(user)

        obj = UserEmailMap()
        obj.user = user
        obj.email = data['email']
        Session().add(obj)
        return obj
コード例 #5
0
ファイル: user.py プロジェクト: msabramo/kallithea
    def add_extra_email(self, user, email):
        """
        Adds email address to UserEmailMap

        :param user:
        :param email:
        """
        from kallithea.model import forms
        form = forms.UserExtraEmailForm()()
        data = form.to_python(dict(email=email))
        user = self._get_user(user)

        obj = UserEmailMap()
        obj.user = user
        obj.email = data['email']
        self.sa.add(obj)
        return obj
コード例 #6
0
 def do():
     m = UserEmailMap()
     m.email = u'*****@*****.**'
     m.user = usr
     Session().add(m)
     Session().commit()