コード例 #1
0
ファイル: test_mozillians.py プロジェクト: Nolski/airmozilla
    def test_fetch_user_name(self, rget, rlogging):
        def mocked_get(url, **options):
            if 'peterbe' in url:
                return Response(VOUCHED_FOR)
            if 'tmickel' in url:
                return Response(NOT_VOUCHED_FOR)
            raise NotImplementedError(url)
        rget.side_effect = mocked_get

        result = mozillians.fetch_user_name('*****@*****.**')
        eq_(result, 'Peter Bengtsson')
        result = mozillians.fetch_user_name('*****@*****.**')
        eq_(result, None)
コード例 #2
0
ファイル: test_mozillians.py プロジェクト: mythmon/airmozilla
    def test_fetch_user_name(self, rget, rlogging):
        def mocked_get(url, **options):
            if 'peterbe' in url:
                return Response(VOUCHED_FOR)
            if 'tmickel' in url:
                return Response(NOT_VOUCHED_FOR)
            raise NotImplementedError(url)

        rget.side_effect = mocked_get

        result = mozillians.fetch_user_name('*****@*****.**')
        eq_(result, 'Peter Bengtsson')
        result = mozillians.fetch_user_name('*****@*****.**')
        eq_(result, None)
コード例 #3
0
ファイル: test_mozillians.py プロジェクト: Nolski/airmozilla
    def test_fetch_user_name_no_user_name(self, rget, rlogging):
        def mocked_get(url, **options):
            if 'peterbe' in url:
                return Response(VOUCHED_FOR_NO_USERNAME)
            raise NotImplementedError(url)
        rget.side_effect = mocked_get

        result = mozillians.fetch_user_name('*****@*****.**')
        eq_(result, '')
コード例 #4
0
ファイル: test_mozillians.py プロジェクト: mythmon/airmozilla
    def test_fetch_user_name_no_user_name(self, rget, rlogging):
        def mocked_get(url, **options):
            if 'peterbe' in url:
                return Response(VOUCHED_FOR_NO_USERNAME)
            raise NotImplementedError(url)

        rget.side_effect = mocked_get

        result = mozillians.fetch_user_name('*****@*****.**')
        eq_(result, '')
コード例 #5
0
ファイル: views.py プロジェクト: vanradd/airmozilla
def user_name(request):
    if (request.user.is_authenticated() and not request.user.get_full_name()
            and request.user.email):
        # try to look it up on Mozillians
        # but first, if this fails the name won't get update and we'll keep
        # trying over and over
        cache_key = 'mozillians-fullname-query-%s' % request.user.pk
        if not cache.get(cache_key):
            full_name = fetch_user_name(request.user.email)
            if full_name:
                first_name, last_name = _first_last_name(full_name)
                request.user.first_name = first_name
                request.user.last_name = last_name
                request.user.save()
            cache.set(cache_key, 1, 60 * 60 * 24)

    name = ''
    if request.user.is_authenticated():
        name = request.user.get_full_name()
    return {'name': name}
コード例 #6
0
ファイル: views.py プロジェクト: akatsoulas/airmozilla
def user_name(request):
    if (
        request.user.is_authenticated() and
        not request.user.get_full_name() and
        request.user.email
    ):
        # try to look it up on Mozillians
        # but first, if this fails the name won't get update and we'll keep
        # trying over and over
        cache_key = 'mozillians-fullname-query-%s' % request.user.pk
        if not cache.get(cache_key):
            full_name = fetch_user_name(request.user.email)
            if full_name:
                first_name, last_name = _first_last_name(full_name)
                request.user.first_name = first_name
                request.user.last_name = last_name
                request.user.save()
            cache.set(cache_key, 1, 60 * 60 * 24)

    name = ''
    if request.user.is_authenticated():
        name = request.user.get_full_name()
    return {'name': name}