From 7746b74e80f58bcddc9765520423a8d546e21ee2 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Aug 31 2017 13:50:47 +0000 Subject: star project: fix docstrings in lib and ui Signed-off-by: Vivek Anand --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 7e4b196..77b684a 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -4366,20 +4366,23 @@ def update_star_project(session, repo, star, user): :arg session: the session to use to connect to the database. :arg repo: a model.Project object representing the project to star/unstar + :arg star: '1' for starring and '0' for unstarring :arg user: string representing the user - :return: string containg 'starred' or 'unstarred' + :return: None or string containing 'You starred this project' or + 'You unstarred this project' ''' if not all([repo, user, star]): return user_obj = get_user(session, user) + msg = None if star == '1': msg = _star_project( session, repo=repo, user=user_obj, ) - else: + elif star == '0': msg = _unstar_project( session, repo=repo, @@ -4394,6 +4397,7 @@ def _star_project(session, repo, user): :arg session: Session object to connect to db with :arg repo: model.Project object representing the repo to star :arg user: model.User object who is starring this repo + :return: None or string containing 'You starred this project' ''' if not all([repo, user]): @@ -4409,8 +4413,10 @@ def _star_project(session, repo, user): def _unstar_project(session, repo, user): ''' Unstar a project :arg session: Session object to connect to db with - :arg repo: model.Project object representing the repo to star + :arg repo: model.Project object representing the repo to unstar :arg user: model.User object who is unstarring this repo + :return: None or string containing 'You unstarred this project' + or 'You never starred the project' ''' if not all([repo, user]): @@ -4428,8 +4434,9 @@ def _unstar_project(session, repo, user): def _get_stargazer_obj(session, repo, user): ''' Query the db to find stargazer object with given repo and user :arg session: Session object to connect to db with - :arg repo: model.Project object representing the repo to star - :arg user: model.User object who is starring this repo + :arg repo: model.Project object + :arg user: model.User object + :return: None or model.Star object ''' if not all([repo, user]): @@ -4451,7 +4458,7 @@ def has_starred(session, repo, user): :arg session: The session object to query the db with :arg repo: model.Project object for which the star is checked :arg user: The username of the user in question - :type user: str + :return: True if user has starred the project, False otherwise ''' if not all([repo, user]): diff --git a/pagure/ui/app.py b/pagure/ui/app.py index fae7d19..d1f6ae7 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -438,8 +438,7 @@ def view_user_stars(username): """ Shows the starred projects of the specified user. - :param username: The username whose stars we have to retrieve - :type username: str + :arg username: The username whose stars we have to retrieve """ user = _get_user(username=username) diff --git a/tests/test_pagure_flask_ui_star_project.py b/tests/test_pagure_flask_ui_star_project.py index 0b01bb2..5ef54b7 100644 --- a/tests/test_pagure_flask_ui_star_project.py +++ b/tests/test_pagure_flask_ui_star_project.py @@ -1,7 +1,7 @@ # coding=utf-8 """ - (c) 2016 - Copyright Red Hat Inc + (c) 2017 - Copyright Red Hat Inc Authors: Pierre-Yves Chibon @@ -93,7 +93,7 @@ class TestStarProjectUI(tests.SimplePagureTest): self._check_star_count(data=data, stars=0) def test_star_project_valid_star(self): - """ Test the star_project endpoint for correct start """ + """ Test the star_project endpoint for correct star """ user = tests.FakeUser() user.username = 'pingou'