示例#1
0
    def test_apps_contributed_no_contributions(self):
        """Test CACHE USERS apps_contributed returns empty list if the user has
        not contributed to any project"""
        user = UserFactory.create()

        apps_contributed = cached_users.apps_contributed(user.id)

        assert apps_contributed == [], apps_contributed
示例#2
0
    def test_apps_contributed_no_contributions(self):
        """Test CACHE USERS apps_contributed returns empty list if the user has
        not contributed to any project"""
        user = UserFactory.create()

        apps_contributed = cached_users.apps_contributed(user.id)

        assert apps_contributed == [], apps_contributed
示例#3
0
def _show_own_profile(user):
    rank_and_score = cached_users.rank_and_score(user.id)
    user.rank = rank_and_score['rank']
    user.score = rank_and_score['score']
    user.total = cached_users.get_total_users()
    apps_contrib = cached_users.apps_contributed(user.id)
    apps_published, apps_draft = _get_user_apps(user.id)
    apps_published.extend(cached_users.hidden_apps(user.id))

    return render_template('account/profile.html', title=gettext("Profile"),
                          apps_contrib=apps_contrib,
                          apps_published=apps_published,
                          apps_draft=apps_draft)#,
示例#4
0
    def test_apps_contributed_contributions(self):
        """Test CACHE USERS apps_contributed returns a list of projects that has
        contributed to"""
        user = UserFactory.create()
        app_contributed = AppFactory.create()
        task = TaskFactory.create(app=app_contributed)
        TaskRunFactory.create(task=task, user=user)
        another_app = AppFactory.create()

        apps_contributed = cached_users.apps_contributed(user.id)

        assert len(apps_contributed) == 1
        assert apps_contributed[0]['short_name'] == app_contributed.short_name, apps_contributed
示例#5
0
    def test_apps_contributed_returns_fields(self):
        """Test CACHE USERS apps_contributed returns the info of the projects with
        the required fields"""
        user = UserFactory.create()
        app_contributed = AppFactory.create()
        task = TaskFactory.create(app=app_contributed)
        TaskRunFactory.create(task=task, user=user)
        fields = ('name', 'short_name', 'info', 'n_task_runs')

        apps_contributed = cached_users.apps_contributed(user.id)

        for field in fields:
            assert field in apps_contributed[0].keys(), field
示例#6
0
def _show_own_profile(user):
    rank_and_score = cached_users.rank_and_score(user.id)
    user.rank = rank_and_score['rank']
    user.score = rank_and_score['score']
    user.total = cached_users.get_total_users()
    apps_contrib = cached_users.apps_contributed(user.id)
    apps_published, apps_draft = _get_user_apps(user.id)
    apps_published.extend(cached_users.hidden_apps(user.id))

    return render_template('account/profile.html',
                           title=gettext("Profile"),
                           apps_contrib=apps_contrib,
                           apps_published=apps_published,
                           apps_draft=apps_draft)  #,
示例#7
0
    def test_apps_contributed_returns_fields(self):
        """Test CACHE USERS apps_contributed returns the info of the projects with
        the required fields"""
        user = UserFactory.create()
        app_contributed = AppFactory.create()
        task = TaskFactory.create(app=app_contributed)
        TaskRunFactory.create(task=task, user=user)
        fields = ('id', 'name', 'short_name', 'owner_id', 'description',
                  'overall_progress', 'n_tasks', 'n_volunteers', 'info')

        apps_contributed = cached_users.apps_contributed(user.id)

        for field in fields:
            assert field in apps_contributed[0].keys(), field
示例#8
0
    def test_apps_contributed_contributions(self):
        """Test CACHE USERS apps_contributed returns a list of projects that has
        contributed to"""
        user = UserFactory.create()
        app_contributed = AppFactory.create()
        task = TaskFactory.create(app=app_contributed)
        TaskRunFactory.create(task=task, user=user)
        another_app = AppFactory.create()

        apps_contributed = cached_users.apps_contributed(user.id)

        assert len(apps_contributed) == 1
        assert apps_contributed[0][
            'short_name'] == app_contributed.short_name, apps_contributed