From b0fb05304c22ba553186bca2418b6a7fed5e3837 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 06 2021 13:37:14 +0000 Subject: [PATCH 1/2] Port pagure to the latest version of python black Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index bb2c67a..c9646b1 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -75,8 +75,7 @@ def build_docs_section(name, endpoints): class APIERROR(enum.Enum): - """ Clast listing as Enum all the possible error thrown by the API. - """ + """Clast listing as Enum all the possible error thrown by the API.""" ENOCODE = "Variable message describing the issue" ENOPROJECT = "Project not found" @@ -171,7 +170,7 @@ def get_request_data(): def api_login_required(acls=None, optional=False): - """ Decorator used to indicate that authentication is required for some + """Decorator used to indicate that authentication is required for some API endpoint. :arg acls: A list of access control @@ -227,7 +226,7 @@ def api_login_required(acls=None, optional=False): def api_login_optional(acls=None): - """ Decorator used to indicate that authentication is optional for some + """Decorator used to indicate that authentication is optional for some API endpoint. """ @@ -284,7 +283,7 @@ def api_method(function): def get_page(): - """ Returns the page value specified in the request. + """Returns the page value specified in the request. Defaults to 1. raises APIERROR.EINVALIDREQ if the page provided isn't an integer raises APIERROR.EINVALIDREQ if the page provided is lower than 1 @@ -310,7 +309,7 @@ def get_page(): def get_per_page(): - """ Returns the per_page value specified in the request. + """Returns the per_page value specified in the request. Defaults to 20. raises APIERROR.EINVALIDREQ if the page provided isn't an integer raises APIERROR.EINVALIDPERPAGEVALUE if the page provided is lower diff --git a/pagure/api/boards.py b/pagure/api/boards.py index 669fd45..6ef91d7 100644 --- a/pagure/api/boards.py +++ b/pagure/api/boards.py @@ -91,7 +91,8 @@ def api_boards_view(repo, username=None, namespace=None): @API.route("///boards", methods=["POST"]) @API.route("/fork///boards", methods=["POST"]) @API.route( - "/fork////boards", methods=["POST"], + "/fork////boards", + methods=["POST"], ) @api_login_required(acls=["modify_project"]) @api_method @@ -228,7 +229,9 @@ def api_board_create(repo, username=None, namespace=None): if removing_names: try: pagure.lib.query.delete_board( - flask.g.session, project=repo, names=removing_names, + flask.g.session, + project=repo, + names=removing_names, ) flask.g.session.commit() except SQLAlchemyError as err: # pragma: no cover @@ -245,7 +248,8 @@ def api_board_create(repo, username=None, namespace=None): @API.route("///boards/delete", methods=["POST"]) @API.route("/fork///boards/delete", methods=["POST"]) @API.route( - "/fork////boards/delete", methods=["POST"], + "/fork////boards/delete", + methods=["POST"], ) @api_login_required(acls=["modify_project"]) @api_method @@ -311,7 +315,9 @@ def api_board_delete(repo, username=None, namespace=None): try: pagure.lib.query.delete_board( - flask.g.session, project=repo, names=names, + flask.g.session, + project=repo, + names=names, ) flask.g.session.commit() except SQLAlchemyError as err: # pragma: no cover @@ -451,7 +457,9 @@ def api_board_status(repo, board_name, username=None, namespace=None): if board is None: raise pagure.exceptions.APIError( - 404, error_code=APIERROR.EINVALIDREQ, errors="Board not found", + 404, + error_code=APIERROR.EINVALIDREQ, + errors="Board not found", ) data = flask.request.get_json() or {} @@ -611,7 +619,9 @@ def api_board_ticket_update_status( if board is None: raise pagure.exceptions.APIError( - 404, error_code=APIERROR.EINVALIDREQ, errors="Board not found", + 404, + error_code=APIERROR.EINVALIDREQ, + errors="Board not found", ) data = flask.request.get_json() or {} @@ -667,7 +677,8 @@ def api_board_ticket_update_status( "///boards//add_issue", methods=["POST"] ) @API.route( - "/fork///boards//add_issue", methods=["POST"], + "/fork///boards//add_issue", + methods=["POST"], ) @API.route( "/fork////boards//add_issue", @@ -737,7 +748,9 @@ def api_board_ticket_add_status( if board is None: raise pagure.exceptions.APIError( - 404, error_code=APIERROR.EINVALIDREQ, errors="Board not found", + 404, + error_code=APIERROR.EINVALIDREQ, + errors="Board not found", ) data = flask.request.get_json() or {} diff --git a/pagure/api/issue.py b/pagure/api/issue.py index 6025117..7286148 100644 --- a/pagure/api/issue.py +++ b/pagure/api/issue.py @@ -1600,7 +1600,10 @@ def api_view_issues_history_detailed_stats( _check_issue_tracker(repo) stats = pagure.lib.query.issues_history_stats( - flask.g.session, repo, detailed=True, weeks_range=weeks_range, + flask.g.session, + repo, + detailed=True, + weeks_range=weeks_range, ) jsonout = flask.jsonify({"stats": stats}) return jsonout diff --git a/pagure/api/project.py b/pagure/api/project.py index ecf831c..3fba02a 100644 --- a/pagure/api/project.py +++ b/pagure/api/project.py @@ -3026,8 +3026,7 @@ def api_get_project_webhook_token(repo, username=None, namespace=None): def _check_value(value): - """ Convert the provided value into a boolean, an int or leave it as it. - """ + """Convert the provided value into a boolean, an int or leave it as it.""" if str(value).lower() in ["true"]: value = True elif str(value).lower() in ["false"]: diff --git a/pagure/api/user.py b/pagure/api/user.py index 1d3ee30..7cfc7fa 100644 --- a/pagure/api/user.py +++ b/pagure/api/user.py @@ -25,8 +25,7 @@ from pagure.utils import is_true, validate_date, validate_date_range def _get_user(username): - """ Check user is valid or not - """ + """Check user is valid or not""" try: return pagure.lib.query.get_user(flask.g.session, username) except pagure.exceptions.PagureException: diff --git a/pagure/cli/admin.py b/pagure/cli/admin.py index b5d3a6e..258feb9 100644 --- a/pagure/cli/admin.py +++ b/pagure/cli/admin.py @@ -54,12 +54,12 @@ WATCH = { def _parser_refresh_gitolite(subparser): - """ Set up the CLI argument parser for the refresh-gitolite action. + """Set up the CLI argument parser for the refresh-gitolite action. :arg subparser: an argparse subparser allowing to have action's specific arguments - """ + """ local_parser = subparser.add_parser( "refresh-gitolite", help="Re-generate the gitolite config file" ) @@ -83,7 +83,7 @@ def _parser_refresh_gitolite(subparser): def _parser_refresh_ssh(subparser): - """ Set up the CLI argument parser for the refresh-ssh action. + """Set up the CLI argument parser for the refresh-ssh action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -97,7 +97,7 @@ def _parser_refresh_ssh(subparser): def _parser_clear_hook_token(subparser): - """ Set up the CLI argument parser for the clear-hook-token action. + """Set up the CLI argument parser for the clear-hook-token action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -111,7 +111,7 @@ def _parser_clear_hook_token(subparser): def _parser_admin_token_list(subparser): - """ Set up the CLI argument parser for the admin-token list action. + """Set up the CLI argument parser for the admin-token list action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -146,7 +146,7 @@ def _parser_admin_token_list(subparser): def _parser_admin_token_info(subparser): - """ Set up the CLI argument parser for the admin-token info action. + """Set up the CLI argument parser for the admin-token info action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -160,7 +160,7 @@ def _parser_admin_token_info(subparser): def _parser_admin_token_expire(subparser): - """ Set up the CLI argument parser for the admin-token expire action. + """Set up the CLI argument parser for the admin-token expire action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -181,7 +181,7 @@ def _parser_admin_token_expire(subparser): def _parser_admin_token_create(subparser): - """ Set up the CLI argument parser for the admin-token create action. + """Set up the CLI argument parser for the admin-token create action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -199,7 +199,7 @@ def _parser_admin_token_create(subparser): def _parser_admin_token_update(subparser): - """ Set up the CLI argument parser for the admin-token update action. + """Set up the CLI argument parser for the admin-token update action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -221,7 +221,7 @@ def _parser_admin_token_update(subparser): def _parser_admin_token(subparser): - """ Set up the CLI argument parser for the admin-token action. + """Set up the CLI argument parser for the admin-token action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -246,7 +246,7 @@ def _parser_admin_token(subparser): def _parser_get_watch(subparser): - """ Set up the CLI argument parser for the get-watch action. + """Set up the CLI argument parser for the get-watch action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -266,7 +266,7 @@ def _parser_get_watch(subparser): def _parser_update_watch(subparser): - """ Set up the CLI argument parser for the update-watch action. + """Set up the CLI argument parser for the update-watch action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -291,7 +291,7 @@ def _parser_update_watch(subparser): def _parser_read_only(subparser): - """ Set up the CLI argument parser for the read-only action. + """Set up the CLI argument parser for the read-only action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -317,7 +317,7 @@ def _parser_read_only(subparser): def _parser_new_group(subparser): - """ Set up the CLI argument parser for the new-group action. + """Set up the CLI argument parser for the new-group action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -340,7 +340,7 @@ def _parser_new_group(subparser): def _parser_list_groups(subparser): - """ Set up the CLI argument parser for the list-groups action. + """Set up the CLI argument parser for the list-groups action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -353,7 +353,7 @@ def _parser_list_groups(subparser): def _parser_block_user(subparser): - """ Set up the CLI argument parser for the block-user action. + """Set up the CLI argument parser for the block-user action. :arg subparser: an argparse subparser allowing to have action's specific arguments @@ -384,7 +384,7 @@ def _parser_block_user(subparser): def _parser_upload_repospanner_hooks(subparser): - """ Set up the CLI argument parser to upload repospanner hook. + """Set up the CLI argument parser to upload repospanner hook. Args: subparser: An argparse subparser @@ -399,7 +399,7 @@ def _parser_upload_repospanner_hooks(subparser): def _parser_ensure_project_hooks(subparser): - """ Set up the CLI argument parser to ensure project hooks are setup + """Set up the CLI argument parser to ensure project hooks are setup Args: subparser: An argparse subparser @@ -415,12 +415,12 @@ def _parser_ensure_project_hooks(subparser): def _parser_delete_project(subparser): - """ Set up the CLI argument parser for the delete-project action. + """Set up the CLI argument parser for the delete-project action. :arg subparser: an argparse subparser allowing to have action's specific arguments - """ + """ local_parser = subparser.add_parser( "delete-project", help="Delete the project specified" ) @@ -441,12 +441,12 @@ def _parser_delete_project(subparser): def _parser_create_branch(subparser): - """ Set up the CLI argument parser for the create-branch action. + """Set up the CLI argument parser for the create-branch action. :arg subparser: an argparse subparser allowing to have action's specific arguments - """ + """ local_parser = subparser.add_parser( "create-branch", help="Create the specified branch in the specified project", @@ -481,12 +481,12 @@ def _parser_create_branch(subparser): def _parser_set_default_branch(subparser): - """ Set up the CLI argument parser for the set-default-branch action. + """Set up the CLI argument parser for the set-default-branch action. :arg subparser: an argparse subparser allowing to have action's specific arguments - """ + """ local_parser = subparser.add_parser( "set-default-branch", help="Set the specified branch as default" ) @@ -505,12 +505,12 @@ def _parser_set_default_branch(subparser): def _parser_update_acls(subparser): - """ Set up the CLI argument parser for the update-acls action. + """Set up the CLI argument parser for the update-acls action. :arg subparser: an argparse subparser allowing to have action's specific arguments - """ + """ local_parser = subparser.add_parser( "update-acls", @@ -592,8 +592,7 @@ def parse_arguments(args=None): def _ask_confirmation(): - """ Ask to confirm an action. - """ + """Ask to confirm an action.""" action = input("Do you want to continue? [y/N]") return action.lower() in ["y", "yes"] @@ -604,8 +603,7 @@ def _get_input(text): def _get_project(arg_project, user=None): - """ From the project specified to the CLI, extract the actual project. - """ + """From the project specified to the CLI, extract the actual project.""" namespace = None if "/" in arg_project: if arg_project.count("/") > 1: @@ -634,7 +632,7 @@ def _check_project(_project, **kwargs): def do_generate_acl(args): - """ Regenerate the gitolite ACL file. + """Regenerate the gitolite ACL file. :arg args: the argparse object returned by ``parse_arguments()``. @@ -688,7 +686,7 @@ def do_generate_acl(args): def do_refresh_ssh(_): - """ Regenerate the user key files. + """Regenerate the user key files. :arg _: the argparse object returned by ``parse_arguments()``, which is ignored as there are no argument to pass to this action. @@ -706,7 +704,7 @@ def do_refresh_ssh(_): def do_generate_hook_token(_): - """ Regenerate the hook_token for each projects in the DB. + """Regenerate the hook_token for each projects in the DB. :arg _: the argparse object returned by ``parse_arguments()``, which is ignored as there are no argument to pass to this action. @@ -723,7 +721,7 @@ def do_generate_hook_token(_): def do_list_admin_token(args): - """ List the admin token. + """List the admin token. :arg args: the argparse object returned by ``parse_arguments()``. @@ -748,7 +746,7 @@ def do_list_admin_token(args): def do_info_admin_token(args): - """ Print out information about the specified API token. + """Print out information about the specified API token. :arg args: the argparse object returned by ``parse_arguments()``. @@ -766,7 +764,7 @@ def do_info_admin_token(args): def do_expire_admin_token(args): - """ Expire a specific admin token. + """Expire a specific admin token. :arg args: the argparse object returned by ``parse_arguments()``. @@ -795,7 +793,7 @@ def do_expire_admin_token(args): def do_update_admin_token(args): - """ Update the expiration date of an admin token. + """Update the expiration date of an admin token. :arg args: the argparse object returned by ``parse_arguments()``. @@ -843,7 +841,7 @@ def do_update_admin_token(args): def do_create_admin_token(args): - """ Create a new admin token. + """Create a new admin token. :arg args: the argparse object returned by ``parse_arguments()``. @@ -892,7 +890,7 @@ def do_create_admin_token(args): def do_delete_project(args): - """ Delete a project. + """Delete a project. :arg args: the argparse object returned by ``parse_arguments()``. @@ -928,7 +926,7 @@ def do_delete_project(args): def do_update_acls(args): - """ Update the ACLs in the database from the list present in the + """Update the ACLs in the database from the list present in the configuration file. :arg args: the argparse object returned by ``parse_arguments()``. @@ -944,7 +942,7 @@ def do_update_acls(args): def do_get_watch_status(args): - """ Get the watch status of an user on a project. + """Get the watch status of an user on a project. :arg args: the argparse object returned by ``parse_arguments()``. @@ -981,7 +979,7 @@ def do_get_watch_status(args): def do_update_watch_status(args): - """ Update the watch status of an user on a project. + """Update the watch status of an user on a project. :arg args: the argparse object returned by ``parse_arguments()``. @@ -1025,7 +1023,7 @@ def do_update_watch_status(args): def do_read_only(args): - """ Set or update the read-only status of a project. + """Set or update the read-only status of a project. :arg args: the argparse object returned by ``parse_arguments()``. @@ -1067,7 +1065,7 @@ def do_read_only(args): def do_new_group(args): - """ Create a new group in this pagure instance. + """Create a new group in this pagure instance. :arg args: the argparse object returned by ``parse_arguments()``. @@ -1112,7 +1110,7 @@ def do_new_group(args): def do_list_groups(args): - """ Lists existing groups in this pagure instance. + """Lists existing groups in this pagure instance. :arg args: the argparse object returned by ``parse_arguments()``. @@ -1128,7 +1126,7 @@ def do_list_groups(args): def do_list_blocked_users(args): - """ List all the blocked users. + """List all the blocked users. :arg args: the argparse object returned by ``parse_arguments()``. @@ -1163,7 +1161,7 @@ def do_list_blocked_users(args): def do_block_user(args): - """ Block the specified user from all interactions with pagure until the + """Block the specified user from all interactions with pagure until the specified date. :arg args: the argparse object returned by ``parse_arguments()``. @@ -1207,7 +1205,7 @@ def do_block_user(args): def do_upload_repospanner_hooks(args): - """ Upload hooks to repoSpanner + """Upload hooks to repoSpanner Args: args (argparse.Namespace): Parsed arguments @@ -1253,7 +1251,7 @@ def do_upload_repospanner_hooks(args): def do_ensure_project_hooks(args): - """ Ensures that all projects have their hooks setup + """Ensures that all projects have their hooks setup Args: args (argparse.Namespace): Parsed arguments @@ -1272,7 +1270,7 @@ def do_ensure_project_hooks(args): def do_create_branch(args): - """ Creates the specified git branch + """Creates the specified git branch Args: args (argparse.Namespace): Parsed arguments @@ -1323,7 +1321,7 @@ def do_create_branch(args): def do_set_default_branch(args): - """ Sets the specified git branch as default + """Sets the specified git branch as default Args: args (argparse.Namespace): Parsed arguments diff --git a/pagure/doc_utils.py b/pagure/doc_utils.py index 3238120..3867222 100644 --- a/pagure/doc_utils.py +++ b/pagure/doc_utils.py @@ -56,8 +56,7 @@ def modify_rst(rst, view_file_url=None): def modify_html(html): - """ Perform style substitutions where docutils doesn't do what we want. - """ + """Perform style substitutions where docutils doesn't do what we want.""" substitutions = { '': "", @@ -98,7 +97,7 @@ def convert_doc(rst_string, view_file_url=None): def convert_readme(content, ext, view_file_url=None): - """ Convert the provided content according to the extension of the file + """Convert the provided content according to the extension of the file provided. """ output = pagure.lib.encoding_utils.decode(ktc.to_bytes(content)) diff --git a/pagure/docs_server.py b/pagure/docs_server.py index dc5e297..fdb213b 100644 --- a/pagure/docs_server.py +++ b/pagure/docs_server.py @@ -81,7 +81,7 @@ TMPL_HTML = """ def __get_tree(repo_obj, tree, filepath, index=0, extended=False): - """ Retrieve the entry corresponding to the provided filename in a + """Retrieve the entry corresponding to the provided filename in a given tree. """ filename = filepath[index] @@ -164,8 +164,7 @@ def __get_tree_and_content(repo_obj, commit, path): @APP.route("/fork///") @APP.route("/fork/.//") def view_docs(repo, username=None, namespace=None, filename=None): - """ Display the documentation - """ + """Display the documentation""" if "." in repo: namespace, repo = repo.split(".", 1) diff --git a/pagure/exceptions.py b/pagure/exceptions.py index ed2fcc4..3d3e219 100644 --- a/pagure/exceptions.py +++ b/pagure/exceptions.py @@ -12,7 +12,7 @@ from __future__ import unicode_literals, absolute_import class PagureException(Exception): - """ Parent class of all the exception for all Pagure specific + """Parent class of all the exception for all Pagure specific exceptions. """ @@ -20,7 +20,7 @@ class PagureException(Exception): class RepoExistsException(PagureException): - """ Exception thrown when trying to create a repository that already + """Exception thrown when trying to create a repository that already exists. """ @@ -28,7 +28,7 @@ class RepoExistsException(PagureException): class ProjectBlackListedException(PagureException): - """ Exception thrown when trying to create a repository but, that repository + """Exception thrown when trying to create a repository but, that repository name has been blacklisted """ @@ -36,14 +36,13 @@ class ProjectBlackListedException(PagureException): class AccessLevelNotFound(PagureException): - """ Exception raised when the access level asked is not allowed on pagure - """ + """Exception raised when the access level asked is not allowed on pagure""" pass class FileNotFoundException(PagureException): - """ Exception thrown when the desired file is not found. + """Exception thrown when the desired file is not found. This exception is found when the file is searched in a git repo or when setting up one of the git hook. @@ -64,7 +63,7 @@ class APIError(PagureException): class BranchNotFoundException(PagureException): - """ Exception thrown when trying to use a branch that could not be + """Exception thrown when trying to use a branch that could not be found in a repository. """ @@ -72,14 +71,13 @@ class BranchNotFoundException(PagureException): class PagureEvException(PagureException): - """ Exceptions used in the pagure_stream_server. - """ + """Exceptions used in the pagure_stream_server.""" pass class GitConflictsException(PagureException): - """ Exception used when trying to pull on a repo and that leads to + """Exception used when trying to pull on a repo and that leads to conflicts. """ @@ -93,8 +91,8 @@ class HookInactiveException(PagureException): class NoCorrespondingPR(PagureException): - """ Exception raised when no pull-request is found with the given - information. """ + """Exception raised when no pull-request is found with the given + information.""" pass @@ -106,7 +104,7 @@ class InvalidObjectException(PagureException): class PagureEncodingException(PagureException, ValueError): - """ Exception raised none of the encoding guessed could be applied to + """Exception raised none of the encoding guessed could be applied to the content examined """ diff --git a/pagure/flask_app.py b/pagure/flask_app.py index efeb564..bece3ca 100644 --- a/pagure/flask_app.py +++ b/pagure/flask_app.py @@ -210,8 +210,7 @@ def create_app(config=None): def generate_user_key_files(): - """ Regenerate the key files used by gitolite. - """ + """Regenerate the key files used by gitolite.""" gitolite_home = pagure_config.get("GITOLITE_HOME", None) if gitolite_home: users = pagure.lib.query.search_user(flask.g.session) @@ -227,7 +226,7 @@ def generate_user_key_files(): def admin_session_timedout(): - """ Check if the current user has been authenticated for more than what + """Check if the current user has been authenticated for more than what is allowed (defaults to 15 minutes). If it is the case, the user is logged out and the method returns True, otherwise it returns False. @@ -248,8 +247,7 @@ def admin_session_timedout(): def logout(): - """ Log out the user currently logged in in the application - """ + """Log out the user currently logged in in the application""" auth = pagure_config.get("PAGURE_AUTH", None) if auth in ["fas", "openid"]: if hasattr(flask.g, "fas_user") and flask.g.fas_user is not None: @@ -521,7 +519,7 @@ def auth_logout(): # pragma: no cover # pylint: disable=unused-argument def end_request(exception=None): - """ This method is called at the end of each request. + """This method is called at the end of each request. Remove the DB session at the end of each request. Runs a garbage collection to get rid of any open pygit2 handles. @@ -555,8 +553,7 @@ def after_request(response): def _get_user(username): - """ Check if user exists or not - """ + """Check if user exists or not""" try: return pagure.lib.query.get_user(flask.g.session, username) except pagure.exceptions.PagureException as e: diff --git a/pagure/forms.py b/pagure/forms.py index 7e30115..a7ff9d9 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -74,7 +74,7 @@ def convert_value(val): class MultipleEmail(wtforms.validators.Email): - """ Split the value by comma and run them through the email validator + """Split the value by comma and run them through the email validator of wtforms. """ @@ -87,15 +87,14 @@ class MultipleEmail(wtforms.validators.Email): def user_namespace_if_private(form, field): - """ Check if the data in the field is the same as in the password field. - """ + """Check if the data in the field is the same as in the password field.""" if form.private.data: field.data = flask.g.fas_user.username def file_virus_validator(form, field): - """ Checks for virus in the file from flask request object, - raises wtf.ValidationError if virus is found else None. """ + """Checks for virus in the file from flask request object, + raises wtf.ValidationError if virus is found else None.""" if not pagure_config["VIRUS_SCAN_ATTACHMENTS"]: return @@ -136,7 +135,8 @@ class ProjectFormSimplified(PagureForm): """ Form to edit the description of a project. """ description = wtforms.StringField( - "Description", [wtforms.validators.DataRequired()], + "Description", + [wtforms.validators.DataRequired()], ) url = wtforms.StringField( "URL", @@ -206,11 +206,12 @@ class ProjectForm(ProjectFormSimplified): default=pagure_config["REPOSPANNER_NEW_REPO"], ) default_branch = wtforms.StringField( - "Default branch", [wtforms.validators.optional()], + "Default branch", + [wtforms.validators.optional()], ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -250,9 +251,13 @@ class ProjectForm(ProjectFormSimplified): class IssueFormSimplied(PagureForm): """ Form to create or edit an issue. """ - title = wtforms.StringField("Title", [wtforms.validators.DataRequired()],) + title = wtforms.StringField( + "Title", + [wtforms.validators.DataRequired()], + ) issue_content = wtforms.TextAreaField( - "Content", [wtforms.validators.DataRequired()], + "Content", + [wtforms.validators.DataRequired()], ) private = wtforms.BooleanField( "Private", [wtforms.validators.optional()], false_values=FALSE_VALUES @@ -271,7 +276,7 @@ class IssueFormSimplied(PagureForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -297,7 +302,7 @@ class IssueForm(IssueFormSimplied): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -311,7 +316,10 @@ class IssueForm(IssueFormSimplied): class RequestPullForm(PagureForm): """ Form to create a pull request. """ - title = wtforms.StringField("Title", [wtforms.validators.DataRequired()],) + title = wtforms.StringField( + "Title", + [wtforms.validators.DataRequired()], + ) initial_comment = wtforms.TextAreaField( "Initial Comment", [wtforms.validators.Optional()] ) @@ -333,10 +341,12 @@ class RemoteRequestPullForm(RequestPullForm): ], ) branch_from = wtforms.StringField( - "Git branch", [wtforms.validators.DataRequired()], + "Git branch", + [wtforms.validators.DataRequired()], ) branch_to = wtforms.StringField( - "Git branch to merge in", [wtforms.validators.DataRequired()], + "Git branch to merge in", + [wtforms.validators.DataRequired()], ) @@ -395,7 +405,7 @@ class StatusForm(PagureForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -422,7 +432,7 @@ class MilestoneForm(PagureForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -450,7 +460,7 @@ class NewTokenForm(PagureForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -507,7 +517,7 @@ class UpdateIssueForm(PagureForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -544,7 +554,8 @@ class AddPullRequestCommentForm(PagureForm): requestid = wtforms.HiddenField("requestid") tree_id = wtforms.HiddenField("treeid") comment = wtforms.TextAreaField( - "Comment", [wtforms.validators.DataRequired()], + "Comment", + [wtforms.validators.DataRequired()], ) @@ -614,13 +625,16 @@ class AddUserForm(PagureForm): """ Form to add a user to a project. """ user = wtforms.StringField( - "Username", [wtforms.validators.DataRequired()], + "Username", + [wtforms.validators.DataRequired()], ) access = wtforms.StringField( - "Access Level", [wtforms.validators.DataRequired()], + "Access Level", + [wtforms.validators.DataRequired()], ) branches = wtforms.StringField( - "Git branches", [wtforms.validators.Optional()], + "Git branches", + [wtforms.validators.Optional()], ) @@ -628,7 +642,8 @@ class AddUserToGroupForm(PagureForm): """ Form to add a user to a pagure group. """ user = wtforms.StringField( - "Username", [wtforms.validators.DataRequired()], + "Username", + [wtforms.validators.DataRequired()], ) @@ -636,7 +651,8 @@ class AssignIssueForm(PagureForm): """ Form to assign an user to an issue. """ assignee = wtforms.StringField( - "Assignee", [wtforms.validators.Optional()], + "Assignee", + [wtforms.validators.Optional()], ) @@ -651,10 +667,12 @@ class AddGroupForm(PagureForm): ], ) access = wtforms.StringField( - "Access Level", [wtforms.validators.DataRequired()], + "Access Level", + [wtforms.validators.DataRequired()], ) branches = wtforms.StringField( - "Git branches", [wtforms.validators.Optional()], + "Git branches", + [wtforms.validators.Optional()], ) @@ -673,7 +691,8 @@ class ModifyACLForm(PagureForm): choices=[("user", "User"), ("group", "Group")], ) name = wtforms.StringField( - "User- or Groupname", [wtforms.validators.DataRequired()], + "User- or Groupname", + [wtforms.validators.DataRequired()], ) acl = wtforms.SelectField( "ACL type", @@ -766,7 +785,7 @@ class NewGroupForm(EditGroupForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -793,7 +812,7 @@ class EditFileForm(PagureForm): branch = wtforms.StringField("Branch", [wtforms.validators.DataRequired()]) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -812,7 +831,7 @@ class DefaultBranchForm(PagureForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -831,7 +850,7 @@ class DefaultPriorityForm(PagureForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -843,11 +862,11 @@ class DefaultPriorityForm(PagureForm): class EditCommentForm(PagureForm): - """ Form to verify that comment is not empty - """ + """Form to verify that comment is not empty""" update_comment = wtforms.TextAreaField( - "Comment ", [wtforms.validators.DataRequired()], + "Comment ", + [wtforms.validators.DataRequired()], ) @@ -866,17 +885,16 @@ class ForkRepoForm(PagureForm): class AddReportForm(PagureForm): - """ Form to verify that comment is not empty - """ + """Form to verify that comment is not empty""" report_name = wtforms.TextAreaField( - "Report name", [wtforms.validators.DataRequired()], + "Report name", + [wtforms.validators.DataRequired()], ) class PublicNotificationForm(PagureForm): - """ Form to verify that comment is not empty - """ + """Form to verify that comment is not empty""" issue_notifs = wtforms.TextAreaField( "Public issue notification", @@ -932,7 +950,8 @@ class AddGitTagForm(PagureForm): """ Form to create a new git tag. """ tagname = wtforms.StringField( - "Name of the tag", [wtforms.validators.DataRequired()], + "Name of the tag", + [wtforms.validators.DataRequired()], ) commit_hash = wtforms.StringField( "Hash of the commit to tag", [wtforms.validators.DataRequired()] diff --git a/pagure/hooks/__init__.py b/pagure/hooks/__init__.py index 6de55b9..c0ef67a 100644 --- a/pagure/hooks/__init__.py +++ b/pagure/hooks/__init__.py @@ -27,7 +27,7 @@ from pagure.lib.plugins import get_enabled_plugins class RequiredIf(wtforms.validators.DataRequired): - """ Wtforms validator setting a field as required if another field + """Wtforms validator setting a field as required if another field has a value. """ @@ -64,7 +64,7 @@ class BaseRunner(object): def runhook( cls, session, username, hooktype, project, repotype, repodir, changes ): - """ Run a specific hook on a project. + """Run a specific hook on a project. By default, this calls out to the pre_receive, update or post_receive functions as appropriate. @@ -115,7 +115,7 @@ class BaseRunner(object): @staticmethod def pre_receive(session, username, project, repotype, repodir, changes): - """ Run the pre-receive tasks of a hook. + """Run the pre-receive tasks of a hook. For args, see BaseRunner.runhook. """ @@ -123,7 +123,7 @@ class BaseRunner(object): @staticmethod def update(session, username, project, repotype, repodir, changes): - """ Run the update tasks of a hook. + """Run the update tasks of a hook. For args, see BaseRunner.runhook. Note that the "changes" list has exactly one element. @@ -132,7 +132,7 @@ class BaseRunner(object): @staticmethod def post_receive(session, username, project, repotype, repodir, changes): - """ Run the post-receive tasks of a hook. + """Run the post-receive tasks of a hook. For args, see BaseRunner.runhook. """ @@ -154,7 +154,7 @@ class BaseHook(object): @classmethod def set_up(cls, project): - """ Install the generic post-receive hook that allow us to call + """Install the generic post-receive hook that allow us to call multiple post-receive hooks as set per plugin. """ if project.is_on_repospanner: @@ -186,7 +186,7 @@ class BaseHook(object): @classmethod def base_install(cls, repopaths, dbobj, hook_name, filein): - """ Method called to install the hook for a project. + """Method called to install the hook for a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed @@ -222,7 +222,7 @@ class BaseHook(object): @classmethod def base_remove(cls, repopaths, hook_name): - """ Method called to remove the hook of a project. + """Method called to remove the hook of a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed @@ -240,7 +240,7 @@ class BaseHook(object): @classmethod def install(cls, *args): - """ In sub-classess, this can be used for installation of the hook. + """In sub-classess, this can be used for installation of the hook. However, this is not required anymore for hooks with a Runner. This class is here as backwards compatibility. @@ -252,7 +252,7 @@ class BaseHook(object): @classmethod def remove(cls, *args): - """ In sub-classess, this can be used for removal of the hook. + """In sub-classess, this can be used for removal of the hook. However, this is not required anymore for hooks with a Runner. This class is here as backwards compatibility. @@ -264,7 +264,7 @@ class BaseHook(object): @classmethod def is_enabled_for(cls, project): - """ Determine if this hook should be run for given project. + """Determine if this hook should be run for given project. On some Pagure instances, some hooks should be run on all projects that fulfill certain criteria. It is therefore not necessary to keep @@ -294,7 +294,7 @@ def run_project_hooks( is_internal, pull_request, ): - """ Function to run the hooks on a project + """Function to run the hooks on a project This will first call all the plugins with a Runner on the project, and afterwards, for a non-repoSpanner repo, run all hooks/.* @@ -470,7 +470,7 @@ def run_project_hooks( def extract_changes(from_stdin): - """ Extracts a changes dict from either stdin or argv + """Extracts a changes dict from either stdin or argv Args: from_stdin (bool): Whether to use stdin. If false, uses argv @@ -491,7 +491,7 @@ def extract_changes(from_stdin): def run_hook_file(hooktype): - """ Runs a specific hook by grabbing the changes and running functions. + """Runs a specific hook by grabbing the changes and running functions. Args: hooktype (string): The name of the hook to run: pre-receive, update diff --git a/pagure/hooks/default.py b/pagure/hooks/default.py index 7474d43..5813f7c 100644 --- a/pagure/hooks/default.py +++ b/pagure/hooks/default.py @@ -32,7 +32,7 @@ FEDMSG_INIT = False def send_fedmsg_notifications(project, topic, msg): - """ If the user or admin asked for fedmsg notifications on commit, this will + """If the user or admin asked for fedmsg notifications on commit, this will do it. """ @@ -75,7 +75,7 @@ def send_fedmsg_notifications(project, topic, msg): def send_stomp_notifications(project, topic, msg): - """ If the user or admin asked for stomp notifications on commit, this will + """If the user or admin asked for stomp notifications on commit, this will do it. """ always_stomp = _config.get("ALWAYS_STOMP_ON_COMMITS") or None @@ -89,7 +89,7 @@ def send_stomp_notifications(project, topic, msg): def send_mqtt_notifications(project, topic, msg): - """ If the user or admin asked for mqtt notifications on commit, this will + """If the user or admin asked for mqtt notifications on commit, this will do it. """ always_mqtt = _config.get("ALWAYS_MQTT_ON_COMMITS") or None @@ -103,7 +103,7 @@ def send_mqtt_notifications(project, topic, msg): def send_webhook_notifications(project, topic, msg): - """ If the user asked for webhook notifications on commit, this will + """If the user asked for webhook notifications on commit, this will do it. """ if project.settings.get("Web-hooks"): @@ -125,8 +125,7 @@ def send_webhook_notifications(project, topic, msg): def send_action_notification( session, subject, action, project, repodir, user, refname, rev ): - """ Send out-going notifications about the branch/tag. - """ + """Send out-going notifications about the branch/tag.""" email = pagure.lib.git.get_author_email(rev, repodir) name = pagure.lib.git.get_author(rev, repodir) author = pagure.lib.query.search_user(session, email=email) @@ -163,7 +162,7 @@ def send_action_notification( def send_notifications( session, project, repodir, user, refname, revs, forced, oldrev ): - """ Send out-going notifications about the commits that have just been + """Send out-going notifications about the commits that have just been pushed. """ @@ -233,7 +232,7 @@ def send_notifications( def inform_pull_request_urls( session, project, commits, refname, default_branch, username ): - """ Inform the user about the URLs to open a new pull-request or visit + """Inform the user about the URLs to open a new pull-request or visit the existing one. """ target_repo = project @@ -304,7 +303,7 @@ class DefaultRunner(BaseRunner): @staticmethod def post_receive(session, username, project, repotype, repodir, changes): - """ Run the default post-receive hook. + """Run the default post-receive hook. For args, see BaseRunner.runhook. """ diff --git a/pagure/hooks/fedmsg_hook.py b/pagure/hooks/fedmsg_hook.py index 5d5a7f8..3752bed 100644 --- a/pagure/hooks/fedmsg_hook.py +++ b/pagure/hooks/fedmsg_hook.py @@ -25,7 +25,7 @@ from pagure.lib.model import BASE, Project class FedmsgTable(BASE): - """ Stores information about the fedmsg hook deployed on a project. + """Stores information about the fedmsg hook deployed on a project. Table -- hook_fedmsg """ @@ -56,7 +56,7 @@ class FedmsgTable(BASE): class FedmsgRunner(BaseRunner): - """ Runner for the fedmsg hook, it does nothing as all the magic is + """Runner for the fedmsg hook, it does nothing as all the magic is part of the default hook/runner. """ @@ -94,7 +94,7 @@ class Fedmsg(BaseHook): @classmethod def install(cls, project, dbobj): - """ Method called to install the hook for a project. + """Method called to install the hook for a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed @@ -109,7 +109,7 @@ class Fedmsg(BaseHook): @classmethod def remove(cls, project): - """ Method called to remove the hook of a project. + """Method called to remove the hook of a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed diff --git a/pagure/hooks/irc.py b/pagure/hooks/irc.py index 2725b31..9c324ac 100644 --- a/pagure/hooks/irc.py +++ b/pagure/hooks/irc.py @@ -27,7 +27,7 @@ from pagure.utils import get_repo_path class IrcTable(BASE): - """ Stores information about the irc hook deployed on a project. + """Stores information about the irc hook deployed on a project. Table -- hook_irc """ @@ -112,7 +112,7 @@ class Hook(BaseHook): @classmethod def install(cls, project, dbobj): - """ Method called to install the hook for a project. + """Method called to install the hook for a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed @@ -130,7 +130,7 @@ class Hook(BaseHook): @classmethod def remove(cls, project): - """ Method called to remove the hook of a project. + """Method called to remove the hook of a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed diff --git a/pagure/hooks/mail.py b/pagure/hooks/mail.py index bbb899e..f32c94d 100644 --- a/pagure/hooks/mail.py +++ b/pagure/hooks/mail.py @@ -29,7 +29,7 @@ from pagure.lib.model import BASE, Project class MailTable(BASE): - """ Stores information about the mail hook deployed on a project. + """Stores information about the mail hook deployed on a project. Table -- hook_mail """ @@ -70,7 +70,7 @@ class MailForm(FlaskForm): class MailRunner(BaseRunner): @staticmethod def post_receive(session, username, project, repotype, repodir, changes): - """ Run the multimail post-receive hook. + """Run the multimail post-receive hook. For args, see BaseRunner.runhook. """ diff --git a/pagure/hooks/mirror_hook.py b/pagure/hooks/mirror_hook.py index 1a577b0..0130ce6 100644 --- a/pagure/hooks/mirror_hook.py +++ b/pagure/hooks/mirror_hook.py @@ -30,7 +30,7 @@ _config = pagure.config.reload_config() class MirrorTable(BASE): - """ Stores information about the mirroring hook deployed on a project. + """Stores information about the mirroring hook deployed on a project. Table -- mirror_pagure """ @@ -69,7 +69,7 @@ class MirrorRunner(BaseRunner): @staticmethod def post_receive(session, username, project, repotype, repodir, changes): - """ Run the default post-receive hook. + """Run the default post-receive hook. For args, see BaseRunner.runhook. """ @@ -150,7 +150,7 @@ class MirrorHook(BaseHook): @classmethod def install(cls, project, dbobj): - """ Method called to install the hook for a project. + """Method called to install the hook for a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed @@ -167,7 +167,7 @@ class MirrorHook(BaseHook): @classmethod def remove(cls, project): - """ Method called to remove the hook of a project. + """Method called to remove the hook of a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed diff --git a/pagure/hooks/pagure_ci.py b/pagure/hooks/pagure_ci.py index 795a050..aa7a383 100644 --- a/pagure/hooks/pagure_ci.py +++ b/pagure/hooks/pagure_ci.py @@ -27,7 +27,7 @@ from pagure.lib.model import BASE, Project class PagureCITable(BASE): - """ Stores information about the CI linked to on a project. + """Stores information about the CI linked to on a project. Table -- hook_pagure_ci """ @@ -65,7 +65,7 @@ class PagureCITable(BASE): class PagureCIRunner(BaseRunner): - """ Runner for the pagure-ci hook, it does nothing as the magic is part + """Runner for the pagure-ci hook, it does nothing as the magic is part of the CI system itself (to see if there was a commit made and build if so). """ @@ -151,7 +151,7 @@ class PagureCiForm(FlaskForm): ) def __init__(self, *args, **kwargs): - """ Calls the default constructor with the normal argument but + """Calls the default constructor with the normal argument but uses the list of collection provided to fill the choices of the drop-down list. """ @@ -179,14 +179,14 @@ class PagureCi(BaseHook): @classmethod def set_up(cls, project): - """ Install the generic post-receive hook that allow us to call + """Install the generic post-receive hook that allow us to call multiple post-receive hooks as set per plugin. """ pass @classmethod def install(cls, project, dbobj): - """ Method called to install the hook for a project. + """Method called to install the hook for a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed @@ -198,7 +198,7 @@ class PagureCi(BaseHook): @classmethod def remove(cls, project): - """ Method called to remove the hook of a project. + """Method called to remove the hook of a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed diff --git a/pagure/hooks/pagure_force_commit.py b/pagure/hooks/pagure_force_commit.py index ac69004..c0dd4a6 100644 --- a/pagure/hooks/pagure_force_commit.py +++ b/pagure/hooks/pagure_force_commit.py @@ -26,7 +26,7 @@ from pagure.lib.model import BASE, Project class PagureForceCommitTable(BASE): - """ Stores information about the pagure hook deployed on a project. + """Stores information about the pagure hook deployed on a project. Table -- hook_pagure_force_commit """ @@ -64,7 +64,7 @@ class PagureForceCommitRunner(BaseRunner): @staticmethod def pre_receive(session, username, project, repotype, repodir, changes): - """ Run the pre-receive tasks of a hook. + """Run the pre-receive tasks of a hook. For args, see BaseRunner.runhook. """ diff --git a/pagure/hooks/pagure_hook.py b/pagure/hooks/pagure_hook.py index eef463f..24f3bab 100644 --- a/pagure/hooks/pagure_hook.py +++ b/pagure/hooks/pagure_hook.py @@ -36,7 +36,7 @@ pagure_config = pagure.config.reload_config() class PagureTable(BASE): - """ Stores information about the pagure hook deployed on a project. + """Stores information about the pagure hook deployed on a project. Table -- hook_pagure """ @@ -148,8 +148,8 @@ def relates_commit(session, username, commitid, issue, app_url=None): def fixes_relation(session, username, commitid, relation, app_url=None): - """ Add a comment to an issue or PR that this commit fixes it and update - the status if the commit is in the master branch. """ + """Add a comment to an issue or PR that this commit fixes it and update + the status if the commit is in the master branch.""" url = "../c/%s" % commitid[:8] if app_url: @@ -216,7 +216,7 @@ class PagureRunner(BaseRunner): @staticmethod def post_receive(session, username, project, repotype, repodir, changes): - """ Run the default post-receive hook. + """Run the default post-receive hook. For args, see BaseRunner.runhook. """ diff --git a/pagure/hooks/pagure_no_new_branches.py b/pagure/hooks/pagure_no_new_branches.py index 717c8ef..82df5fa 100644 --- a/pagure/hooks/pagure_no_new_branches.py +++ b/pagure/hooks/pagure_no_new_branches.py @@ -25,7 +25,7 @@ from pagure.lib.model import BASE, Project class PagureNoNewBranchesTable(BASE): - """ Stores information about the pagure hook deployed on a project. + """Stores information about the pagure hook deployed on a project. Table -- hook_pagure_no_new_branches """ @@ -60,7 +60,7 @@ class PagureNoNewBranchRunner(BaseRunner): @staticmethod def pre_receive(session, username, project, repotype, repodir, changes): - """ Run the pre-receive tasks of a hook. + """Run the pre-receive tasks of a hook. For args, see BaseRunner.runhook. """ diff --git a/pagure/hooks/pagure_request_hook.py b/pagure/hooks/pagure_request_hook.py index 776601a..152bcfd 100644 --- a/pagure/hooks/pagure_request_hook.py +++ b/pagure/hooks/pagure_request_hook.py @@ -27,7 +27,7 @@ from pagure.lib.model import BASE, Project class PagureRequestsTable(BASE): - """ Stores information about the pagure requests hook deployed on a + """Stores information about the pagure requests hook deployed on a project. Table -- hook_pagure_requests @@ -59,13 +59,13 @@ class PagureRequestsTable(BASE): class PagureRequestRunner(BaseRunner): - """ Runner for the hook updating the db about requests on push to the + """Runner for the hook updating the db about requests on push to the git repo containing the meta-data about pull-requests. """ @staticmethod def post_receive(session, username, project, repotype, repodir, changes): - """ Run the default post-receive hook. + """Run the default post-receive hook. For args, see BaseRunner.runhook. """ diff --git a/pagure/hooks/pagure_ticket_hook.py b/pagure/hooks/pagure_ticket_hook.py index 9bd6672..bbecc5e 100644 --- a/pagure/hooks/pagure_ticket_hook.py +++ b/pagure/hooks/pagure_ticket_hook.py @@ -31,7 +31,7 @@ from pagure.lib.model import BASE, Project class PagureTicketsTable(BASE): - """ Stores information about the pagure tickets hook deployed on a project. + """Stores information about the pagure tickets hook deployed on a project. Table -- hook_pagure_tickets """ @@ -66,7 +66,7 @@ class PagureTicketRunner(BaseRunner): @staticmethod def post_receive(session, username, project, repotype, repodir, changes): - """ Run the post-receive tasks of a hook. + """Run the post-receive tasks of a hook. For args, see BaseRunner.runhook. """ @@ -128,7 +128,7 @@ class PagureTicketHook(BaseHook): @classmethod def set_up(cls, project): - """ Install the generic post-receive hook that allow us to call + """Install the generic post-receive hook that allow us to call multiple post-receive hooks as set per plugin. """ repopath = os.path.join(pagure_config["TICKETS_FOLDER"], project.path) @@ -152,7 +152,7 @@ class PagureTicketHook(BaseHook): @classmethod def install(cls, project, dbobj): - """ Method called to install the hook for a project. + """Method called to install the hook for a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed @@ -168,7 +168,7 @@ class PagureTicketHook(BaseHook): @classmethod def remove(cls, project): - """ Method called to remove the hook of a project. + """Method called to remove the hook of a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed diff --git a/pagure/hooks/pagure_unsigned_commits.py b/pagure/hooks/pagure_unsigned_commits.py index bc3668f..072ff57 100644 --- a/pagure/hooks/pagure_unsigned_commits.py +++ b/pagure/hooks/pagure_unsigned_commits.py @@ -30,7 +30,7 @@ _config = pagure.config.reload_config() class PagureUnsignedCommitTable(BASE): - """ Stores information about the pagure hook deployed on a project. + """Stores information about the pagure hook deployed on a project. Table -- hook_pagure_unsigned_commit """ @@ -66,7 +66,7 @@ class PagureUnsignerRunner(BaseRunner): @staticmethod def pre_receive(session, username, project, repotype, repodir, changes): - """ Run the pre-receive tasks of a hook. + """Run the pre-receive tasks of a hook. For args, see BaseRunner.runhook. """ diff --git a/pagure/hooks/rtd.py b/pagure/hooks/rtd.py index 41b6d6f..5fd8235 100644 --- a/pagure/hooks/rtd.py +++ b/pagure/hooks/rtd.py @@ -30,7 +30,7 @@ _config = pagure.config.config class RtdTable(BASE): - """ Stores information about the pagure hook deployed on a project. + """Stores information about the pagure hook deployed on a project. Table -- hook_rtd """ @@ -102,7 +102,7 @@ will have to provide below. class RtdRunner(BaseRunner): @staticmethod def post_receive(session, username, project, repotype, repodir, changes): - """ Perform the RTD Post Receive hook. + """Perform the RTD Post Receive hook. For arguments, see BaseRunner.runhook. """ diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index 25b6d87..306605a 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -61,7 +61,7 @@ MERGE_OPTIONS = { def internal_access_only(function): - """ Decorator used to check if the request is iternal or not. + """Decorator used to check if the request is iternal or not. The request must either come from one of the addresses listed in IP_ALLOWED_INTERNAL or it must have the "Authentication" @@ -71,8 +71,7 @@ def internal_access_only(function): @wraps(function) def decorated_function(*args, **kwargs): - """ Wrapped function actually checking if the request is local. - """ + """Wrapped function actually checking if the request is local.""" ip_allowed = pagure_config.get( "IP_ALLOWED_INTERNAL", ["127.0.0.1", "localhost", "::1"] ) @@ -228,8 +227,7 @@ def check_ssh_access(): @PV.route("/pull-request/comment/", methods=["PUT"]) @internal_access_only def pull_request_add_comment(): - """ Add a comment to a pull-request. - """ + """Add a comment to a pull-request.""" pform = pagure.forms.ProjectCommentForm(csrf_enabled=False) if not pform.validate_on_submit(): flask.abort(400, description="Invalid request") @@ -280,8 +278,7 @@ def pull_request_add_comment(): @PV.route("/ticket/comment/", methods=["PUT"]) @internal_access_only def ticket_add_comment(): - """ Add a comment to an issue. - """ + """Add a comment to an issue.""" pform = pagure.forms.ProjectCommentForm(csrf_enabled=False) if not pform.validate_on_submit(): flask.abort(400, description="Invalid request") @@ -341,8 +338,7 @@ def ticket_add_comment(): @PV.route("/pull-request/merge", methods=["POST"]) def mergeable_request_pull(): - """ Returns if the specified pull-request can be merged or not. - """ + """Returns if the specified pull-request can be merged or not.""" force = flask.request.form.get("force", False) if force is not False: force = True @@ -413,7 +409,7 @@ def mergeable_request_pull(): @PV.route("/pull-request/ready", methods=["POST"]) def get_pull_request_ready_branch(): - """ Return the list of branches that have commits not in the main + """Return the list of branches that have commits not in the main branch/repo (thus for which one could open a PR) and the number of commits that differ. """ @@ -480,8 +476,7 @@ def get_pull_request_ready_branch(): "/fork////issue/template", methods=["POST"] ) def get_ticket_template(repo, namespace=None, username=None): - """ Return the template asked for the specified project - """ + """Return the template asked for the specified project""" form = pagure.forms.ConfirmationForm() if not form.validate_on_submit(): @@ -542,8 +537,7 @@ def get_ticket_template(repo, namespace=None, username=None): @PV.route("/branches/commit/", methods=["POST"]) def get_branches_of_commit(): - """ Return the list of branches that have the specified commit in - """ + """Return the list of branches that have the specified commit in""" form = pagure.forms.ConfirmationForm() if not form.validate_on_submit(): response = flask.jsonify( @@ -645,7 +639,7 @@ def get_branches_of_commit(): @PV.route("/branches/heads/", methods=["POST"]) def get_branches_head(): - """ Return the heads of each branch in the repo, using the following + """Return the heads of each branch in the repo, using the following structure: { code: 'OK', @@ -714,7 +708,7 @@ def get_branches_head(): @PV.route("/task/", methods=["GET"]) def task_info(taskid): - """ Return the results of the specified task or a 418 if the task is + """Return the results of the specified task or a 418 if the task is still being processed. """ task = pagure.lib.tasks.get_result(taskid) @@ -730,9 +724,7 @@ def task_info(taskid): @PV.route("/stats/commits/authors", methods=["POST"]) def get_stats_commits(): - """ Return statistics about the commits made on the specified repo. - - """ + """Return statistics about the commits made on the specified repo.""" form = pagure.forms.ConfirmationForm() if not form.validate_on_submit(): response = flask.jsonify( @@ -774,9 +766,7 @@ def get_stats_commits(): @PV.route("/stats/commits/trend", methods=["POST"]) def get_stats_commits_trend(): - """ Return evolution of the commits made on the specified repo. - - """ + """Return evolution of the commits made on the specified repo.""" form = pagure.forms.ConfirmationForm() if not form.validate_on_submit(): response = flask.jsonify( @@ -821,7 +811,7 @@ def get_stats_commits_trend(): @PV.route("/fork///family", methods=["POST"]) @PV.route("/fork////family", methods=["POST"]) def get_project_family(repo, namespace=None, username=None): - """ Return the family of projects for the specified project + """Return the family of projects for the specified project { code: 'OK', diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 636ea5d..e6a82a1 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -54,7 +54,7 @@ _log = logging.getLogger(__name__) def commit_to_patch( repo_obj, commits, diff_view=False, find_similar=False, separated=False ): - """ For a given commit (PyGit2 commit object) of a specified git repo, + """For a given commit (PyGit2 commit object) of a specified git repo, returns a string representation of the changes the commit did in a format that allows it to be used as patch. @@ -145,7 +145,7 @@ Subject: {subject} def generate_gitolite_acls(project=None, group=None): - """ Generate the gitolite configuration file. + """Generate the gitolite configuration file. :arg project: the project of which to update the ACLs. This argument can take three values: ``-1``, ``None`` and a project. @@ -197,10 +197,10 @@ def update_git(obj, repo): def _maybe_wait(result): - """ Function to patch if one wants to wait for finish. + """Function to patch if one wants to wait for finish. This function should only ever be overridden by a few tests that depend - on counting and very precise timing. """ + on counting and very precise timing.""" pass @@ -214,7 +214,7 @@ def _make_signature(name, email): def _update_git(obj, repo): - """ Update the given issue in its git. + """Update the given issue in its git. This method forks the provided repo, add/edit the issue whose file name is defined by the uid field of the issue and if there are additions/ @@ -313,9 +313,7 @@ def clean_git(repo, obj_repotype, obj_uid): def _clean_git(repo, obj_repotype, obj_uid): - """ Update the given issue remove it from its git. - - """ + """Update the given issue remove it from its git.""" _log.info("Update the git repo: %s to remove: %s", repo.path, obj_uid) with TemporaryClone(repo, obj_repotype, "clean_git") as tempclone: @@ -369,7 +367,7 @@ def _clean_git(repo, obj_repotype, obj_uid): def get_user_from_json(session, jsondata, key="user"): - """ From the given json blob, retrieve the user info and search for it + """From the given json blob, retrieve the user info and search for it in the db and create the user if it does not already exist. """ user = None @@ -412,7 +410,7 @@ def get_user_from_json(session, jsondata, key="user"): def get_project_from_json(session, jsondata): - """ From the given json blob, retrieve the project info and search for + """From the given json blob, retrieve the project info and search for it in the db and create the projec if it does not already exist. """ project = None @@ -468,7 +466,7 @@ def get_project_from_json(session, jsondata): def update_custom_field_from_json(session, repo, issue, json_data): - """ Update the custom fields according to the custom fields of + """Update the custom fields according to the custom fields of the issue. If the custom field is not present for the repo in it's settings, this will create them. @@ -522,7 +520,7 @@ def update_custom_field_from_json(session, repo, issue, json_data): def update_ticket_from_git( session, reponame, namespace, username, issue_uid, json_data, agent ): - """ Update the specified issue (identified by its unique identifier) + """Update the specified issue (identified by its unique identifier) with the data present in the json blob provided. :arg session: the session to connect to the database with. @@ -797,7 +795,7 @@ def update_ticket_from_git( def update_request_from_git( session, reponame, namespace, username, request_uid, json_data ): - """ Update the specified request (identified by its unique identifier) + """Update the specified request (identified by its unique identifier) with the data present in the json blob provided. :arg session: the session to connect to the database with. @@ -897,7 +895,7 @@ def update_request_from_git( def _add_file_to_git(repo, issue, attachmentfolder, user, filename): - """ Add a given file to the specified ticket git repository. + """Add a given file to the specified ticket git repository. :arg repo: the Project object from the database :arg attachmentfolder: the folder on the filesystem where the attachments @@ -982,7 +980,7 @@ class TemporaryClone(object): repo = None def __init__(self, project, repotype, action, path=None, parent=None): - """ Initializes a TempoaryClone instance. + """Initializes a TempoaryClone instance. Args: project (model.Project): A project instance @@ -1095,7 +1093,7 @@ class TemporaryClone(object): shutil.rmtree(self.repopath) def change_project_association(self, new_project): - """ Make this instance "belong" to another project. + """Make this instance "belong" to another project. This is useful when you want to create TemporaryClone of one project and then push some of its content into a different project just @@ -1112,7 +1110,7 @@ class TemporaryClone(object): ) def mirror(self, username, force=False, **extra): - """ Run ``git push --mirror`` of the repo to its origin. + """Run ``git push --mirror`` of the repo to its origin. Args: username (string): The user on who's account this push is @@ -1125,7 +1123,7 @@ class TemporaryClone(object): self._push(username, "--mirror", force, **extra) def push(self, username, sbranch, tbranch=None, force=False, **extra): - """ Push the repo back to its origin. + """Push the repo back to its origin. Args: username (string): The user on who's account this push is @@ -1139,7 +1137,7 @@ class TemporaryClone(object): self._push(username, pushref, force, **extra) def _push(self, username, pushref, force, **extra): - """ Push the repo back to its origin. + """Push the repo back to its origin. Args: username (string): The user on who's account this push is @@ -1243,7 +1241,7 @@ class TemporaryClone(object): def _update_file_in_git( repo, branch, branchto, filename, content, message, user, email ): - """ Update a specific file in the specified repository with the content + """Update a specific file in the specified repository with the content given and commit the change under the user's name. :arg repo: the Project object from the database @@ -1327,7 +1325,7 @@ def _update_file_in_git( def read_output(cmd, abspath, input=None, keepends=False, error=False, **kw): - """ Read the output from the given command to run. + """Read the output from the given command to run. cmd: The command to run, this is a list with each space separated into an @@ -1428,7 +1426,7 @@ def get_revs_between(oldrev, newrev, abspath, refname, forced=False): def is_forced_push(oldrev, newrev, abspath): - """ Returns whether there was a force push between HEAD and BASE. + """Returns whether there was a force push between HEAD and BASE. Doc: http://stackoverflow.com/a/12258773 """ @@ -1442,7 +1440,7 @@ def is_forced_push(oldrev, newrev, abspath): def get_base_revision(torev, fromrev, abspath): - """ Return the base revision between HEAD and BASE. + """Return the base revision between HEAD and BASE. This is useful in case of force-push. """ cmd = ["merge-base", fromrev, torev] @@ -1484,7 +1482,7 @@ def get_commit_subject(commit, abspath): def get_repo_info_from_path(gitdir, hide_notfound=False): - """ Returns the name, username, namespace and type of a git directory + """Returns the name, username, namespace and type of a git directory This gets computed based on the *_FOLDER's in the config file, and as such only works for the central file-based repositories. @@ -1591,29 +1589,25 @@ def get_repo_info_from_path(gitdir, hide_notfound=False): def get_repo_name(abspath): - """ Return the name of the git repo based on its path. - """ + """Return the name of the git repo based on its path.""" _, _, _, name = get_repo_info_from_path(abspath) return name def get_repo_namespace(abspath, gitfolder=None): - """ Return the name of the git repo based on its path. - """ + """Return the name of the git repo based on its path.""" _, _, namespace, _ = get_repo_info_from_path(abspath) return namespace def get_username(abspath): - """ Return the username of the git repo based on its path. - """ + """Return the username of the git repo based on its path.""" _, username, _, _ = get_repo_info_from_path(abspath) return username def get_branch_ref(repo, branchname): - """ Return the reference to the specified branch or raises an exception. - """ + """Return the reference to the specified branch or raises an exception.""" location = pygit2.GIT_BRANCH_LOCAL if branchname not in repo.listall_branches(): branchname = "origin/%s" % branchname @@ -1628,8 +1622,7 @@ def get_branch_ref(repo, branchname): def merge_pull_request(session, request, username, domerge=True): - """ Merge the specified pull-request. - """ + """Merge the specified pull-request.""" if domerge: _log.info("%s asked to merge the pull-request: %s", username, request) else: @@ -1955,7 +1948,7 @@ def merge_pull_request(session, request, username, domerge=True): def rebase_pull_request(session, request, username): - """ Rebase the specified pull-request. + """Rebase the specified pull-request. Args: session (sqlalchemy): the session to connect to the database with @@ -2094,7 +2087,7 @@ def rebase_pull_request(session, request, username): def get_diff_info(repo_obj, orig_repo, branch_from, branch_to, prid=None): - """ Return the info needed to see a diff or make a Pull-Request between + """Return the info needed to see a diff or make a Pull-Request between the two specified repo. :arg repo_obj: The pygit2.Repository object of the first git repo @@ -2261,7 +2254,7 @@ def diff_pull_request( notify=True, username=None, ): - """ Returns the diff and the list of commits between the two git repos + """Returns the diff and the list of commits between the two git repos mentionned in the given pull-request. :arg session: The sqlalchemy session to connect to the database @@ -2383,8 +2376,7 @@ def diff_pull_request( def update_pull_ref(request, repo): - """ Create or update the refs/pull/ reference in the git repo. - """ + """Create or update the refs/pull/ reference in the git repo.""" repopath = pagure.utils.get_repo_path(request.project) reponame = "%s_%s" % (request.user.user, request.uid) @@ -2422,7 +2414,7 @@ def update_pull_ref(request, repo): def get_git_tags(project, with_commits=False): - """ Returns the list of tags created in the git repositorie of the + """Returns the list of tags created in the git repositorie of the specified project. """ repopath = pagure.utils.get_repo_path(project) @@ -2448,7 +2440,7 @@ def get_git_tags(project, with_commits=False): def new_git_tag(project, tagname, target, user, message=None, force=False): - """ Create a new git tag in the git repositorie of the specified project. + """Create a new git tag in the git repositorie of the specified project. :arg project: the project in which we want to create a git tag :type project: pagure.lib.model.Project @@ -2486,9 +2478,9 @@ def new_git_tag(project, tagname, target, user, message=None, force=False): def get_git_tags_objects(project): - """ Returns the list of references of the tags created in the git + """Returns the list of references of the tags created in the git repositorie the specified project. - The list is sorted using the time of the commit associated to the tag """ + The list is sorted using the time of the commit associated to the tag""" repopath = pagure.utils.get_repo_path(project) repo_obj = PagureRepo(repopath) tags = {} @@ -2566,7 +2558,7 @@ def log_commits_to_db(session, project, commits, gitdir): def reinit_git(project, repofolder): - """ Delete and recreate a git folder + """Delete and recreate a git folder :args project: SQLAlchemy object of the project :args folder: The folder which contains the git repos like TICKETS_FOLDER for tickets and REQUESTS_FOLDER for @@ -2587,7 +2579,7 @@ def reinit_git(project, repofolder): def get_git_branches(project, with_commits=False): - """ Return a list of branches for the project + """Return a list of branches for the project :arg project: The Project instance to get the branches for :arg with_commits: Whether we should return branch head commits or not """ @@ -2609,7 +2601,7 @@ def get_git_branches(project, with_commits=False): def get_default_git_branches(project): - """ Return a tuple of the default branchname and its head commit hash + """Return a tuple of the default branchname and its head commit hash :arg project: The Project instance to get the branches for """ repo_path = pagure.utils.get_repo_path(project) @@ -2624,7 +2616,7 @@ def get_default_git_branches(project): def new_git_branch( username, project, branch, from_branch=None, from_commit=None ): - """ Create a new git branch on the project + """Create a new git branch on the project :arg project: The Project instance to get the branches for :arg from_branch: The branch to branch off of """ @@ -2659,7 +2651,7 @@ def new_git_branch( def git_set_ref_head(project, branch): - """ Set the HEAD reference of the project + """Set the HEAD reference of the project :arg project: The project instance to set the HEAD reference :arg branch: The branch to be set as HEAD reference """ @@ -2671,7 +2663,7 @@ def git_set_ref_head(project, branch): def get_branch_aliases(project): - """ Iterates through the references of the provided git repo to extract all + """Iterates through the references of the provided git repo to extract all of its aliases. """ repo_path = pagure.utils.get_repo_path(project) @@ -2685,7 +2677,7 @@ def get_branch_aliases(project): def set_branch_alias(project, source, dest): - """ Create a reference in the provided git repo from the source reference + """Create a reference in the provided git repo from the source reference to the dest one. """ repo_path = pagure.utils.get_repo_path(project) @@ -2696,7 +2688,8 @@ def set_branch_alias(project, source, dest): try: repo_obj.create_reference( - "refs/heads/{}".format(source), "refs/heads/{}".format(dest), + "refs/heads/{}".format(source), + "refs/heads/{}".format(dest), ) except ValueError as err: _log.debug( @@ -2709,7 +2702,7 @@ def set_branch_alias(project, source, dest): def drop_branch_aliases(project, source, dest): - """ Delete a reference in the provided git repo from the source reference + """Delete a reference in the provided git repo from the source reference to the dest one. """ repo_path = pagure.utils.get_repo_path(project) @@ -2726,7 +2719,7 @@ def drop_branch_aliases(project, source, dest): def delete_project_repos(project): - """ Deletes the actual git repositories on disk or repoSpanner + """Deletes the actual git repositories on disk or repoSpanner Args: project (Project): Project to delete repos for @@ -2774,7 +2767,7 @@ def delete_project_repos(project): def set_up_project_hooks(project, region, hook=None): - """ Makes sure the git repositories for a project have their hooks setup. + """Makes sure the git repositories for a project have their hooks setup. Args: project (model.Project): Project to set up hooks for @@ -2824,7 +2817,7 @@ def set_up_project_hooks(project, region, hook=None): def _create_project_repo(project, region, templ, ignore_existing, repotype): - """ Creates a single specific git repository on disk or repoSpanner + """Creates a single specific git repository on disk or repoSpanner Args: project (Project): Project to create repos for @@ -2901,7 +2894,7 @@ def _create_project_repo(project, region, templ, ignore_existing, repotype): def create_project_repos(project, region, templ, ignore_existing): - """ Creates the actual git repositories on disk or repoSpanner + """Creates the actual git repositories on disk or repoSpanner Args: project (Project): Project to create repos for @@ -2930,7 +2923,7 @@ def create_project_repos(project, region, templ, ignore_existing): def get_stats_patch(patch): - """ Returns some statistics about a given patch. + """Returns some statistics about a given patch. These stats include: status: if the file was added (A), deleted (D), modified (M) or @@ -3008,7 +3001,7 @@ def get_stats_patch(patch): def generate_archive(project, commit, tag, name, archive_fmt): - """ Generate the desired archive of the specified project for the + """Generate the desired archive of the specified project for the specified commit with the given name and archive format. Args: diff --git a/pagure/lib/git_auth.py b/pagure/lib/git_auth.py index b354a51..201be10 100644 --- a/pagure/lib/git_auth.py +++ b/pagure/lib/git_auth.py @@ -38,7 +38,7 @@ GIT_AUTH_BACKEND_INSTANCE = None def get_git_auth_helper(backend=None): - """ Instantiate and return the appropriate git auth helper backend. + """Instantiate and return the appropriate git auth helper backend. :arg backend: The name of the backend to find on the system (declared via the entry_points in setup.py). @@ -86,7 +86,7 @@ def get_git_auth_helper(backend=None): class GitAuthHelper(with_metaclass(abc.ABCMeta, object)): - """ The class to inherit from when creating your own git authentication + """The class to inherit from when creating your own git authentication helper. """ @@ -95,7 +95,7 @@ class GitAuthHelper(with_metaclass(abc.ABCMeta, object)): @classmethod @abc.abstractmethod def generate_acls(self, project, group=None): - """ This is the method that is called by pagure to generate the + """This is the method that is called by pagure to generate the configuration file. :arg project: the project of which to update the ACLs. This argument @@ -121,7 +121,7 @@ class GitAuthHelper(with_metaclass(abc.ABCMeta, object)): @classmethod @abc.abstractmethod def remove_acls(self, session, project): - """ This is the method that is called by pagure to remove a project + """This is the method that is called by pagure to remove a project from the configuration file. :arg cls: the current class @@ -138,7 +138,7 @@ class GitAuthHelper(with_metaclass(abc.ABCMeta, object)): # This method can't be marked as abstract, since it's new and that would # break backwards compatibility def check_acl(cls, session, project, username, refname, **info): - """ This method is used in Dynamic Git Auth helpers to check acls. + """This method is used in Dynamic Git Auth helpers to check acls. It is acceptable for implementations to print things, which will be returned to the user. @@ -182,7 +182,7 @@ class GitAuthHelper(with_metaclass(abc.ABCMeta, object)): def _read_file(filename): - """ Reads the specified file and return its content. + """Reads the specified file and return its content. Returns None if it could not read the file for any reason. """ if not os.path.exists(filename): @@ -197,7 +197,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def _process_project(cls, project, config, global_pr_only): - """ Generate the gitolite configuration for the specified project. + """Generate the gitolite configuration for the specified project. :arg project: the project to generate the configuration for :type project: pagure.lib.model.Project @@ -281,7 +281,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def _clean_current_config(cls, current_config, project): - """ Remove the specified project from the current configuration file + """Remove the specified project from the current configuration file :arg current_config: the content of the current/actual gitolite configuration file read from the disk @@ -314,7 +314,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def _clean_groups(cls, config, group=None): - """ Removes the groups in the given configuration file. + """Removes the groups in the given configuration file. :arg config: the current configuration :type config: list @@ -361,7 +361,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def _generate_groups_config(cls, session): - """ Generate the gitolite configuration for all of the groups. + """Generate the gitolite configuration for all of the groups. :arg session: the session with which to connect to the database :return: the gitolite configuration for the groups @@ -380,7 +380,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def _get_current_config(cls, configfile, preconfig=None, postconfig=None): - """ Load the current gitolite configuration file from the disk. + """Load the current gitolite configuration file from the disk. :arg configfile: the name of the configuration file to load :type configfile: str @@ -435,7 +435,7 @@ class Gitolite2Auth(GitAuthHelper): postconf=None, group=None, ): - """ Generate the configuration file for gitolite for all projects + """Generate the configuration file for gitolite for all projects on the forge. :arg cls: the current class @@ -585,7 +585,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def remove_acls(cls, session, project): - """ Remove a project from the configuration file for gitolite. + """Remove a project from the configuration file for gitolite. :arg cls: the current class :type: Gitolite2Auth @@ -685,7 +685,7 @@ class Gitolite2Auth(GitAuthHelper): @staticmethod def _get_gitolite_command(): - """ Return the gitolite command to run based on the info in the + """Return the gitolite command to run based on the info in the configuration file. """ _log.info("Compiling the gitolite configuration") @@ -700,7 +700,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def _repos_from_lines(cls, lines): - """ Return list of strings representing complete repo entries from list + """Return list of strings representing complete repo entries from list of lines as returned by _process_project. """ repos = [] @@ -715,7 +715,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def _run_gitolite_cmd(cls, cmd): - """ Run gitolite command as subprocess, raise PagureException + """Run gitolite command as subprocess, raise PagureException if it fails. """ if cmd: @@ -738,7 +738,7 @@ class Gitolite2Auth(GitAuthHelper): @classmethod def generate_acls(cls, project, group=None): - """ Generate the gitolite configuration file for all repos + """Generate the gitolite configuration file for all repos :arg project: the project to update in the gitolite configuration file. It can be of three types/values. @@ -824,7 +824,7 @@ class Gitolite3Auth(Gitolite2Auth): @staticmethod def _get_gitolite_command(): - """ Return the gitolite command to run based on the info in the + """Return the gitolite command to run based on the info in the configuration file. """ _log.info("Compiling the gitolite configuration") @@ -839,7 +839,7 @@ class Gitolite3Auth(Gitolite2Auth): @classmethod def post_compile_only(cls): - """ This method runs `gitolite trigger POST_COMPILE` without touching + """This method runs `gitolite trigger POST_COMPILE` without touching any other gitolite configuration. Most importantly, this will process SSH keys used by gitolite. """ @@ -867,9 +867,9 @@ class PagureGitAuth(GitAuthHelper): pass def info(self, msg): - """ Function that prints info about decisions to clients. + """Function that prints info about decisions to clients. - This is a function to make it possible to override for test suite. """ + This is a function to make it possible to override for test suite.""" print(msg) def check_acl( @@ -920,7 +920,7 @@ class GitAuthTestHelper(GitAuthHelper): @classmethod def generate_acls(cls, project, group=None): - """ Print a statement when called, useful for debugging, only. + """Print a statement when called, useful for debugging, only. :arg project: this variable is just printed out but not used in any real place. @@ -938,7 +938,7 @@ class GitAuthTestHelper(GitAuthHelper): @classmethod def remove_acls(cls, session, project): - """ Print a statement about which a project would be removed from + """Print a statement about which a project would be removed from the configuration file for gitolite. :arg cls: the current class diff --git a/pagure/lib/lib_ci.py b/pagure/lib/lib_ci.py index 058b468..e4e22d1 100644 --- a/pagure/lib/lib_ci.py +++ b/pagure/lib/lib_ci.py @@ -31,7 +31,7 @@ BUILD_STATS = { def process_jenkins_build(session, project, build_id, iteration=0): - """ Gets the build info from jenkins and flags that particular + """Gets the build info from jenkins and flags that particular pull-request. """ import jenkins diff --git a/pagure/lib/link.py b/pagure/lib/link.py index a2ecec2..449c78d 100644 --- a/pagure/lib/link.py +++ b/pagure/lib/link.py @@ -59,7 +59,7 @@ def get_relation( reftype="relates", include_prs=False, ): - """ For a given text, searches using regex if the text contains + """For a given text, searches using regex if the text contains reference to another issue in this project or another one. Returns the list of issues referenced (possibly empty). diff --git a/pagure/lib/login.py b/pagure/lib/login.py index e34363c..eeb56a0 100644 --- a/pagure/lib/login.py +++ b/pagure/lib/login.py @@ -32,7 +32,7 @@ from cryptography.hazmat.primitives import constant_time def id_generator(size=15, chars=string.ascii_uppercase + string.digits): - """ Generates a random identifier for the given size and using the + """Generates a random identifier for the given size and using the specified characters. If no size is specified, it uses 15 as default. If no characters are specified, it uses ascii char upper case and @@ -45,7 +45,7 @@ def id_generator(size=15, chars=string.ascii_uppercase + string.digits): def get_session_by_visitkey(session, sessionid): - """ Return a specified VisitUser via its session identifier (visit_key). + """Return a specified VisitUser via its session identifier (visit_key). :arg session: the session with which to connect to the database. @@ -58,7 +58,7 @@ def get_session_by_visitkey(session, sessionid): def generate_hashed_value(password): - """ Generate hash value for password. + """Generate hash value for password. :arg password: password for which the hash has to be generated. :type password: str (Python 3) or unicode (Python 2) @@ -74,7 +74,7 @@ def generate_hashed_value(password): def check_password(entered_password, user_password, seed=None): - """ Version checking and returning the password + """Version checking and returning the password :arg entered_password: password entered by the user. :type entered_password: str (Python 3) or unicode (Python 2) @@ -116,7 +116,7 @@ def check_password(entered_password, user_password, seed=None): def check_username_and_password(session, username, password): - """ Check if the provided username and password match what is in the + """Check if the provided username and password match what is in the database and raise an pagure.exceptions.PagureException if that is not the case. """ diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 203c8e3..84e15ff 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -49,7 +49,7 @@ _log = logging.getLogger(__name__) def create_tables(db_url, alembic_ini=None, acls=None, debug=False): - """ Create the tables in the database using the information from the + """Create the tables in the database using the information from the url obtained. :arg db_url, URL used to connect to the database. The URL contains @@ -100,8 +100,7 @@ def create_tables(db_url, alembic_ini=None, acls=None, debug=False): def create_default_status(session, acls=None): - """ Insert the defaults status in the status tables. - """ + """Insert the defaults status in the status tables.""" statuses = ["Open", "Closed"] for status in statuses: @@ -165,7 +164,7 @@ class AccessLevels(BASE): class StatusIssue(BASE): - """ Stores the status a ticket can have. + """Stores the status a ticket can have. Table -- status_issue """ @@ -177,7 +176,7 @@ class StatusIssue(BASE): class StatusPullRequest(BASE): - """ Stores the status a pull-request can have. + """Stores the status a pull-request can have. Table -- status_issue """ @@ -189,7 +188,7 @@ class StatusPullRequest(BASE): class User(BASE): - """ Stores information about users. + """Stores information about users. Table -- users """ @@ -232,14 +231,13 @@ class User(BASE): @property def url_path(self): - """ Return the path at which this user can be accessed in the web UI. - """ + """Return the path at which this user can be accessed in the web UI.""" return "user/%s" % (self.user) @property def html_title(self): - """ Return the ``fullname (username)`` or simply ``username`` to be + """Return the ``fullname (username)`` or simply ``username`` to be used in the html templates. """ if self.fullname: @@ -254,7 +252,7 @@ class User(BASE): @property def settings(self): - """ Return the dict stored as string in the database as an actual + """Return the dict stored as string in the database as an actual dict object. """ default = {"cc_me_to_my_actions": False} @@ -304,7 +302,7 @@ class User(BASE): class UserEmail(BASE): - """ Stores email information about the users. + """Stores email information about the users. Table -- user_emails """ @@ -330,7 +328,7 @@ class UserEmail(BASE): class UserEmailPending(BASE): - """ Stores email information about the users. + """Stores email information about the users. Table -- user_emails_pending """ @@ -360,7 +358,7 @@ class UserEmailPending(BASE): class Project(BASE): - """ Stores the projects. + """Stores the projects. Table -- projects """ @@ -531,7 +529,7 @@ class Project(BASE): @property def mail_id(self): - """ Return a unique representation of the project as string that + """Return a unique representation of the project as string that can be used when sending emails. """ return "%s-project-%s" % (self.fullname, self.id) @@ -547,7 +545,7 @@ class Project(BASE): return "%s.git" % self.fullname def repospanner_repo_info(self, repotype, region=None): - """ Returns info for getting a repoSpanner repo for a project. + """Returns info for getting a repoSpanner repo for a project. Args: repotype (string): Type of repository @@ -577,7 +575,7 @@ class Project(BASE): return url, regioninfo def _repospanner_repo_name(self, repotype, region=None): - """ Returns the name of a repo as named in repoSpanner. + """Returns the name of a repo as named in repoSpanner. Args: repotype (string): Type of repository @@ -595,7 +593,7 @@ class Project(BASE): ) def repopath(self, repotype): - """ Return the full repository path of the git repo on the filesystem. + """Return the full repository path of the git repo on the filesystem. If the repository is on repoSpanner, this will be a pseudo repository, which is "git repo enough" to be considered a valid repo, but any @@ -637,7 +635,7 @@ class Project(BASE): @property def fullname(self): - """ Return the name of the git repo as user/project if it is a + """Return the name of the git repo as user/project if it is a project forked, otherwise it returns the project name. """ str_name = self.name @@ -649,7 +647,7 @@ class Project(BASE): @property def url_path(self): - """ Return the path at which this project can be accessed in the + """Return the path at which this project can be accessed in the web UI. """ path = self.name @@ -672,7 +670,7 @@ class Project(BASE): @property def settings(self): - """ Return the dict stored as string in the database as an actual + """Return the dict stored as string in the database as an actual dict object. """ default = { @@ -721,7 +719,7 @@ class Project(BASE): @property def milestones(self): - """ Return the dict stored as string in the database as an actual + """Return the dict stored as string in the database as an actual dict object. """ milestones = {} @@ -750,8 +748,7 @@ class Project(BASE): @property def milestones_keys(self): - """ Return the list of milestones so we can keep the order consistent. - """ + """Return the list of milestones so we can keep the order consistent.""" milestones_keys = {} if self._milestones_keys: @@ -766,7 +763,7 @@ class Project(BASE): @property def priorities(self): - """ Return the dict stored as string in the database as an actual + """Return the dict stored as string in the database as an actual dict object. """ priorities = {} @@ -783,7 +780,7 @@ class Project(BASE): @property def block_users(self): - """ Return the dict stored as string in the database as an actual + """Return the dict stored as string in the database as an actual dict object. """ block_users = [] @@ -800,7 +797,7 @@ class Project(BASE): @property def quick_replies(self): - """ Return a list of quick replies available for pull requests and + """Return a list of quick replies available for pull requests and issues. """ quick_replies = [] @@ -817,7 +814,7 @@ class Project(BASE): @property def notifications(self): - """ Return the dict stored as string in the database as an actual + """Return the dict stored as string in the database as an actual dict object. """ notifications = {} @@ -834,7 +831,7 @@ class Project(BASE): @property def reports(self): - """ Return the dict stored as string in the database as an actual + """Return the dict stored as string in the database as an actual dict object. """ reports = {} @@ -851,7 +848,7 @@ class Project(BASE): @property def close_status(self): - """ Return the dict stored as string in the database as an actual + """Return the dict stored as string in the database as an actual dict object. """ close_status = [] @@ -899,7 +896,7 @@ class Project(BASE): @property def contributors(self): - """ Return the dict presenting the different contributors of the + """Return the dict presenting the different contributors of the project based on their access level. """ contributors = collections.defaultdict(list) @@ -911,7 +908,7 @@ class Project(BASE): @property def contributor_groups(self): - """ Return the dict presenting the different contributors of the + """Return the dict presenting the different contributors of the project based on their access level. """ contributors = collections.defaultdict(list) @@ -922,7 +919,7 @@ class Project(BASE): return contributors def get_project_users(self, access, combine=True): - """ Returns the list of users/groups of the project according + """Returns the list of users/groups of the project according to the given access. :arg access: the access level to query for, can be: 'admin', @@ -979,7 +976,7 @@ class Project(BASE): return list(users - collaborators - committers - admins) def get_project_groups(self, access, combine=True): - """ Returns the list of groups of the project according + """Returns the list of groups of the project according to the given access. :arg access: the access level to query for, can be: 'admin', @@ -1034,8 +1031,7 @@ class Project(BASE): @property def access_users(self): - """ Return a dictionary with all user access - """ + """Return a dictionary with all user access""" return { "admin": sorted( self.get_project_users(access="admin", combine=False), @@ -1077,8 +1073,7 @@ class Project(BASE): @property def access_groups(self): - """ Return a dictionary with all group access - """ + """Return a dictionary with all group access""" return { "admin": sorted( self.get_project_groups(access="admin", combine=False), @@ -1104,13 +1099,11 @@ class Project(BASE): return [board for board in self.boards if board.active] def lock(self, ltype): - """ Get a SQL lock of type ltype for the current project. - """ + """Get a SQL lock of type ltype for the current project.""" return ProjectLocker(self, ltype) def to_json(self, public=False, api=False): - """ Return a representation of the project as JSON. - """ + """Return a representation of the project as JSON.""" custom_keys = [[key.name, key.key_type] for key in self.issue_keys] output = { @@ -1143,7 +1136,7 @@ class Project(BASE): class ProjectLock(BASE): - """ Table used to define project-specific locks. + """Table used to define project-specific locks. Table -- project_locks """ @@ -1166,7 +1159,7 @@ class ProjectLock(BASE): class ProjectLocker(object): - """ This is used as a context manager to lock a project. + """This is used as a context manager to lock a project. This is used as a context manager to make it very explicit when we unlock the project, and so that we unlock even if an exception occurs. @@ -1209,7 +1202,7 @@ class ProjectLocker(object): class ProjectUser(BASE): - """ Stores the user of a projects. + """Stores the user of a projects. Table -- user_projects """ @@ -1236,7 +1229,10 @@ class ProjectUser(BASE): ), nullable=False, ) - branches = sa.Column(sa.Text, nullable=True,) + branches = sa.Column( + sa.Text, + nullable=True, + ) project = relation( "Project", @@ -1250,7 +1246,7 @@ class ProjectUser(BASE): class SSHKey(BASE): - """ Stores information about SSH keys. + """Stores information about SSH keys. Every instance needs to either have user_id set (SSH key for a specific user) or project_id ("deploy key" for a specific project). @@ -1330,7 +1326,7 @@ class SSHKey(BASE): class Issue(BASE): - """ Stores the issues reported on a project. + """Stores the issues reported on a project. Table -- issues """ @@ -1432,12 +1428,12 @@ class Issue(BASE): @property def attachments(self): - """ Return a list of attachment tuples: (LINK, FILENAME, DISPLAY_NAME, - DATE) """ + """Return a list of attachment tuples: (LINK, FILENAME, DISPLAY_NAME, + DATE)""" def extract_info(text): - """ Return a tuple containing the link, file name, and the - "display" file name from the markdown attachment link """ + """Return a tuple containing the link, file name, and the + "display" file name from the markdown attachment link""" pattern_md = re.compile(r"^\[\!(.*)\]") pattern_link = re.compile(r"\(([^)]+)\)") pattern_file = re.compile(r"\[([^]]+)\]") @@ -1511,7 +1507,7 @@ class Issue(BASE): @property def mail_id(self): - """ Return a unique reprensetation of the issue as string that + """Return a unique reprensetation of the issue as string that can be used when sending emails. """ return "%s-ticket-%s" % (self.project.name, self.uid) @@ -1533,22 +1529,20 @@ class Issue(BASE): @property def user_comments(self): - """ Return user comments only, filter it from notifications - """ + """Return user comments only, filter it from notifications""" return [ comment for comment in self.comments if not comment.notification ] @property def sortable_priority(self): - """ Return an empty string if no priority is set allowing issues to - be sorted using this attribute. """ + """Return an empty string if no priority is set allowing issues to + be sorted using this attribute.""" return self.priority if self.priority else "" @property def boards_name(self): - """ Return the list of boards the issue is part of - """ + """Return the list of boards the issue is part of""" out = [] for status_board in self.boards_issues: out.append(status_board.board.name) @@ -1563,9 +1557,7 @@ class Issue(BASE): ) def to_json(self, public=False, with_comments=True, with_project=False): - """ Returns a dictionary representation of the issue. - - """ + """Returns a dictionary representation of the issue.""" custom_fields = [ dict( name=field.key.name, @@ -1626,7 +1618,7 @@ class Issue(BASE): class IssueToIssue(BASE): - """ Stores the parent/child relationship between two issues. + """Stores the parent/child relationship between two issues. Table -- issue_to_issue """ @@ -1646,7 +1638,7 @@ class IssueToIssue(BASE): class PrToIssue(BASE): - """ Stores the associations between issues and pull-requests. + """Stores the associations between issues and pull-requests. Table -- pr_to_issue """ @@ -1669,7 +1661,7 @@ class PrToIssue(BASE): class IssueComment(BASE): - """ Stores the comments made on a commit/file. + """Stores the comments made on a commit/file. Table -- issue_comments """ @@ -1729,7 +1721,7 @@ class IssueComment(BASE): @property def mail_id(self): - """ Return a unique reprensetation of the issue as string that + """Return a unique reprensetation of the issue as string that can be used when sending emails. """ return "%s-ticket-%s-%s" % ( @@ -1745,7 +1737,7 @@ class IssueComment(BASE): @property def reactions(self): - """ Return the reactions stored as a string in the database parsed as + """Return the reactions stored as a string in the database parsed as an actual dict object. """ if self._reactions: @@ -1758,9 +1750,7 @@ class IssueComment(BASE): self._reactions = json.dumps(reactions) def to_json(self, public=False): - """ Returns a dictionary representation of the issue. - - """ + """Returns a dictionary representation of the issue.""" output = { "id": self.id, "comment": self.comment, @@ -1778,7 +1768,7 @@ class IssueComment(BASE): class IssueKeys(BASE): - """ Stores the custom keys a project can use on issues. + """Stores the custom keys a project can use on issues. Table -- issue_keys """ @@ -1829,7 +1819,7 @@ class IssueKeys(BASE): class IssueValues(BASE): - """ Stores the values of the custom keys set by project on issues. + """Stores the values of the custom keys set by project on issues. Table -- issue_values """ @@ -1866,7 +1856,7 @@ class IssueValues(BASE): class Tag(BASE): - """ Stores the tags. + """Stores the tags. Table -- tags """ @@ -1880,7 +1870,7 @@ class Tag(BASE): class TagIssue(BASE): - """ Stores the tag associated with an issue. + """Stores the tag associated with an issue. Table -- tags_issues """ @@ -1915,7 +1905,7 @@ class TagIssue(BASE): class TagColored(BASE): - """ Stores the colored tags. + """Stores the colored tags. Table -- tags_colored """ @@ -1964,7 +1954,7 @@ class TagColored(BASE): class TagIssueColored(BASE): - """ Stores the colored tag associated with an issue. + """Stores the colored tag associated with an issue. Table -- tags_issues_colored """ @@ -2008,7 +1998,7 @@ class TagIssueColored(BASE): class TagProject(BASE): - """ Stores the tag associated with a project. + """Stores the tag associated with a project. Table -- tags_projects """ @@ -2046,7 +2036,7 @@ class TagProject(BASE): class PullRequest(BASE): - """ Stores the pull requests created on a project. + """Stores the pull requests created on a project. Table -- pull_requests """ @@ -2195,7 +2185,7 @@ class PullRequest(BASE): @property def mail_id(self): - """ Return a unique reprensetation of the issue as string that + """Return a unique reprensetation of the issue as string that can be used when sending emails. """ return "%s-pull-request-%s" % (self.project.name, self.uid) @@ -2207,15 +2197,14 @@ class PullRequest(BASE): @property def discussion(self): - """ Return the list of comments related to the pull-request itself, + """Return the list of comments related to the pull-request itself, ie: not related to a specific commit. """ return [comment for comment in self.comments if not comment.commit_id] @property def flags_stats(self): - """ Return some stats about the flags associated with this PR. - """ + """Return some stats about the flags associated with this PR.""" flags = self.flags flags.reverse() @@ -2232,7 +2221,7 @@ class PullRequest(BASE): @property def score(self): - """ Return the review score of the pull-request by checking the + """Return the review score of the pull-request by checking the number of +1, -1, :thumbup: and :thumbdown: in the comment of the pull-request. This includes only the main comments not the inline ones. @@ -2254,7 +2243,7 @@ class PullRequest(BASE): @property def threshold_reached(self): - """ Return whether the pull-request has reached the threshold above + """Return whether the pull-request has reached the threshold above which it is allowed to be merged, if the project requests a minimal score on pull-request, otherwise returns None. @@ -2269,15 +2258,14 @@ class PullRequest(BASE): @property def remote(self): - """ Return whether the current PullRequest is a remote pull-request + """Return whether the current PullRequest is a remote pull-request or not. """ return self.remote_git is not None @property def user_comments(self): - """ Return user comments only, filter it from notifications - """ + """Return user comments only, filter it from notifications""" return [ comment for comment in self.comments if not comment.notification ] @@ -2291,9 +2279,7 @@ class PullRequest(BASE): ) def to_json(self, public=False, api=False, with_comments=True): - """ Returns a dictionary representation of the pull-request. - - """ + """Returns a dictionary representation of the pull-request.""" output = { "id": self.id, "uid": self.uid, @@ -2337,7 +2323,7 @@ class PullRequest(BASE): class PullRequestComment(BASE): - """ Stores the comments made on a pull-request. + """Stores the comments made on a pull-request. Table -- pull_request_comments """ @@ -2405,7 +2391,7 @@ class PullRequestComment(BASE): @property def mail_id(self): - """ Return a unique representation of the issue as string that + """Return a unique representation of the issue as string that can be used when sending emails. """ return "%s-pull-request-%s-%s" % ( @@ -2421,7 +2407,7 @@ class PullRequestComment(BASE): @property def reactions(self): - """ Return the reactions stored as a string in the database parsed as + """Return the reactions stored as a string in the database parsed as an actual dict object. """ if self._reactions: @@ -2456,7 +2442,7 @@ class PullRequestComment(BASE): class PullRequestFlag(BASE): - """ Stores the flags attached to a pull-request. + """Stores the flags attached to a pull-request. Table -- pull_request_flags """ @@ -2523,7 +2509,7 @@ class PullRequestFlag(BASE): @property def mail_id(self): - """ Return a unique representation of the flag as string that + """Return a unique representation of the flag as string that can be used when sending emails. """ return "%s-pull-request-%s-%s" % ( @@ -2533,9 +2519,7 @@ class PullRequestFlag(BASE): ) def to_json(self, public=False): - """ Returns a dictionary representation of the pull-request. - - """ + """Returns a dictionary representation of the pull-request.""" output = { "pull_request_uid": self.pull_request_uid, "username": self.username, @@ -2552,7 +2536,7 @@ class PullRequestFlag(BASE): class CommitFlag(BASE): - """ Stores the flags attached to a commit. + """Stores the flags attached to a commit. Table -- commit_flags """ @@ -2619,7 +2603,7 @@ class CommitFlag(BASE): @property def mail_id(self): - """ Return a unique representation of the flag as string that + """Return a unique representation of the flag as string that can be used when sending emails. """ return "%s-commit-%s-%s" % ( @@ -2629,9 +2613,7 @@ class CommitFlag(BASE): ) def to_json(self, public=False): - """ Returns a dictionary representation of the commit flag. - - """ + """Returns a dictionary representation of the commit flag.""" output = { "commit_hash": self.commit_hash, "username": self.username, @@ -2648,7 +2630,7 @@ class CommitFlag(BASE): class TagPullRequest(BASE): - """ Stores the tag associated with an pull-request. + """Stores the tag associated with an pull-request. Table -- tags_pull_requests """ @@ -2758,9 +2740,7 @@ class PagureGroup(BASE): return "/".join([base_url, "group", self.group_name]) def to_json(self, public=False): - """ Returns a dictionary representation of the pull-request. - - """ + """Returns a dictionary representation of the pull-request.""" output = { "name": self.group_name, "display_name": self.display_name, @@ -2798,7 +2778,10 @@ class ProjectGroup(BASE): ), nullable=False, ) - branches = sa.Column(sa.Text, nullable=True,) + branches = sa.Column( + sa.Text, + nullable=True, + ) project = relation( "Project", @@ -2818,7 +2801,7 @@ class ProjectGroup(BASE): class Star(BASE): - """ Stores users association with the all the projects which + """Stores users association with the all the projects which they have starred Table -- star @@ -2860,7 +2843,7 @@ class Star(BASE): class Watcher(BASE): - """ Stores the user of a projects. + """Stores the user of a projects. Table -- watchers """ @@ -2968,9 +2951,7 @@ class PagureLog(BASE): ) def to_json(self, public=False): - """ Returns a dictionary representation of the issue. - - """ + """Returns a dictionary representation of the issue.""" output = { "id": self.id, "type": self.log_type, @@ -3037,7 +3018,7 @@ class PagureLog(BASE): class IssueWatcher(BASE): - """ Stores the users watching issues. + """Stores the users watching issues. Table -- issue_watchers """ @@ -3075,7 +3056,7 @@ class IssueWatcher(BASE): class PullRequestWatcher(BASE): - """ Stores the users watching issues. + """Stores the users watching issues. Table -- pull_request_watchers """ @@ -3211,8 +3192,7 @@ class Token(BASE): @property def acls_list(self): - """ Return a list containing the name of each ACLs this token has. - """ + """Return a list containing the name of each ACLs this token has.""" return sorted(["%s" % acl.name for acl in self.acls]) @property @@ -3322,7 +3302,10 @@ class Board(BASE): def __repr__(self): """ Return a string representation of this object. """ - return "Board: %s - name %s" % (self.id, self.name,) + return "Board: %s - name %s" % ( + self.id, + self.name, + ) def to_json(self): """ The JSON representation of a board. """ @@ -3386,7 +3369,7 @@ class BoardStatus(BASE): ) def visible_tickets(self, watching_user): - """ Returns the sorted list of tickets visible to the user currently + """Returns the sorted list of tickets visible to the user currently watching. If the user currently watching (ie: ``watching_user``) is False, do not diff --git a/pagure/lib/model_base.py b/pagure/lib/model_base.py index 1c7bdef..170d615 100644 --- a/pagure/lib/model_base.py +++ b/pagure/lib/model_base.py @@ -34,7 +34,7 @@ SESSIONMAKER = None def create_session(db_url=None, debug=False, pool_recycle=3600): - """ Create the Session object to use to query the database. + """Create the Session object to use to query the database. :arg db_url: URL used to connect to the database. The URL contains information with regards to the database engine, the host to connect diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py index 47474ed..631d490 100644 --- a/pagure/lib/notify.py +++ b/pagure/lib/notify.py @@ -206,7 +206,7 @@ def mqtt_publish(topic, message): def log(project, topic, msg, webhook=True): - """ This is the place where we send notifications to user about actions + """This is the place where we send notifications to user about actions occuring in pagure. """ @@ -246,7 +246,7 @@ def log(project, topic, msg, webhook=True): def _add_mentioned_users(emails, comment): - """ Check the comment to see if an user is mentioned in it and if + """Check the comment to see if an user is mentioned in it and if so add this user to the list of people to notify. """ filtered_comment = re.sub( @@ -260,7 +260,7 @@ def _add_mentioned_users(emails, comment): def _clean_emails(emails, user): - """ Remove the email of the user doing the action if it is in the list. + """Remove the email of the user doing the action if it is in the list. This avoids receiving emails about action you do. """ @@ -278,7 +278,7 @@ def _clean_emails(emails, user): def _get_emails_for_obj(obj): - """ Return the list of emails to send notification to when notifying + """Return the list of emails to send notification to when notifying about the specified issue or pull-request. """ emails = set() @@ -390,7 +390,7 @@ def _build_url(*args): def _fullname_to_url(fullname): - """ For forked projects, fullname is 'forks/user/...' but URL is + """For forked projects, fullname is 'forks/user/...' but URL is 'fork/user/...'. This is why we can't have nice things. """ if fullname.startswith("forks/"): @@ -409,7 +409,7 @@ def send_email( reporter=None, assignee=None, ): # pragma: no cover - """ Send an email with the specified information. + """Send an email with the specified information. :arg text: the content of the email to send :type text: unicode @@ -529,7 +529,9 @@ def send_email( keyfile = pagure_config.get("SMTP_KEYFILE") or None certfile = pagure_config.get("SMTP_CERTFILE") or None respcode, _ = smtp.starttls( - keyfile=keyfile, certfile=certfile, context=context, + keyfile=keyfile, + certfile=certfile, + context=context, ) if respcode != 220: _log.warning( @@ -555,7 +557,7 @@ def send_email( def notify_new_comment(comment, user=None): - """ Notify the people following an issue that a new comment was added + """Notify the people following an issue that a new comment was added to the issue. """ @@ -601,7 +603,7 @@ def notify_new_comment(comment, user=None): def notify_new_issue(issue, user=None): - """ Notify the people following a project that a new issue was added + """Notify the people following a project that a new issue was added to it. """ text = """ @@ -643,8 +645,7 @@ def notify_new_issue(issue, user=None): def notify_assigned_issue(issue, new_assignee, user): - """ Notify the people following an issue that the assignee changed. - """ + """Notify the people following an issue that the assignee changed.""" action = "reset" if new_assignee: action = "assigned to `%s`" % new_assignee.user @@ -688,8 +689,7 @@ The issue: `%s` of project: `%s` has been %s by %s. def notify_status_change_issue(issue, user): - """ Notify the people following a project that an issue changed status. - """ + """Notify the people following a project that an issue changed status.""" status = issue.status if status.lower() != "open" and issue.close_status: status = "%s as %s" % (status, issue.close_status) @@ -729,8 +729,7 @@ The status of the issue: `%s` of project: `%s` has been updated to: %s by %s. def notify_meta_change_issue(issue, user, msg): - """ Notify that a custom field changed - """ + """Notify that a custom field changed""" text = """ `%s` updated issue. @@ -766,8 +765,7 @@ def notify_meta_change_issue(issue, user, msg): def notify_assigned_request(request, new_assignee, user): - """ Notify the people following a pull-request that the assignee changed. - """ + """Notify the people following a pull-request that the assignee changed.""" action = "reset" if new_assignee: action = "assigned to `%s`" % new_assignee.user @@ -811,7 +809,7 @@ The pull-request: `%s` of project: `%s` has been %s by %s. def notify_new_pull_request(request): - """ Notify the people following a project that a new pull-request was + """Notify the people following a project that a new pull-request was added to it. """ text = """ @@ -851,7 +849,7 @@ def notify_new_pull_request(request): def notify_merge_pull_request(request, user): - """ Notify the people following a project that a pull-request was merged + """Notify the people following a project that a pull-request was merged in it. """ text = """ @@ -895,7 +893,7 @@ Merged pull-request: def notify_reopen_pull_request(request, user): - """ Notify the people following a project that a closed pull-request + """Notify the people following a project that a closed pull-request has been reopened. """ text = """ @@ -939,7 +937,7 @@ Reopened pull-request: def notify_closed_pull_request(request, user): - """ Notify the people following a project that a pull-request was + """Notify the people following a project that a pull-request was closed in it. """ text = """ @@ -984,7 +982,7 @@ Closed pull-request: def notify_pull_request_comment(comment, user): - """ Notify the people following a pull-request that a new comment was + """Notify the people following a pull-request that a new comment was added to it. """ text = """ @@ -1031,7 +1029,7 @@ def notify_pull_request_comment(comment, user): def notify_pull_request_flag(flag, request, user): - """ Notify the people following a pull-request that a new flag was + """Notify the people following a pull-request that a new flag was added to it. """ text = """ @@ -1068,8 +1066,7 @@ def notify_pull_request_flag(flag, request, user): def notify_new_email(email, user): - """ Ask the user to confirm to the email belong to them. - """ + """Ask the user to confirm to the email belong to them.""" root_url = pagure_config.get("APP_URL", flask.request.url_root) @@ -1103,7 +1100,7 @@ Your pagure admin. def notify_new_commits(abspath, project, branch, commits): - """ Notify the people following a project's commits that new commits have + """Notify the people following a project's commits that new commits have been added. """ # string note: abspath, project and branch can only contain ASCII @@ -1160,7 +1157,7 @@ To view more about the commits, visit: def notify_commit_flag(flag, user): - """ Notify the people following a project that a new flag was added + """Notify the people following a project that a new flag was added to one of its commit. """ text = """ diff --git a/pagure/lib/plugins.py b/pagure/lib/plugins.py index 9f66848..a89cdf8 100644 --- a/pagure/lib/plugins.py +++ b/pagure/lib/plugins.py @@ -16,7 +16,7 @@ from pagure.lib.model_base import BASE def get_plugin_names(blacklist=None, without_backref=False): - """ Return the list of plugins names. + """Return the list of plugins names. :arg blacklist: name or list of names to not return :type blacklist: string or list of strings @@ -61,7 +61,7 @@ def get_plugin(plugin_name): def get_enabled_plugins(project): - """ Returns a list of plugins enabled for a specific project. + """Returns a list of plugins enabled for a specific project. Args: project (model.Project): The project to look for. diff --git a/pagure/lib/query.py b/pagure/lib/query.py index 7b01aab..a169e51 100644 --- a/pagure/lib/query.py +++ b/pagure/lib/query.py @@ -101,7 +101,7 @@ def get_repotypes(): class Unspecified(object): - """ Custom None object used to indicate that the caller has not made + """Custom None object used to indicate that the caller has not made a choice for a particular argument. """ @@ -122,8 +122,7 @@ def set_pagure_ci(services): def get_user(session, key): - """ Searches for a user in the database for a given username or email. - """ + """Searches for a user in the database for a given username or email.""" user_obj = search_user(session, username=key) if not user_obj: user_obj = search_user(session, email=key) @@ -135,16 +134,14 @@ def get_user(session, key): def get_user_by_id(session, userid): - """ Searches for a user in the database for a given username or email. - """ + """Searches for a user in the database for a given username or email.""" query = session.query(model.User).filter(model.User.id == userid) return query.first() def get_blocked_users(session, username=None, date=None): - """ Returns all the users that are blocked in this pagure instance. - """ + """Returns all the users that are blocked in this pagure instance.""" now = datetime.datetime.utcnow() query = session.query(model.User).filter( model.User.refuse_sessions_before >= (date or now) @@ -160,7 +157,7 @@ def get_blocked_users(session, username=None, date=None): def get_next_id(session, projectid): - """ Returns the next identifier of a project ticket or pull-request + """Returns the next identifier of a project ticket or pull-request based on the identifier already in the database. """ query1 = session.query(func.max(model.Issue.id)).filter( @@ -180,7 +177,7 @@ def get_next_id(session, projectid): def search_user(session, username=None, email=None, token=None, pattern=None): - """ Searches the database for the user or users matching the given + """Searches the database for the user or users matching the given criterias. :arg session: the session to use to connect to the database. @@ -254,7 +251,7 @@ def are_valid_ssh_keys(keys): def find_ssh_key(session, search_key, username): - """ Finds and returns SSHKey matching the requested search_key. + """Finds and returns SSHKey matching the requested search_key. Args: session: database session @@ -281,7 +278,7 @@ def find_ssh_key(session, search_key, username): def create_deploykeys_ssh_keys_on_disk(project, gitolite_keydir): - """ Create the ssh keys for the projects' deploy keys on the key dir. + """Create the ssh keys for the projects' deploy keys on the key dir. This method does NOT support multiple ssh keys per deploy key. """ @@ -326,7 +323,7 @@ def create_deploykeys_ssh_keys_on_disk(project, gitolite_keydir): def create_user_ssh_keys_on_disk(user, gitolite_keydir): - """ Create the ssh keys for the user on the specific folder. + """Create the ssh keys for the user on the specific folder. This is the method allowing to have multiple ssh keys per user. """ @@ -1138,8 +1135,7 @@ def add_user_to_project( branches=None, required_groups=None, ): - """ Add a specified user to a specified project with a specified access - """ + """Add a specified user to a specified project with a specified access""" new_user_obj = get_user(session, new_user) @@ -1632,7 +1628,7 @@ def add_commit_flag( def get_commit_flag(session, project, commit_hash): - """ Return the commit flags corresponding to the specified git hash + """Return the commit flags corresponding to the specified git hash (commitid) in the specified repository. :arg session: the session with which to connect to the database @@ -1672,7 +1668,7 @@ def new_project( private=False, default_branch=None, ): - """ Create a new project based on the information provided. + """Create a new project based on the information provided. Is an async operation, and returns task ID. """ @@ -2009,7 +2005,7 @@ def new_pull_request( def link_pr_to_issue_on_description(session, request): - """ Link the given request to issues it may be referring to in its + """Link the given request to issues it may be referring to in its description if there is a description and such link in it. """ _log.debug("Drop the existing relations") @@ -2088,7 +2084,7 @@ def edit_issue( milestone=Unspecified, private=None, ): - """ Edit the specified issue. + """Edit the specified issue. :arg session: the session to use to connect to the database. :arg issue: the pagure.lib.model.Issue object to edit. @@ -2236,7 +2232,7 @@ def edit_issue( def update_project_settings(session, repo, settings, user, from_api=False): - """ Update the settings of a project. + """Update the settings of a project. If from_api is true, all values that are not specified will be changed back to their default value. @@ -2400,8 +2396,7 @@ def search_projects( private=None, owner=None, ): - """List existing projects - """ + """List existing projects""" projects = session.query(sqlalchemy.distinct(model.Project.id)) if owner is not None and username is not None: @@ -2647,8 +2642,7 @@ def list_users_projects( private=None, acls=None, ): - """List a users projects - """ + """List a users projects""" projects = session.query(sqlalchemy.distinct(model.Project.id)) if acls is None: @@ -2838,8 +2832,7 @@ def list_users_projects( def _get_project(session, name, user=None, namespace=None): - """Get a project from the database - """ + """Get a project from the database""" case = pagure_config.get("CASE_SENSITIVE", False) query = session.query(model.Project) @@ -2905,7 +2898,7 @@ def search_issues( order="desc", order_key=None, ): - """ Retrieve one or more issues associated to a project with the given + """Retrieve one or more issues associated to a project with the given criterias. Watch out that the closed argument is incompatible with the status @@ -3242,8 +3235,7 @@ def search_issues( def get_tags_of_project(session, project, pattern=None): - """ Returns the list of tags associated with the issues of a project. - """ + """Returns the list of tags associated with the issues of a project.""" query = ( session.query(model.TagColored) .filter(model.TagColored.tag != "") @@ -3260,16 +3252,14 @@ def get_tags_of_project(session, project, pattern=None): def get_tag(session, tag): - """ Returns a Tag object for the given tag text. - """ + """Returns a Tag object for the given tag text.""" query = session.query(model.Tag).filter(model.Tag.tag == tag) return query.first() def get_colored_tag(session, tag, project_id): - """ Returns a TagColored object for the given tag text. - """ + """Returns a TagColored object for the given tag text.""" query = ( session.query(model.TagColored) .filter(model.TagColored.tag == tag) @@ -3297,8 +3287,7 @@ def search_pull_requests( order_key=None, search_pattern=None, ): - """ Retrieve the specified pull-requests. - """ + """Retrieve the specified pull-requests.""" query = session.query(model.PullRequest) @@ -3444,8 +3433,7 @@ def search_pull_requests( def reopen_pull_request(session, request, user): - """ Re-Open the provided pull request - """ + """Re-Open the provided pull request""" if request.status != "Closed": raise pagure.exceptions.PagureException( "Trying to reopen a pull request that is not closed" @@ -3479,8 +3467,7 @@ def reopen_pull_request(session, request, user): def close_pull_request(session, request, user, merged=True): - """ Close the provided pull-request. - """ + """Close the provided pull-request.""" user_obj = get_user(session, user) if merged is True: @@ -3527,8 +3514,7 @@ def close_pull_request(session, request, user, merged=True): def reset_status_pull_request(session, project, but_uids=None): - """ Reset the status of all opened Pull-Requests of a project. - """ + """Reset the status of all opened Pull-Requests of a project.""" query = ( session.query(model.PullRequest) .filter(model.PullRequest.project_id == project.id) @@ -3585,8 +3571,7 @@ def add_attachment(repo, issue, attachmentfolder, user, filename, filestream): def get_issue_statuses(session): - """ Return the complete list of status an issue can have. - """ + """Return the complete list of status an issue can have.""" output = [] statuses = session.query(model.StatusIssue).all() for status in statuses: @@ -3595,8 +3580,7 @@ def get_issue_statuses(session): def get_issue_comment(session, issue_uid, comment_id): - """ Return a specific comment of a specified issue. - """ + """Return a specific comment of a specified issue.""" query = ( session.query(model.IssueComment) .filter(model.IssueComment.issue_uid == issue_uid) @@ -3609,8 +3593,7 @@ def get_issue_comment(session, issue_uid, comment_id): def get_issue_comment_by_user_and_comment( session, issue_uid, user_id, content ): - """ Return a specific comment of a specified issue. - """ + """Return a specific comment of a specified issue.""" query = ( session.query(model.IssueComment) .filter(model.IssueComment.issue_uid == issue_uid) @@ -3622,8 +3605,7 @@ def get_issue_comment_by_user_and_comment( def get_request_comment(session, request_uid, comment_id): - """ Return a specific comment of a specified request. - """ + """Return a specific comment of a specified request.""" query = ( session.query(model.PullRequestComment) .filter(model.PullRequestComment.pull_request_uid == request_uid) @@ -3634,7 +3616,7 @@ def get_request_comment(session, request_uid, comment_id): def get_issue_by_uid(session, issue_uid): - """ Return the issue corresponding to the specified unique identifier. + """Return the issue corresponding to the specified unique identifier. :arg session: the session to use to connect to the database. :arg issue_uid: the unique identifier of an issue. This identifier is @@ -3651,7 +3633,7 @@ def get_issue_by_uid(session, issue_uid): def get_request_by_uid(session, request_uid): - """ Return the request corresponding to the specified unique identifier. + """Return the request corresponding to the specified unique identifier. :arg session: the session to use to connect to the database. :arg request_uid: the unique identifier of a request. This identifier is @@ -3670,7 +3652,7 @@ def get_request_by_uid(session, request_uid): def get_pull_request_flag_by_uid(session, request, flag_uid): - """ Return the flag corresponding to the specified unique identifier. + """Return the flag corresponding to the specified unique identifier. :arg session: the session to use to connect to the database. :arg request: the pull-request that was flagged @@ -3692,7 +3674,7 @@ def get_pull_request_flag_by_uid(session, request, flag_uid): def get_commit_flag_by_uid(session, commit_hash, flag_uid): - """ Return the flag corresponding to the specified unique identifier. + """Return the flag corresponding to the specified unique identifier. :arg session: the session to use to connect to the database. :arg commit_hash: the hash of the commit that got flagged @@ -3754,8 +3736,8 @@ def set_up_user( def allowed_emailaddress(email): - """ check if email domains are restricted and if a given email address - is allowed. """ + """check if email domains are restricted and if a given email address + is allowed.""" allowed_email_domains = pagure_config.get("ALLOWED_EMAIL_DOMAINS", None) if allowed_email_domains: for domain in allowed_email_domains: @@ -3836,7 +3818,7 @@ def avatar_url_from_email(email, size=64, default="retro", dns=False): def update_tags(session, obj, tags, username): - """ Update the tags of a specified object (adding or removing them). + """Update the tags of a specified object (adding or removing them). This object can be either an issue or a project. """ @@ -3866,9 +3848,7 @@ def update_tags(session, obj, tags, username): def update_dependency_issue(session, repo, issue, depends, username): - """ Update the dependency of a specified issue (adding or removing them) - - """ + """Update the dependency of a specified issue (adding or removing them)""" if isinstance(depends, six.string_types): depends = [depends] @@ -3911,7 +3891,7 @@ def update_dependency_issue(session, repo, issue, depends, username): def update_blocked_issue(session, repo, issue, blocks, username): - """ Update the upstream dependency of a specified issue (adding or + """Update the upstream dependency of a specified issue (adding or removing them) """ @@ -3959,8 +3939,7 @@ def update_blocked_issue(session, repo, issue, blocks, username): def add_user_pending_email(session, userobj, email): - """ Add the provided email to the specified user. - """ + """Add the provided email to the specified user.""" try: allowed_emailaddress(email) except pagure.exceptions.PagureException: @@ -3989,7 +3968,7 @@ def add_user_pending_email(session, userobj, email): def resend_pending_email(session, userobj, email): - """ Resend to the user the confirmation email for the provided email + """Resend to the user the confirmation email for the provided email address. """ other_user = search_user(session, email=email) @@ -4012,7 +3991,7 @@ def resend_pending_email(session, userobj, email): def search_pending_email(session, email=None, token=None): - """ Searches the database for the pending email matching the given + """Searches the database for the pending email matching the given criterias. :arg session: the session to use to connect to the database. @@ -4038,9 +4017,7 @@ def search_pending_email(session, email=None, token=None): def generate_hook_token(session): - """ For each project in the database, re-generate a unique hook_token. - - """ + """For each project in the database, re-generate a unique hook_token.""" for project in search_projects(session): project.hook_token = pagure.lib.login.id_generator(40) @@ -4049,9 +4026,7 @@ def generate_hook_token(session): def get_group_types(session, group_type=None): - """ Return the list of type a group can have. - - """ + """Return the list of type a group can have.""" query = session.query(model.PagureGroupType).order_by( model.PagureGroupType.group_type ) @@ -4072,9 +4047,7 @@ def search_groups( limit=None, count=False, ): - """ Return the groups based on the criteria specified. - - """ + """Return the groups based on the criteria specified.""" query = session.query(model.PagureGroup).order_by( model.PagureGroup.group_type, model.PagureGroup.group_name ) @@ -4113,7 +4086,7 @@ def search_groups( def add_user_to_group( session, username, group, user, is_admin, from_external=False ): - """ Add the specified user to the given group. + """Add the specified user to the given group. from_external indicates whether this is a remotely synced group. """ @@ -4156,8 +4129,7 @@ def add_user_to_group( def edit_group_info(session, group, display_name, description, user, is_admin): - """ Edit the information regarding a given group. - """ + """Edit the information regarding a given group.""" action_user = user user = search_user(session, username=user) if not user: @@ -4210,8 +4182,7 @@ def delete_user_of_group( force=False, from_external=False, ): - """ Removes the specified user from the given group. - """ + """Removes the specified user from the given group.""" group_obj = search_groups(session, group_name=groupname) if not group_obj: @@ -4267,8 +4238,7 @@ def add_group( is_admin, blacklist, ): - """ Creates a new group with the given information. - """ + """Creates a new group with the given information.""" if " " in group_name: raise pagure.exceptions.PagureException( "Spaces are not allowed in group names: %s" % group_name @@ -4326,7 +4296,7 @@ def add_group( def get_user_group(session, userid, groupid): - """ Return a specific user_group for the specified group and user + """Return a specific user_group for the specified group and user identifiers. :arg session: the session with which to connect to the database. @@ -4354,7 +4324,7 @@ def is_group_member(session, user, groupname): def get_api_token(session, token_str): - """ Return the Token object corresponding to the provided token string + """Return the Token object corresponding to the provided token string if there is any, returns None otherwise. """ query = session.query(model.Token).filter(model.Token.id == token_str) @@ -4363,7 +4333,7 @@ def get_api_token(session, token_str): def get_acls(session, restrict=None): - """ Returns all the possible ACLs a token can have according to the + """Returns all the possible ACLs a token can have according to the database. """ query = session.query(model.ACL).order_by(model.ACL.name) @@ -4379,7 +4349,7 @@ def get_acls(session, restrict=None): def add_token_to_user( session, project, acls, username, expiration_date, description=None ): - """ Create a new token for the specified user on the specified project + """Create a new token for the specified user on the specified project with the given ACLs. """ acls_obj = session.query(model.ACL).filter(model.ACL.name.in_(acls)).all() @@ -4413,7 +4383,7 @@ def add_token_to_user( def _convert_markdown(md_processor, text): - """ Small function converting the text to html using the given markdown + """Small function converting the text to html using the given markdown processor. This was done in order to make testing it easier. @@ -4422,8 +4392,7 @@ def _convert_markdown(md_processor, text): def text2markdown(text, extended=True, readme=False): - """ Simple text to html converter using the markdown library. - """ + """Simple text to html converter using the markdown library.""" extensions = [ "markdown.extensions.def_list", "markdown.extensions.fenced_code", @@ -4490,7 +4459,7 @@ def filter_img_src(name, value): def clean_input(text, ignore=None): - """ For a given html text, escape everything we do not want to support + """For a given html text, escape everything we do not want to support to avoid potential security breach. """ if ignore and not isinstance(ignore, (tuple, set, list)): @@ -4564,8 +4533,7 @@ def clean_input(text, ignore=None): def could_be_text(text): - """ Returns whether we think this chain of character could be text or not - """ + """Returns whether we think this chain of character could be text or not""" try: text.decode("utf-8") return True @@ -4711,7 +4679,7 @@ def get_pull_request_of_user( def update_watch_status(session, project, user, watch): - """ Update the user status for watching a project. + """Update the user status for watching a project. The watch status can be: -1: reset the watch status to default @@ -4784,8 +4752,7 @@ def update_watch_status(session, project, user, watch): def get_watch_level_on_repo( session, user, repo, repouser=None, namespace=None ): - """ Get a list representing the watch level of the user on the project. - """ + """Get a list representing the watch level of the user on the project.""" # If a user wasn't passed in, we can't determine their watch level if user is None: return [] @@ -4903,7 +4870,7 @@ def user_watch_list(session, user, exclude_groups=None): def set_watch_obj(session, user, obj, watch_status): - """ Set the watch status of the user on the specified object. + """Set the watch status of the user on the specified object. Objects can be either an issue or a pull-request """ @@ -4952,8 +4919,7 @@ def set_watch_obj(session, user, obj, watch_status): def get_watch_list(session, obj): - """ Return a list of all the users that are watching the "object" - """ + """Return a list of all the users that are watching the "object" """ private = False if obj.isa == "issue": private = obj.private @@ -5020,8 +4986,7 @@ def get_watch_list(session, obj): def save_report(session, repo, name, url, username): - """ Save the report of issues based on the given URL of the project. - """ + """Save the report of issues based on the given URL of the project.""" url_obj = urlparse(url) url = url_obj.geturl().replace(url_obj.query, "") query = {} @@ -5040,7 +5005,7 @@ def save_report(session, repo, name, url, username): def set_custom_key_fields(session, project, fields, types, data, notify=None): - """ Set or update the custom key fields of a project with the values + """Set or update the custom key fields of a project with the values provided. "data" is currently only used for lists and dates """ @@ -5087,8 +5052,7 @@ def set_custom_key_fields(session, project, fields, types, data, notify=None): def set_custom_key_value(session, issue, key, value): - """ Set or update the value of the specified custom key. - """ + """Set or update the value of the specified custom key.""" query = ( session.query(model.IssueValues) @@ -5152,7 +5116,7 @@ def set_custom_key_value(session, issue, key, value): def get_yearly_stats_user(session, user, date, tz="UTC"): - """ Return the activity of the specified user in the year preceding the + """Return the activity of the specified user in the year preceding the specified date. 'offset' is intended to be a timezone offset from UTC, in minutes: you can discover the offset for a timezone and pass that in order for the results to be relative to that timezone. Note, offset @@ -5178,7 +5142,7 @@ def get_yearly_stats_user(session, user, date, tz="UTC"): def get_user_activity_day(session, user, date, tz="UTC"): - """ Return the activity of the specified user on the specified date. + """Return the activity of the specified user on the specified date. 'offset' is intended to be a timezone offset from UTC, in minutes: you can discover the offset for a timezone and pass that, so this will return activity that occurred on the specified date in the @@ -5276,7 +5240,7 @@ def email_logs_count(session, email): def update_log_email_user(session, email, user): - """ Update the logs with the provided email to point to the specified + """Update the logs with the provided email to point to the specified user. """ session.query(model.PagureLog).filter( @@ -5297,8 +5261,7 @@ def get_custom_key(session, project, keyname): def get_active_milestones(session, project): - """ Returns the list of all the active milestones for a given project. - """ + """Returns the list of all the active milestones for a given project.""" query = ( session.query(model.Issue.milestone) @@ -5311,7 +5274,7 @@ def get_active_milestones(session, project): def add_metadata_update_notif(session, obj, messages, user): - """ Add a notification to the specified issue with the given messages + """Add a notification to the specified issue with the given messages which should reflect changes made to the meta-data of the issue. """ if not messages: @@ -5419,7 +5382,7 @@ def get_access_levels(session): def get_obj_access(session, project_obj, obj): - """ Returns the level of access the user/group has on the project. + """Returns the level of access the user/group has on the project. :arg session: the session to use to connect to the database. :arg project_obj: SQLAlchemy object of Project class @@ -5451,7 +5414,7 @@ def search_token( expired=False, description=None, ): - """ Searches the API tokens corresponding to the criterias specified. + """Searches the API tokens corresponding to the criterias specified. :arg session: the session to use to connect to the database. :arg acls: List of the ACL associated with these API tokens @@ -5497,7 +5460,7 @@ def search_token( def set_project_owner(session, project, user, required_groups=None): - """ Set the ownership of a project + """Set the ownership of a project :arg session: the session to use to connect to the database. :arg project: a Project object representing the project's ownership to change. @@ -5604,7 +5567,7 @@ def get_pagination_metadata( def update_star_project(session, repo, star, user): - """ Unset or set the star status depending on the star value. + """Unset or set the star status depending on the star value. :arg session: the session to use to connect to the database. :arg repo: a model.Project object representing the project to star/unstar @@ -5626,7 +5589,7 @@ def update_star_project(session, repo, star, user): def _star_project(session, repo, user): - """ Star a project + """Star a project :arg session: Session object to connect to db with :arg repo: model.Project object representing the repo to star @@ -5642,7 +5605,7 @@ def _star_project(session, repo, user): def _unstar_project(session, repo, user): - """ Unstar a project + """Unstar a project :arg session: Session object to connect to db with :arg repo: model.Project object representing the repo to unstar :arg user: model.User object who is unstarring this repo @@ -5663,7 +5626,7 @@ 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 + """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 :arg user: model.User object @@ -5682,7 +5645,7 @@ def _get_stargazer_obj(session, repo, user): def has_starred(session, repo, user): - """ Check if a given user has starred a particular project + """Check if a given user has starred a particular project :arg session: The session object to query the db with :arg repo: model.Project object for which the star is checked @@ -5700,7 +5663,7 @@ def has_starred(session, repo, user): def update_read_only_mode(session, repo, read_only=True): - """ Remove the read only mode from the project + """Remove the read only mode from the project :arg session: The session object to query the db with :arg repo: model.Project object to mark/unmark read only @@ -5724,7 +5687,7 @@ def update_read_only_mode(session, repo, read_only=True): def issues_history_stats(session, project, detailed=False, weeks_range=53): - """ Returns the number of opened issues on the specified project over + """Returns the number of opened issues on the specified project over the last 365 days :arg session: The session object to query the db with @@ -5807,7 +5770,7 @@ def issues_history_stats(session, project, detailed=False, weeks_range=53): def get_authorized_project( session, project_name, user=None, namespace=None, asuser=None ): - """ Retrieving the project with user permission constraint + """Retrieving the project with user permission constraint :arg session: The SQLAlchemy session to use :type session: sqlalchemy.orm.session.Session @@ -5833,7 +5796,7 @@ def get_authorized_project( def get_project_family(session, project): - """ Retrieve the family of the specified project, ie: all the forks + """Retrieve the family of the specified project, ie: all the forks of the main project. If the specified project is a fork, let's work our way up the chain until we find the main project so we can go down and get all the forks @@ -5868,7 +5831,7 @@ def get_project_family(session, project): def link_pr_issue(session, issue, request, origin="commit"): - """ Associate the specified issue with the specified pull-requets. + """Associate the specified issue with the specified pull-requets. :arg session: The SQLAlchemy session to use :type session: sqlalchemy.orm.session.Session @@ -5890,7 +5853,7 @@ def link_pr_issue(session, issue, request, origin="commit"): def remove_user_of_project(session, user, project, agent): - """ Remove the specified user from the given project. + """Remove the specified user from the given project. :arg session: the session with which to connect to the database. :arg user: an pagure.lib.model.User object to remove from the project. @@ -5932,7 +5895,7 @@ def remove_user_of_project(session, user, project, agent): def create_board(session, project, name, active, tag): - """ Create a board on a given project. + """Create a board on a given project. :arg session: the session with which to connect to the database. :arg project: the model.Project of the project that is creating the @@ -5957,7 +5920,7 @@ def create_board(session, project, name, active, tag): def edit_board(session, project, name, active, tag, bg_color=None): - """ Edit an existing board on a given project. + """Edit an existing board on a given project. :arg session: the session with which to connect to the database. :arg project: the model.Project of the project that is creating the @@ -5995,7 +5958,7 @@ def edit_board(session, project, name, active, tag, bg_color=None): def delete_board(session, project, names): - """ Delete boards of a given project. + """Delete boards of a given project. :arg session: the session with which to connect to the database. :arg project: the model.Project of the project that is creating the @@ -6017,7 +5980,7 @@ def delete_board(session, project, names): def update_board_status( session, board, name, rank, default, close, close_status, bg_color ): - """ Create or update the board statuses of a project. + """Create or update the board statuses of a project. :arg session: the session with which to connect to the database. :arg board: the model.Board of the board being updated. @@ -6063,7 +6026,7 @@ def update_board_status( def add_issue_to_boards( session, issue, board_name, user, status_id=None, rank=None ): - """ Add the given issue to the boards specified. + """Add the given issue to the boards specified. :arg session: the session with which to connect to the database. :arg issue: the model.Issue of the issue to add to the boards. @@ -6104,13 +6067,15 @@ def add_issue_to_boards( rank = len(status.boards_issues) + 1 board_issue = model.BoardIssues( - issue_uid=issue.uid, status_id=status.id, rank=rank, + issue_uid=issue.uid, + status_id=status.id, + rank=rank, ) session.add(board_issue) def remove_issue_from_boards(session, issue, board_names, user): - """ Remove the given issue from the specified boards. + """Remove the given issue from the specified boards. :arg session: the session with which to connect to the database. :arg issue: the model.Issue of the issue to add to the boards. @@ -6135,8 +6100,7 @@ def update_ticket_board_status( ticket_uid=None, ticket_id=None, ): - """ Set the status of a ticket on a given board. - """ + """Set the status of a ticket on a given board.""" if not ticket_uid and not ticket_id: raise pagure.exceptions.PagureException( "One of ticket_id/ticket_uid must be provided" @@ -6203,7 +6167,9 @@ def update_ticket_board_status( if board.name not in seen: _log.debug("Adding to a new board") board_issue = model.BoardIssues( - issue_uid=ticket.uid, status_id=status.id, rank=rank, + issue_uid=ticket.uid, + status_id=status.id, + rank=rank, ) session.add(board_issue) @@ -6233,7 +6199,10 @@ def update_ticket_board_status( elif not status.close and ticket.status != "Open": comments.extend( edit_issue( - session=session, issue=ticket, user=user, status="Open", + session=session, + issue=ticket, + user=user, + status="Open", ) ) session.add(ticket) diff --git a/pagure/lib/repo.py b/pagure/lib/repo.py index fb6774d..4592fe6 100644 --- a/pagure/lib/repo.py +++ b/pagure/lib/repo.py @@ -22,7 +22,7 @@ _log = logging.getLogger(__name__) def get_pygit2_version(): - """ Return pygit2 version as a tuple of integers. + """Return pygit2 version as a tuple of integers. This is needed for correct version comparison. """ return tuple([int(i) for i in pygit2.__version__.split(".")]) @@ -50,14 +50,14 @@ def run_command(command, cwd=None): class PagureRepo(pygit2.Repository): - """ An utility class allowing to go around pygit2's inability to be + """An utility class allowing to go around pygit2's inability to be stable. """ @staticmethod def clone(path_from, path_to, checkout_branch=None, bare=False): - """ Clone the git repo at the specified path to the specified location. + """Clone the git repo at the specified path to the specified location. This method is meant to replace pygit2.clone_repository which for us leaks file descriptors on large project leading to "Too many open files @@ -87,7 +87,7 @@ class PagureRepo(pygit2.Repository): remote.push(refname) def pull(self, remote_name="origin", branch="master", force=False): - """ pull changes for the specified remote (defaults to origin). + """pull changes for the specified remote (defaults to origin). Code from MichaelBoselowitz at: https://github.com/MichaelBoselowitz/pygit2-examples/blob/ @@ -133,7 +133,7 @@ class PagureRepo(pygit2.Repository): @staticmethod def log(path, log_options=None, target=None, fromref=None): - """ Run git log with the specified options at the specified target. + """Run git log with the specified options at the specified target. This method runs the system's `git log` command since pygit2 doesn't offer us the possibility to do this via them. @@ -159,7 +159,7 @@ class PagureRepo(pygit2.Repository): @staticmethod def get_active_branches(path, nbranch=8, catch_exception=False): - """ Returns the active branches in the git repo at the specified + """Returns the active branches in the git repo at the specified location. :arg path: the location of the git repo diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index 8be0769..2baf7c5 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -61,7 +61,7 @@ def augment_celery_log(**kwargs): def get_result(uuid): - """ Returns the AsyncResult object for a given task. + """Returns the AsyncResult object for a given task. :arg uuid: the unique identifier of the task to retrieve. :type uuid: str @@ -82,7 +82,7 @@ def ret(endpoint, **kwargs): def generate_gitolite_acls( self, session, namespace=None, name=None, user=None, group=None ): - """ Generate the gitolite configuration file either entirely or for a + """Generate the gitolite configuration file either entirely or for a specific project. :arg session: SQLAlchemy session object @@ -131,7 +131,7 @@ def generate_gitolite_acls( @conn.task(queue=pagure_config.get("GITOLITE_CELERY_QUEUE", None), bind=True) @pagure_task def gitolite_post_compile_only(self, session): - """ Do gitolite post-processing only. Most importantly, this processes SSH + """Do gitolite post-processing only. Most importantly, this processes SSH keys used by gitolite. This is an optimization task that's supposed to be used if you only need to run `gitolite trigger POST_COMPILE` without touching any other gitolite configuration @@ -149,7 +149,7 @@ def gitolite_post_compile_only(self, session): def delete_project( self, session, namespace=None, name=None, user=None, action_user=None ): - """ Delete a project in pagure. + """Delete a project in pagure. This is achieved in three steps: - Remove the project from gitolite.conf @@ -222,7 +222,7 @@ def create_project( ignore_existing_repo, default_branch=None, ): - """ Create a project. + """Create a project. :arg session: SQLAlchemy session object :type session: sqlalchemy.orm.session.Session @@ -332,7 +332,7 @@ def create_project( def update_git( self, session, name, namespace, user, ticketuid=None, requestuid=None ): - """ Update the JSON representation of either a ticket or a pull-request + """Update the JSON representation of either a ticket or a pull-request depending on the argument specified. """ project = pagure.lib.query._get_project( @@ -364,7 +364,7 @@ def update_git( @conn.task(queue=pagure_config.get("SLOW_CELERY_QUEUE", None), bind=True) @pagure_task def clean_git(self, session, name, namespace, user, obj_repotype, obj_uid): - """ Remove the JSON representation of a ticket on the git repository + """Remove the JSON representation of a ticket on the git repository for tickets. """ project = pagure.lib.query._get_project( @@ -393,8 +393,7 @@ def update_file_in_git( username, email, ): - """ Update a file in the specified git repo. - """ + """Update a file in the specified git repo.""" userobj = pagure.lib.query.search_user(session, username=username) project = pagure.lib.query._get_project( session, namespace=namespace, name=name, user=user @@ -424,8 +423,7 @@ def update_file_in_git( @conn.task(queue=pagure_config.get("MEDIUM_CELERY_QUEUE", None), bind=True) @pagure_task def delete_branch(self, session, name, namespace, user, branchname): - """ Delete a branch from a git repo. - """ + """Delete a branch from a git repo.""" project = pagure.lib.query._get_project( session, namespace=namespace, name=name, user=user ) @@ -456,7 +454,7 @@ def fork( editbranch, editfile, ): - """ Forks the specified project for the specified user. + """Forks the specified project for the specified user. :arg namespace: the namespace of the project :type namespace: str @@ -554,8 +552,7 @@ def fork( @conn.task(queue=pagure_config.get("FAST_CELERY_QUEUE", None), bind=True) @pagure_task def pull_remote_repo(self, session, remote_git, branch_from): - """ Clone a remote git repository locally for remote PRs. - """ + """Clone a remote git repository locally for remote PRs.""" clonepath = pagure.utils.get_remote_repo_path( remote_git, branch_from, ignore_non_exist=True @@ -571,7 +568,7 @@ def pull_remote_repo(self, session, remote_git, branch_from): @conn.task(queue=pagure_config.get("MEDIUM_CELERY_QUEUE", None), bind=True) @pagure_task def refresh_remote_pr(self, session, name, namespace, user, requestid): - """ Refresh the local clone of a git repository used in a remote + """Refresh the local clone of a git repository used in a remote pull-request. """ project = pagure.lib.query._get_project( @@ -608,8 +605,7 @@ def refresh_remote_pr(self, session, name, namespace, user, requestid): @conn.task(queue=pagure_config.get("FAST_CELERY_QUEUE", None), bind=True) @pagure_task def move_to_repospanner(self, session, name, namespace, user, region): - """ Move a repository to a repoSpanner region. - """ + """Move a repository to a repoSpanner region.""" project = pagure.lib.query._get_project( session, namespace=namespace, name=name, user=user ) @@ -708,8 +704,7 @@ def move_to_repospanner(self, session, name, namespace, user, region): @conn.task(queue=pagure_config.get("FAST_CELERY_QUEUE", None), bind=True) @pagure_task def refresh_pr_cache(self, session, name, namespace, user, but_uids=None): - """ Refresh the merge status cached of pull-requests. - """ + """Refresh the merge status cached of pull-requests.""" project = pagure.lib.query._get_project( session, namespace=namespace, name=name, user=user ) @@ -724,8 +719,7 @@ def refresh_pr_cache(self, session, name, namespace, user, but_uids=None): def rebase_pull_request( self, session, name, namespace, user, requestid, user_rebaser ): - """ Rebase a pull-request. - """ + """Rebase a pull-request.""" project = pagure.lib.query._get_project( session, namespace=namespace, name=name, user=user ) @@ -760,8 +754,7 @@ def merge_pull_request( user_merger, delete_branch_after=False, ): - """ Merge pull-request. - """ + """Merge pull-request.""" project = pagure.lib.query._get_project( session, namespace=namespace, name=name, user=user ) @@ -810,8 +803,7 @@ def merge_pull_request( def add_file_to_git( self, session, name, namespace, user, user_attacher, issueuid, filename ): - """ Add a file to the specified git repo. - """ + """Add a file to the specified git repo.""" project = pagure.lib.query._get_project( session, namespace=namespace, name=name, user=user ) @@ -837,11 +829,11 @@ def add_file_to_git( @conn.task(queue=pagure_config.get("MEDIUM_CELERY_QUEUE", None), bind=True) @pagure_task def project_dowait(self, session, name, namespace, user): - """ This is a task used to test the locking systems. + """This is a task used to test the locking systems. It should never be allowed to be called in production instances, since that would allow an attacker to basically DOS a project by calling this - repeatedly. """ + repeatedly.""" assert pagure_config.get("ALLOW_PROJECT_DOWAIT", False) project = pagure.lib.query._get_project( @@ -859,7 +851,7 @@ def project_dowait(self, session, name, namespace, user): @conn.task(queue=pagure_config.get("MEDIUM_CELERY_QUEUE", None), bind=True) @pagure_task def sync_pull_ref(self, session, name, namespace, user, requestid): - """ Synchronize a pull/ reference from the content in the forked repo, + """Synchronize a pull/ reference from the content in the forked repo, allowing local checkout of the pull-request. """ project = pagure.lib.query._get_project( @@ -893,7 +885,7 @@ def sync_pull_ref(self, session, name, namespace, user, requestid): @conn.task(queue=pagure_config.get("FAST_CELERY_QUEUE", None), bind=True) @pagure_task def update_pull_request(self, session, pr_uid, username=None): - """ Updates a pull-request in the DB once a commit was pushed to it in + """Updates a pull-request in the DB once a commit was pushed to it in git. """ request = pagure.lib.query.get_request_by_uid(session, pr_uid) @@ -920,8 +912,7 @@ def update_pull_request(self, session, pr_uid, username=None): @conn.task(queue=pagure_config.get("MEDIUM_CELERY_QUEUE", None), bind=True) @pagure_task def update_checksums_file(self, session, folder, filenames): - """ Update the checksums file in the release folder of the project. - """ + """Update the checksums file in the release folder of the project.""" sha_file = os.path.join(folder, "CHECKSUMS") new_file = not os.path.exists(sha_file) @@ -960,7 +951,7 @@ def update_checksums_file(self, session, folder, filenames): @conn.task(queue=pagure_config.get("FAST_CELERY_QUEUE", None), bind=True) @pagure_task def commits_author_stats(self, session, repopath): - """ Returns some statistics about commits made against the specified + """Returns some statistics about commits made against the specified git repository. """ @@ -1023,7 +1014,7 @@ def commits_author_stats(self, session, repopath): @conn.task(queue=pagure_config.get("FAST_CELERY_QUEUE", None), bind=True) @pagure_task def commits_history_stats(self, session, repopath): - """ Returns the evolution of the commits made against the specified + """Returns the evolution of the commits made against the specified git repository. """ @@ -1049,7 +1040,7 @@ def commits_history_stats(self, session, repopath): @conn.task(queue=pagure_config.get("MEDIUM_CELERY_QUEUE", None), bind=True) @pagure_task def link_pr_to_ticket(self, session, pr_uid): - """ Link the specified pull-request against the ticket(s) mentioned in + """Link the specified pull-request against the ticket(s) mentioned in the commits of the pull-request """ @@ -1237,7 +1228,7 @@ def git_garbage_collect(self, session, repopath): def generate_archive( self, session, project, namespace, username, commit, tag, name, archive_fmt ): - """ Generate the archive of the specified project on the specified + """Generate the archive of the specified project on the specified commit with the given name and archive format. Currently only support the following format: gzip and tar.gz @@ -1275,7 +1266,7 @@ def generate_archive( @conn.task(queue=pagure_config.get("AUTHORIZED_KEYS_QUEUE", None), bind=True) @pagure_task def add_key_to_authorized_keys(self, session, ssh_folder, username, sshkey): - """ Add the specified key to the the `authorized_keys` file of the + """Add the specified key to the the `authorized_keys` file of the specified ssh folder. """ if not os.path.exists(ssh_folder): @@ -1298,7 +1289,7 @@ def add_key_to_authorized_keys(self, session, ssh_folder, username, sshkey): @conn.task(queue=pagure_config.get("AUTHORIZED_KEYS_QUEUE", None), bind=True) @pagure_task def remove_key_from_authorized_keys(self, session, ssh_folder, sshkey): - """ Remove the specified key from the the `authorized_keys` file of the + """Remove the specified key from the the `authorized_keys` file of the specified ssh folder. """ if not os.path.exists(ssh_folder): diff --git a/pagure/lib/tasks_mirror.py b/pagure/lib/tasks_mirror.py index 2757fee..4a07cf2 100644 --- a/pagure/lib/tasks_mirror.py +++ b/pagure/lib/tasks_mirror.py @@ -79,7 +79,7 @@ def _serialize_public_ssh_key(key): def _create_ssh_key(keyfile): - """ Create the public and private ssh keys. + """Create the public and private ssh keys. The specified file name will be the private key and the public one will be in a similar file name ending with a '.pub'. @@ -109,8 +109,7 @@ def _create_ssh_key(keyfile): @conn.task(queue=pagure_config["MIRRORING_QUEUE"], bind=True) @pagure_task def setup_mirroring(self, session, username, namespace, name): - """ Setup the specified project for mirroring. - """ + """Setup the specified project for mirroring.""" plugin = pagure.lib.plugins.get_plugin("Mirroring") plugin.db_object() @@ -163,8 +162,7 @@ def setup_mirroring(self, session, username, namespace, name): @conn.task(queue=pagure_config["MIRRORING_QUEUE"], bind=True) @pagure_task def teardown_mirroring(self, session, username, namespace, name): - """ Stop the mirroring of the specified project. - """ + """Stop the mirroring of the specified project.""" plugin = pagure.lib.plugins.get_plugin("Mirroring") plugin.db_object() @@ -192,8 +190,7 @@ def teardown_mirroring(self, session, username, namespace, name): @conn.task(queue=pagure_config["MIRRORING_QUEUE"], bind=True) @pagure_task def mirror_project(self, session, username, namespace, name): - """ Does the actual mirroring of the specified project. - """ + """Does the actual mirroring of the specified project.""" plugin = pagure.lib.plugins.get_plugin("Mirroring") plugin.db_object() diff --git a/pagure/lib/tasks_services.py b/pagure/lib/tasks_services.py index 74e10fa..72ccc86 100644 --- a/pagure/lib/tasks_services.py +++ b/pagure/lib/tasks_services.py @@ -117,7 +117,7 @@ def call_web_hooks(project, topic, msg, urls): def webhook_notification( self, session, topic, msg, namespace=None, name=None, user=None ): - """ Send webhook notifications about an event on that project. + """Send webhook notifications about an event on that project. :arg session: SQLAlchemy session object :type session: sqlalchemy.orm.session.Session @@ -167,7 +167,7 @@ def log_commit_send_notifications( namespace=None, username=None, ): - """ Send webhook notifications about an event on that project. + """Send webhook notifications about an event on that project. :arg session: SQLAlchemy session object :type session: sqlalchemy.orm.session.Session @@ -272,7 +272,7 @@ def load_json_commits_to_db( namespace=None, username=None, ): - """ Loads into the database the specified commits that have been pushed + """Loads into the database the specified commits that have been pushed to either the tickets or the pull-request repository. """ @@ -409,9 +409,7 @@ def trigger_ci_build( pr_uid=None, ): - """ Triggers a new run of the CI system on the specified pull-request. - - """ + """Triggers a new run of the CI system on the specified pull-request.""" pagure.lib.plugins.get_plugin("Pagure CI") if not pr_uid and not project_name: diff --git a/pagure/lib/tasks_utils.py b/pagure/lib/tasks_utils.py index 5958e58..6cc453d 100644 --- a/pagure/lib/tasks_utils.py +++ b/pagure/lib/tasks_utils.py @@ -18,7 +18,7 @@ from pagure.config import config as pagure_config def pagure_task(function): - """ Simple decorator that is responsible for: + """Simple decorator that is responsible for: * Adjusting the status of the task when it starts * Creating and cleaning up a SQLAlchemy session """ diff --git a/pagure/login_forms.py b/pagure/login_forms.py index 420cc3b..7e6418a 100644 --- a/pagure/login_forms.py +++ b/pagure/login_forms.py @@ -31,8 +31,7 @@ except ImportError: def same_password(form, field): - """ Check if the data in the field is the same as in the password field. - """ + """Check if the data in the field is the same as in the password field.""" if field.data != form.password.data: raise wtforms.validators.ValidationError( "Both password fields should be equal" @@ -43,7 +42,8 @@ class LostPasswordForm(FlaskForm): """ Form to ask for a password change. """ username = wtforms.StringField( - "username", [wtforms.validators.DataRequired()], + "username", + [wtforms.validators.DataRequired()], ) @@ -51,10 +51,12 @@ class ResetPasswordForm(FlaskForm): """ Form to reset one's password in the local database. """ password = wtforms.PasswordField( - "Password", [wtforms.validators.DataRequired()], + "Password", + [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - "Confirm password", [wtforms.validators.DataRequired(), same_password], + "Confirm password", + [wtforms.validators.DataRequired(), same_password], ) @@ -62,10 +64,12 @@ class LoginForm(FlaskForm): """ Form to login via the local database. """ username = wtforms.StringField( - "username", [wtforms.validators.DataRequired()], + "username", + [wtforms.validators.DataRequired()], ) password = wtforms.PasswordField( - "Password", [wtforms.validators.DataRequired()], + "Password", + [wtforms.validators.DataRequired()], ) @@ -73,7 +77,8 @@ class NewUserForm(FlaskForm): """ Form to add a new user to the local database. """ user = wtforms.StringField( - "username", [wtforms.validators.DataRequired()], + "username", + [wtforms.validators.DataRequired()], ) fullname = wtforms.StringField( "Full name", [wtforms.validators.Optional()] @@ -83,10 +88,12 @@ class NewUserForm(FlaskForm): [wtforms.validators.DataRequired(), wtforms.validators.Email()], ) password = wtforms.PasswordField( - "Password", [wtforms.validators.DataRequired()], + "Password", + [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - "Confirm password", [wtforms.validators.DataRequired(), same_password], + "Confirm password", + [wtforms.validators.DataRequired(), same_password], ) @@ -94,11 +101,14 @@ class ChangePasswordForm(FlaskForm): """ Form to reset one's password in the local database. """ old_password = wtforms.PasswordField( - "Old Password", [wtforms.validators.DataRequired()], + "Old Password", + [wtforms.validators.DataRequired()], ) password = wtforms.PasswordField( - "Password", [wtforms.validators.DataRequired()], + "Password", + [wtforms.validators.DataRequired()], ) confirm_password = wtforms.PasswordField( - "Confirm password", [wtforms.validators.DataRequired(), same_password], + "Confirm password", + [wtforms.validators.DataRequired(), same_password], ) diff --git a/pagure/mail_logging.py b/pagure/mail_logging.py index 449fc63..6c7b185 100644 --- a/pagure/mail_logging.py +++ b/pagure/mail_logging.py @@ -64,7 +64,7 @@ def format_callstack(): class ContextInjector(logging.Filter): # pragma: no cover - """ Logging filter that adds context to log records. + """Logging filter that adds context to log records. Filters are typically used to "filter" log records. They declare a filter method that can return True or False. Only records with 'True' will @@ -175,8 +175,7 @@ Callstack that lead to the logging statement def get_mail_handler(smtp_server, mail_admin, from_email): - """ Set up the handler sending emails for big exception - """ + """Set up the handler sending emails for big exception""" mail_handler = logging.handlers.SMTPHandler( smtp_server, from_email, mail_admin, "Pagure error" diff --git a/pagure/perfrepo.py b/pagure/perfrepo.py index 39f1204..2a4c067 100644 --- a/pagure/perfrepo.py +++ b/pagure/perfrepo.py @@ -145,7 +145,7 @@ class FakeDiffer(six.Iterator): # pragma: no cover class PerfRepo( six.with_metaclass(PerfRepoMeta, six.Iterator) ): # pragma: no cover - """ An utility class allowing to go around pygit2's inability to be + """An utility class allowing to go around pygit2's inability to be stable. """ diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py index 8e9a0fe..b265b3f 100644 --- a/pagure/pfmarkdown.py +++ b/pagure/pfmarkdown.py @@ -349,7 +349,7 @@ class AutolinkPattern2(markdown.inlinepatterns.Pattern): """ Return a link Element given an autolink (``). """ def handleMatch(self, m): - """ When the pattern matches, update the text. + """When the pattern matches, update the text. :arg m: the matched object @@ -617,7 +617,7 @@ def _obj_anchor_tag(user, namespace, repo, obj, text): def _get_ns_repo_user(): - """ Return the namespace, repo, user corresponding to the given request + """Return the namespace, repo, user corresponding to the given request :return: A tuple of three string corresponding to namespace, repo, user :rtype: tuple(str, str, str) diff --git a/pagure/ui/__init__.py b/pagure/ui/__init__.py index ee79e27..ab632f3 100644 --- a/pagure/ui/__init__.py +++ b/pagure/ui/__init__.py @@ -49,7 +49,5 @@ def unauthorized(error): # pragma: no cover @UI_NS.route("/api/") @UI_NS.route("/api") def api_redirect(): - """ Redirects the user to the API documentation page. - - """ + """Redirects the user to the API documentation page.""" return flask.redirect(flask.url_for("api_ns.api")) diff --git a/pagure/ui/app.py b/pagure/ui/app.py index cb5495e..8cd2b08 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -40,7 +40,7 @@ _log = logging.getLogger(__name__) def _filter_acls(repos, acl, user): - """ Filter the given list of repositories to return only the ones where + """Filter the given list of repositories to return only the ones where the user has the specified acl. """ if acl.lower() == "main admin": @@ -57,8 +57,7 @@ def _filter_acls(repos, acl, user): @UI_NS.route("/browse/projects/", endpoint="browse_projects") @UI_NS.route("/") def index(): - """ Front page of the application. - """ + """Front page of the application.""" if ( authenticated() and flask.request.path == "/" @@ -152,8 +151,7 @@ def get_userdash_common(user): @UI_NS.route("/dashboard/projects") @login_required def userdash_projects(): - """ User Dashboard page listing projects for the user - """ + """User Dashboard page listing projects for the user""" user = _get_user(username=flask.g.fas_user.username) userdash_counts, search_data = get_userdash_common(user) @@ -257,8 +255,7 @@ def userdash_projects(): @UI_NS.route("/dashboard/activity") @login_required def userdash_activity(): - """ User Dashboard page listing user activity - """ + """User Dashboard page listing user activity""" user = _get_user(username=flask.g.fas_user.username) userdash_counts, search_data = get_userdash_common(user) @@ -281,8 +278,7 @@ def userdash_activity(): @UI_NS.route("/dashboard/groups") @login_required def userdash_groups(): - """ User Dashboard page listing a user's groups - """ + """User Dashboard page listing a user's groups""" user = _get_user(username=flask.g.fas_user.username) userdash_counts, search_data = get_userdash_common(user) @@ -310,8 +306,7 @@ def userdash_groups(): @UI_NS.route("/dashboard/forks") @login_required def userdash_forks(): - """ Forks tab of the user dashboard - """ + """Forks tab of the user dashboard""" user = _get_user(username=flask.g.fas_user.username) userdash_counts, search_data = get_userdash_common(user) @@ -359,8 +354,7 @@ def userdash_forks(): @UI_NS.route("/dashboard/watchlist") @login_required def userdash_watchlist(): - """ User Dashboard page for a user's watchlist - """ + """User Dashboard page for a user's watchlist""" watch_list = pagure.lib.query.user_watch_list( flask.g.session, @@ -383,8 +377,7 @@ def userdash_watchlist(): def index_auth(): - """ Front page for authenticated user. - """ + """Front page for authenticated user.""" user = _get_user(username=flask.g.fas_user.username) acl = flask.request.args.get("acl", "").strip().lower() or None @@ -482,8 +475,7 @@ def index_auth(): @UI_NS.route("/search/") @UI_NS.route("/search") def search(): - """ Search this pagure instance for projects or users. - """ + """Search this pagure instance for projects or users.""" stype = flask.request.args.get("type", "projects") term = flask.request.args.get("term") page = flask.request.args.get("page", 1) @@ -517,8 +509,7 @@ def search(): @UI_NS.route("/users") @UI_NS.route("/users/") def view_users(username=None): - """ Present the list of users. - """ + """Present the list of users.""" page = flask.request.args.get("page", 1) try: page = int(page) @@ -577,8 +568,7 @@ def view_users(username=None): @UI_NS.route("/projects/") @UI_NS.route("/projects//") def view_projects(pattern=None, namespace=None): - """ Present the list of projects. - """ + """Present the list of projects.""" forks = flask.request.args.get("forks") page = flask.request.args.get("page", 1) @@ -678,8 +668,7 @@ def get_userprofile_common(user): @UI_NS.route("/user//") @UI_NS.route("/user/") def view_user(username): - """ Front page of a specific user. - """ + """Front page of a specific user.""" user = _get_user(username=username) # public profile, so never show private repos, @@ -712,8 +701,7 @@ def view_user(username): @UI_NS.route("/user//projects/") @UI_NS.route("/user//projects") def userprofile_projects(username): - """ Public Profile view of a user's projects. - """ + """Public Profile view of a user's projects.""" user = _get_user(username=username) repopage = flask.request.args.get("repopage", 1) @@ -758,8 +746,7 @@ def userprofile_projects(username): @UI_NS.route("/user//forks/") @UI_NS.route("/user//forks") def userprofile_forks(username): - """ Public Profile view of a user's forks. - """ + """Public Profile view of a user's forks.""" user = _get_user(username=username) forkpage = flask.request.args.get("forkpage", 1) @@ -804,8 +791,7 @@ def userprofile_forks(username): @UI_NS.route("/user2//") @UI_NS.route("/user2/") def view_user2(username): - """ Front page of a specific user. - """ + """Front page of a specific user.""" user = _get_user(username=username) acl = flask.request.args.get("acl", "").strip().lower() or None @@ -894,8 +880,7 @@ def view_user2(username): @UI_NS.route("/user//requests/") @UI_NS.route("/user//requests") def view_user_requests(username): - """ Shows the pull-requests for the specified user. - """ + """Shows the pull-requests for the specified user.""" user = _get_user(username=username) pr_type = flask.request.args.get("type", "filed").lower() @@ -1055,8 +1040,7 @@ def userprofile_groups(username): @UI_NS.route("/new", methods=("GET", "POST")) @login_required def new_project(): - """ Form to create a new project. - """ + """Form to create a new project.""" user = pagure.lib.query.search_user( flask.g.session, username=flask.g.fas_user.username @@ -1178,8 +1162,7 @@ def wait_task(taskid): @UI_NS.route("/settings") @login_required def user_settings(): - """ Update the user settings. - """ + """Update the user settings.""" if admin_session_timedout(): return flask.redirect( flask.url_for("auth_login", next=flask.request.url) @@ -1193,8 +1176,7 @@ def user_settings(): @UI_NS.route("/settings/usersettings", methods=["POST"]) @login_required def update_user_settings(): - """ Update the user's settings set in the settings page. - """ + """Update the user's settings set in the settings page.""" if admin_session_timedout(): if flask.request.method == "POST": flask.flash("Action canceled, try it again", "error") @@ -1232,8 +1214,7 @@ def update_user_settings(): @UI_NS.route("/settings/usersettings/addkey", methods=["POST"]) @login_required def add_user_sshkey(): - """ Add the specified SSH key to the user. - """ + """Add the specified SSH key to the user.""" if admin_session_timedout(): if flask.request.method == "POST": flask.flash("Action canceled, try it again", "error") @@ -1289,8 +1270,7 @@ def add_user_sshkey(): @UI_NS.route("/settings/usersettings/removekey/", methods=["POST"]) @login_required def remove_user_sshkey(keyid): - """ Removes an SSH key from the user. - """ + """Removes an SSH key from the user.""" if admin_session_timedout(): if flask.request.method == "POST": flask.flash("Action canceled, try it again", "error") @@ -1342,7 +1322,7 @@ def remove_user_sshkey(keyid): @UI_NS.route("/markdown/", methods=["POST"]) def markdown_preview(): - """ Return the provided markdown text in html. + """Return the provided markdown text in html. The text has to be provided via the parameter 'content' of a POST query. """ @@ -1356,8 +1336,7 @@ def markdown_preview(): @UI_NS.route("/settings/email/drop", methods=["POST"]) @login_required def remove_user_email(): - """ Remove the specified email from the logged in user. - """ + """Remove the specified email from the logged in user.""" if admin_session_timedout(): return flask.redirect( flask.url_for("auth_login", next=flask.request.url) @@ -1401,8 +1380,7 @@ def remove_user_email(): @UI_NS.route("/settings/email/add", methods=["GET", "POST"]) @login_required def add_user_email(): - """ Add a new email for the logged in user. - """ + """Add a new email for the logged in user.""" if admin_session_timedout(): return flask.redirect( flask.url_for("auth_login", next=flask.request.url) @@ -1436,8 +1414,7 @@ def add_user_email(): @UI_NS.route("/settings/email/default", methods=["POST"]) @login_required def set_default_email(): - """ Set the default email address of the user. - """ + """Set the default email address of the user.""" if admin_session_timedout(): return flask.redirect( flask.url_for("auth_login", next=flask.request.url) @@ -1474,8 +1451,7 @@ def set_default_email(): @UI_NS.route("/settings/email/resend", methods=["POST"]) @login_required def reconfirm_email(): - """ Re-send the email address of the user. - """ + """Re-send the email address of the user.""" if admin_session_timedout(): return flask.redirect( flask.url_for("auth_login", next=flask.request.url) @@ -1504,8 +1480,7 @@ def reconfirm_email(): @UI_NS.route("/settings/email/confirm//") @UI_NS.route("/settings/email/confirm/") def confirm_email(token): - """ Confirm a new email. - """ + """Confirm a new email.""" if admin_session_timedout(): return flask.redirect( flask.url_for("auth_login", next=flask.request.url) @@ -1540,7 +1515,7 @@ def confirm_email(token): @UI_NS.route("/ssh_info/") @UI_NS.route("/ssh_info") def ssh_hostkey(): - """ Endpoint returning information about the SSH hostkey and fingerprint + """Endpoint returning information about the SSH hostkey and fingerprint of the current pagure instance. """ return flask.render_template("doc_ssh_keys.html") @@ -1550,8 +1525,7 @@ def ssh_hostkey(): @UI_NS.route("/settings/token/new", methods=("GET", "POST")) @login_required def add_api_user_token(): - """ Create an user token (not project specific). - """ + """Create an user token (not project specific).""" if admin_session_timedout(): if flask.request.method == "POST": flask.flash("Action canceled, try it again", "error") @@ -1602,8 +1576,7 @@ def add_api_user_token(): @UI_NS.route("/settings/token/revoke/", methods=["POST"]) @login_required def revoke_api_user_token(token_id): - """ Revoke a user token (ie: not project specific). - """ + """Revoke a user token (ie: not project specific).""" if admin_session_timedout(): flask.flash("Action canceled, try it again", "error") url = flask.url_for(".user_settings") @@ -1639,8 +1612,7 @@ def revoke_api_user_token(token_id): @UI_NS.route("/settings/token/renew/", methods=["POST"]) @login_required def renew_api_user_token(token_id): - """ Renew a user token (ie: not project specific). - """ + """Renew a user token (ie: not project specific).""" if admin_session_timedout(): flask.flash("Action canceled, try it again", "error") url = flask.url_for(".user_settings") @@ -1684,8 +1656,7 @@ def renew_api_user_token(token_id): @UI_NS.route("/settings/forcelogout", methods=("POST",)) @login_required def force_logout(): - """ Set refuse_sessions_before, logging the user out everywhere - """ + """Set refuse_sessions_before, logging the user out everywhere""" if admin_session_timedout(): flask.flash("Action canceled, try it again", "error") return flask.redirect( @@ -1707,7 +1678,7 @@ def force_logout(): @UI_NS.route("/about") @UI_NS.route("/about/") def help(): - """ A page to direct users to the appropriate places to get assistance, - or find basic instance information. + """A page to direct users to the appropriate places to get assistance, + or find basic instance information. """ return flask.render_template("about.html") diff --git a/pagure/ui/boards.py b/pagure/ui/boards.py index 9f11fae..56ee864 100644 --- a/pagure/ui/boards.py +++ b/pagure/ui/boards.py @@ -45,8 +45,7 @@ _log = logging.getLogger(__name__) @UI_NS.route("/fork////boards/") @has_issue_tracker def view_board(repo, board_name, username=None, namespace=None): - """ View a board - """ + """View a board""" project = flask.g.repo @@ -113,8 +112,7 @@ def view_board(repo, board_name, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def view_board_settings(repo, board_name, username=None, namespace=None): - """ Presents and update the settings of the board - """ + """Presents and update the settings of the board""" project = flask.g.repo if not project.boards: diff --git a/pagure/ui/clone.py b/pagure/ui/clone.py index dd769b5..c086971 100644 --- a/pagure/ui/clone.py +++ b/pagure/ui/clone.py @@ -36,7 +36,7 @@ _auth_log = logging.getLogger("pagure_auth") def _get_remote_user(project): - """ Returns the remote user using either the content of + """Returns the remote user using either the content of ``flask.g.remote_user`` or checking the headers for ``Authorization`` and check if the provided API token is valid. """ @@ -94,7 +94,7 @@ def _get_remote_user(project): def proxy_raw_git(project): - """ Proxy a request to Git or gitolite3 via a subprocess. + """Proxy a request to Git or gitolite3 via a subprocess. This should get called after it is determined the requested project is not on repoSpanner. @@ -227,7 +227,7 @@ def proxy_raw_git(project): def proxy_repospanner(project, service): - """ Proxy a request to repoSpanner. + """Proxy a request to repoSpanner. Args: project (model.Project): The project being accessed @@ -284,7 +284,7 @@ def proxy_repospanner(project, service): def clone_proxy(project, username=None, namespace=None): - """ Proxy the /info/refs endpoint for HTTP pull/push. + """Proxy the /info/refs endpoint for HTTP pull/push. Note that for the clone endpoints, it's very explicit that has been renamed to , to avoid the automatic repo searching from flask_app. @@ -426,7 +426,7 @@ def clone_proxy(project, username=None, namespace=None): def add_clone_proxy_cmds(): - """ This function adds flask routes for all possible clone paths. + """This function adds flask routes for all possible clone paths. This comes down to: /(fork//)(/)(.git) diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 282f523..9011bf7 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -43,7 +43,7 @@ _log = logging.getLogger(__name__) @UI_NS.app_template_filter("hasattr") def jinja_hasattr(obj, string): - """ Template filter checking if the provided object at the provided + """Template filter checking if the provided object at the provided string as attribute """ return hasattr(obj, string) @@ -51,15 +51,13 @@ def jinja_hasattr(obj, string): @UI_NS.app_template_filter("render") def jinja_render(tmpl, **kwargs): - """ Render the given template with the provided arguments - """ + """Render the given template with the provided arguments""" return flask.render_template_string(tmpl, **kwargs) @UI_NS.app_template_filter("humanize") def humanize_date(date): - """ Template filter returning the last commit date of the provided repo. - """ + """Template filter returning the last commit date of the provided repo.""" if date: return arrow.get(date).humanize() @@ -67,7 +65,7 @@ def humanize_date(date): @UI_NS.app_template_filter("format_ts") @UI_NS.app_template_filter("format_datetime") def format_ts(string): - """ Template filter transforming a timestamp, datetime or anything + """Template filter transforming a timestamp, datetime or anything else arrow.get() can handle to a human-readable date """ # We *could* enhance this by allowing users to specify preferred @@ -82,7 +80,7 @@ def format_ts(string): @UI_NS.app_template_filter("humanize_tooltip") def humanize_with_tooltip(date): - """ Template filter returning a human readable time string with an + """Template filter returning a human readable time string with an UTC timestamp tooltip """ if date: @@ -96,8 +94,7 @@ def humanize_with_tooltip(date): @UI_NS.app_template_filter("linkify") def linkify_text(text): - """ escape all html tags with bleach, then use bleach to linkify - """ + """escape all html tags with bleach, then use bleach to linkify""" if text: cleaned = bleach.clean(text, tags=[], attributes=[]) return bleach.linkify(cleaned) @@ -107,9 +104,9 @@ def linkify_text(text): @UI_NS.app_template_filter("syntax_alias") def get_syntax_alias(filename): - """ return an alias based on the filename that is used to - override the automatic syntax highlighting dectection - by highlight.js + """return an alias based on the filename that is used to + override the automatic syntax highlighting dectection + by highlight.js """ override_rules = pagure_config.get( @@ -137,8 +134,7 @@ def format_loc( index=None, isprdiff=False, ): - """ Template filter putting the provided lines of code into a table - """ + """Template filter putting the provided lines of code into a table""" if loc is None: return @@ -408,7 +404,7 @@ def format_loc( @UI_NS.app_template_filter("blame_loc") def blame_loc(loc, repo, username, blame): - """ Template filter putting the provided lines of code into a table + """Template filter putting the provided lines of code into a table This method blame lines of code (loc) takes as input a text (lines of @@ -488,8 +484,7 @@ def blame_loc(loc, repo, username, blame): @UI_NS.app_template_filter("wraps") def text_wraps(text, size=10): - """ Template filter to wrap text at a specified size - """ + """Template filter to wrap text at a specified size""" if text: parts = textwrap.wrap(text, size) if len(parts) > 1: @@ -501,8 +496,7 @@ def text_wraps(text, size=10): @UI_NS.app_template_filter("avatar") def avatar(packager, size=64, css_class=None, src_tag="src"): - """ Template filter that returns html for avatar of any given Username. - """ + """Template filter that returns html for avatar of any given Username.""" if not isinstance(packager, six.text_type): packager = packager.decode("utf-8") @@ -526,8 +520,7 @@ def avatar(packager, size=64, css_class=None, src_tag="src"): @UI_NS.app_template_filter("avatar_url") def avatar_url(email, size=64): - """ Template filter that returns html for avatar of any given Email. - """ + """Template filter that returns html for avatar of any given Email.""" return pagure.lib.query.avatar_url_from_email(email, size) @@ -539,7 +532,7 @@ def shorted_commit(cid): @UI_NS.app_template_filter("markdown") def markdown_filter(text): - """ Template filter converting a string into html content using the + """Template filter converting a string into html content using the markdown library. """ return pagure.lib.query.text2markdown(text) @@ -574,7 +567,7 @@ def patch_to_diff(patch): @UI_NS.app_template_filter("author2user") def author_to_user(author, size=16, cssclass=None, with_name=True): - """ Template filter transforming a pygit2 Author object into a text + """Template filter transforming a pygit2 Author object into a text either with just the username or linking to the user in pagure. """ output = escape(author.name) @@ -609,8 +602,7 @@ def author_to_user(author, size=16, cssclass=None, with_name=True): @UI_NS.app_template_filter("author2avatar") def author_to_avatar(author, size=32): - """ Template filter transforming a pygit2 Author object into an avatar. - """ + """Template filter transforming a pygit2 Author object into an avatar.""" if not author.email: return "" user = pagure.lib.query.search_user(flask.g.session, email=author.email) @@ -620,7 +612,7 @@ def author_to_avatar(author, size=32): @UI_NS.app_template_filter("author2user_commits") def author_to_user_commits(author, link, size=16, cssclass=None): - """ Template filter transforming a pygit2 Author object into a text + """Template filter transforming a pygit2 Author object into a text either with just the username or linking to the user in pagure. """ output = author.name @@ -641,7 +633,7 @@ def author_to_user_commits(author, link, size=16, cssclass=None): @UI_NS.app_template_filter("InsertDiv") def insert_div(content): - """ Template filter inserting an opening
and closing
+ """Template filter inserting an opening
and closing
after the first title and then at the end of the content. """ # This is quite a hack but simpler solution using .replace() didn't work @@ -667,7 +659,7 @@ def insert_div(content): @UI_NS.app_template_filter("noJS") def no_js(content, ignore=None): - """ Template filter replacing by </script> """ return pagure.lib.query.clean_input(content, ignore=ignore) @@ -675,8 +667,7 @@ def no_js(content, ignore=None): @UI_NS.app_template_filter("toRGB") def int_to_rgb(percent): - """ Template filter converting a given percentage to a css RGB value. - """ + """Template filter converting a given percentage to a css RGB value.""" output = "rgb(255, 0, 0);" try: percent = int(percent) @@ -694,8 +685,7 @@ def int_to_rgb(percent): @UI_NS.app_template_filter("increment_largest_priority") def largest_priority(dictionary): - """ Template filter to return the largest priority +1 - """ + """Template filter to return the largest priority +1""" if dictionary: keys = [int(k) for k in dictionary if k] if keys: @@ -705,7 +695,7 @@ def largest_priority(dictionary): @UI_NS.app_template_filter("unicode") def convert_unicode(text): - """ If the provided string is a binary string, this filter converts it + """If the provided string is a binary string, this filter converts it to UTF-8 (unicode). """ if isinstance(text, str) and six.PY2: @@ -716,7 +706,7 @@ def convert_unicode(text): @UI_NS.app_template_filter("combine_url") def combine_url(url, page, pagetitle, **kwargs): - """ Add the specified arguments in the provided kwargs dictionary to + """Add the specified arguments in the provided kwargs dictionary to the given URL. """ url_obj = urlparse(url) @@ -744,7 +734,7 @@ def combine_url(url, page, pagetitle, **kwargs): @UI_NS.app_template_filter("add_or_remove") def add_or_remove(item, items): - """ Adds the item to the list if it is not in there and remove it + """Adds the item to the list if it is not in there and remove it otherwise. """ if item in items: @@ -756,8 +746,7 @@ def add_or_remove(item, items): @UI_NS.app_template_filter("table_sort_arrow") def table_sort_arrow(column, order_key, order): - """ Outputs an arrow icon if the column is currently being sorted on - """ + """Outputs an arrow icon if the column is currently being sorted on""" arrow_html = '' if column == order_key: if order == "desc": @@ -769,8 +758,7 @@ def table_sort_arrow(column, order_key, order): @UI_NS.app_template_filter("table_get_link_order") def table_get_link_order(column, order_key, order): - """ Get the correct order parameter value for the table heading link - """ + """Get the correct order parameter value for the table heading link""" if column == order_key: # If the user is clicking on the column again, they want the # oposite order @@ -785,8 +773,7 @@ def table_get_link_order(column, order_key, order): @UI_NS.app_template_filter("flag2label") def flag_to_label(flag): - """ For a given flag return the bootstrap label to use - """ + """For a given flag return the bootstrap label to use""" return pagure_config["FLAG_STATUSES_LABELS"][flag.status.lower()] @@ -838,7 +825,7 @@ def user_group_can_ssh_commit(username): @UI_NS.app_template_filter("git_url_ssh") def get_git_url_ssh(complement=""): - """ Return the GIT SSH URL to be displayed in the UI based on the + """Return the GIT SSH URL to be displayed in the UI based on the content of the configuration file. """ git_url_ssh = pagure_config.get("GIT_URL_SSH") diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index b11a08d..670b75e 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -49,7 +49,7 @@ _log = logging.getLogger(__name__) def _get_parent_request_repo_path(repo): - """ Return the path of the parent git repository corresponding to the + """Return the path of the parent git repository corresponding to the provided Repository object from the DB. """ if repo.parent: @@ -67,8 +67,7 @@ def _get_parent_request_repo_path(repo): @UI_NS.route("/fork////pull-requests/") @UI_NS.route("/fork////pull-requests") def request_pulls(repo, username=None, namespace=None): - """ List all Pull-requests associated to a repo - """ + """List all Pull-requests associated to a repo""" status = flask.request.args.get("status", "Open") tags = flask.request.args.getlist("tags") tags = [tag.strip() for tag in tags if tag.strip()] @@ -243,8 +242,7 @@ def request_pulls(repo, username=None, namespace=None): "/fork////pull-request/" ) def request_pull(repo, requestid, username=None, namespace=None): - """ View a pull request with the changes from the fork into the project. - """ + """View a pull request with the changes from the fork into the project.""" repo = flask.g.repo _log.info("Viewing pull Request #%s repo: %s", requestid, repo.fullname) @@ -381,8 +379,7 @@ def request_pull(repo, requestid, username=None, namespace=None): "/fork////pull-request/.patch" ) def request_pull_patch(repo, requestid, username=None, namespace=None): - """ Returns the commits from the specified pull-request as patches. - """ + """Returns the commits from the specified pull-request as patches.""" return request_pull_to_diff_or_patch( repo, requestid, username, namespace, diff=False ) @@ -395,8 +392,7 @@ def request_pull_patch(repo, requestid, username=None, namespace=None): "/fork////pull-request/.diff" ) def request_pull_diff(repo, requestid, username=None, namespace=None): - """ Returns the commits from the specified pull-request as patches. - """ + """Returns the commits from the specified pull-request as patches.""" return request_pull_to_diff_or_patch( repo, requestid, username, namespace, diff=True ) @@ -405,7 +401,7 @@ def request_pull_diff(repo, requestid, username=None, namespace=None): def request_pull_to_diff_or_patch( repo, requestid, username=None, namespace=None, diff=False ): - """ Returns the commits from the specified pull-request as patches. + """Returns the commits from the specified pull-request as patches. :arg repo: the `pagure.lib.model.Project` object of the current pagure project browsed @@ -529,8 +525,7 @@ def request_pull_to_diff_or_patch( ) @login_required def request_pull_edit(repo, requestid, username=None, namespace=None): - """ Edit the title of a pull-request. - """ + """Edit the title of a pull-request.""" repo = flask.g.repo @@ -654,8 +649,7 @@ def pull_request_add_comment( username=None, namespace=None, ): - """ Add a comment to a commit in a pull-request. - """ + """Add a comment to a commit in a pull-request.""" repo = flask.g.repo if not repo.settings.get("pull_requests", True): @@ -754,8 +748,7 @@ def pull_request_add_comment( ) @login_required def pull_request_drop_comment(repo, requestid, username=None, namespace=None): - """ Delete a comment of a pull-request. - """ + """Delete a comment of a pull-request.""" repo = flask.g.repo if not repo: @@ -846,8 +839,7 @@ def pull_request_drop_comment(repo, requestid, username=None, namespace=None): def pull_request_edit_comment( repo, requestid, commentid, username=None, namespace=None ): - """Edit comment of a pull request - """ + """Edit comment of a pull request""" is_js = flask.request.args.get("js", False) project = flask.g.repo @@ -942,8 +934,7 @@ def pull_request_edit_comment( ) @login_required def reopen_request_pull(repo, requestid, username=None, namespace=None): - """ Re-Open a pull request. - """ + """Re-Open a pull request.""" form = pagure.forms.ConfirmationForm() if form.validate_on_submit(): @@ -1020,8 +1011,7 @@ def reopen_request_pull(repo, requestid, username=None, namespace=None): ) @login_required def ci_trigger_request_pull(repo, requestid, username=None, namespace=None): - """ Trigger CI testing for a PR. - """ + """Trigger CI testing for a PR.""" form = pagure.forms.TriggerCIPRForm() if not form.validate_on_submit(): flask.flash("Invalid input submitted", "error") @@ -1085,8 +1075,7 @@ def ci_trigger_request_pull(repo, requestid, username=None, namespace=None): ) @login_required def merge_request_pull(repo, requestid, username=None, namespace=None): - """ Create a pull request with the changes from the fork into the project. - """ + """Create a pull request with the changes from the fork into the project.""" form = pagure.forms.MergePRForm() if not form.validate_on_submit(): @@ -1317,8 +1306,7 @@ def merge_request_pull(repo, requestid, username=None, namespace=None): ) @login_required def close_request_pull(repo, requestid, username=None, namespace=None): - """ Close a pull request without merging it. - """ + """Close a pull request without merging it.""" form = pagure.forms.ConfirmationForm() if form.validate_on_submit(): @@ -1386,8 +1374,7 @@ def close_request_pull(repo, requestid, username=None, namespace=None): ) @login_required def refresh_request_pull(repo, requestid, username=None, namespace=None): - """ Refresh a remote pull request. - """ + """Refresh a remote pull request.""" form = pagure.forms.ConfirmationForm() if form.validate_on_submit(): @@ -1549,8 +1536,7 @@ def update_pull_requests(repo, requestid, username=None, namespace=None): @UI_NS.route("/do_fork/fork///", methods=["POST"]) @login_required def fork_project(repo, username=None, namespace=None): - """ Fork the project specified into the user's namespace - """ + """Fork the project specified into the user's namespace""" repo = flask.g.repo form = pagure.forms.ConfirmationForm() @@ -1641,8 +1627,7 @@ def fork_project(repo, username=None, namespace=None): def new_request_pull( repo, branch_to, branch_from, username=None, namespace=None ): - """ Create a pull request with the changes from the fork into the project. - """ + """Create a pull request with the changes from the fork into the project.""" branch_to = flask.request.values.get("branch_to", branch_to) project_to = flask.request.values.get("project_to") @@ -1853,8 +1838,8 @@ def new_request_pull( ) @login_required def new_remote_request_pull(repo, username=None, namespace=None): - """ Create a pull request with the changes from a remote fork into the - project. + """Create a pull request with the changes from a remote fork into the + project. """ confirm = flask.request.values.get("confirm", False) @@ -2068,8 +2053,7 @@ def new_remote_request_pull(repo, username=None, namespace=None): ) @login_required def fork_edit_file(repo, branchname, filename, username=None, namespace=None): - """ Fork the project specified and open the specific file to edit - """ + """Fork the project specified and open the specific file to edit""" repo = flask.g.repo form = pagure.forms.ConfirmationForm() diff --git a/pagure/ui/groups.py b/pagure/ui/groups.py index b070e2e..b258de9 100644 --- a/pagure/ui/groups.py +++ b/pagure/ui/groups.py @@ -259,8 +259,7 @@ def give_group(group): @UI_NS.route("/group///delete", methods=["POST"]) @login_required def group_user_delete(user, group): - """ Delete an user from a certain group - """ + """Delete an user from a certain group""" if not pagure_config.get("ENABLE_USER_MNGT", True): flask.abort(404) @@ -307,8 +306,7 @@ def group_user_delete(user, group): @UI_NS.route("/group//delete", methods=["POST"]) @login_required def group_delete(group): - """ Delete a certain group - """ + """Delete a certain group""" if not pagure_config.get("ENABLE_USER_MNGT", True): flask.abort(404) @@ -350,8 +348,7 @@ def group_delete(group): @UI_NS.route("/group/add", methods=["GET", "POST"]) @login_required def add_group(): - """ Endpoint to create groups - """ + """Endpoint to create groups""" if not pagure_config.get("ENABLE_USER_MNGT", True): flask.abort(404) diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index 4682f34..cc7ece9 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -515,8 +515,7 @@ def issue_comment_add_reaction( @UI_NS.route("/fork////issues") @has_issue_tracker def view_issues(repo, username=None, namespace=None): - """ List all issues associated to a repo - """ + """List all issues associated to a repo""" status = flask.request.args.get("status", "Open") status = flask.request.args.get("close_status") or status @@ -747,8 +746,7 @@ def view_issues(repo, username=None, namespace=None): @UI_NS.route("/fork////roadmap") @has_issue_tracker def view_roadmap(repo, username=None, namespace=None): - """ List all issues associated to a repo as roadmap - """ + """List all issues associated to a repo as roadmap""" milestones_status_arg = flask.request.args.get("status", "active") milestones_keyword_arg = flask.request.args.get("keyword", None) milestones_onlyincomplete_arg = flask.request.args.get( @@ -849,8 +847,7 @@ def view_roadmap(repo, username=None, namespace=None): @UI_NS.route("/fork////roadmap/") @has_issue_tracker def view_milestone(repo, username=None, namespace=None, milestone=None): - """ List all issues associated to a repo as roadmap - """ + """List all issues associated to a repo as roadmap""" repo = flask.g.repo @@ -908,8 +905,7 @@ def view_milestone(repo, username=None, namespace=None, milestone=None): @login_required @has_issue_tracker def new_issue(repo, username=None, namespace=None): - """ Create a new issue - """ + """Create a new issue""" template = flask.request.args.get("template") or "default" repo = flask.g.repo open_access = repo.settings.get("open_metadata_access_to_all", False) @@ -1112,8 +1108,7 @@ def new_issue(repo, username=None, namespace=None): @UI_NS.route("/fork////issue/") @has_issue_tracker def view_issue(repo, issueid, username=None, namespace=None): - """ List all issues associated to a repo - """ + """List all issues associated to a repo""" repo = flask.g.repo @@ -1189,8 +1184,7 @@ def view_issue(repo, issueid, username=None, namespace=None): ) @has_issue_tracker def delete_issue(repo, issueid, username=None, namespace=None): - """ Delete the specified issue - """ + """Delete the specified issue""" repo = flask.g.repo @@ -1266,8 +1260,7 @@ def delete_issue(repo, issueid, username=None, namespace=None): @login_required @has_issue_tracker def edit_issue(repo, issueid, username=None, namespace=None): - """ Edit the specified issue - """ + """Edit the specified issue""" repo = flask.g.repo issue = pagure.lib.query.search_issues( @@ -1403,8 +1396,7 @@ def edit_issue(repo, issueid, username=None, namespace=None): @login_required @has_issue_tracker def upload_issue(repo, issueid, username=None, namespace=None): - """ Upload a file to a ticket. - """ + """Upload a file to a ticket.""" repo = flask.g.repo issue = pagure.lib.query.search_issues( @@ -1468,7 +1460,7 @@ def upload_issue(repo, issueid, username=None, namespace=None): @UI_NS.route("/fork////issue/raw/") @has_issue_tracker def view_issue_raw_file(repo, filename=None, username=None, namespace=None): - """ Displays the raw content of a file of a commit for the specified + """Displays the raw content of a file of a commit for the specified ticket repo. """ raw = is_true(flask.request.args.get("raw")) @@ -1560,8 +1552,7 @@ def view_issue_raw_file(repo, filename=None, username=None, namespace=None): def edit_comment_issue( repo, issueid, commentid, username=None, namespace=None ): - """Edit comment of an issue - """ + """Edit comment of an issue""" is_js = flask.request.args.get("js", False) project = flask.g.repo @@ -1648,8 +1639,7 @@ def edit_comment_issue( @login_required @is_repo_admin def save_reports(repo, username=None, namespace=None): - """ Marked for watching or Unwatching - """ + """Marked for watching or Unwatching""" return_point = flask.url_for( "ui_ns.view_issues", repo=repo, username=username, namespace=namespace @@ -1684,8 +1674,7 @@ def save_reports(repo, username=None, namespace=None): @UI_NS.route("/fork///report/") @UI_NS.route("/fork////report/") def view_report(repo, report, username=None, namespace=None): - """ Show the specified report. - """ + """Show the specified report.""" reports = flask.g.repo.reports if report not in reports: flask.abort(404, description="No such report found") diff --git a/pagure/ui/login.py b/pagure/ui/login.py index 7da94a3..ef78bbd 100644 --- a/pagure/ui/login.py +++ b/pagure/ui/login.py @@ -36,8 +36,7 @@ _log = logging.getLogger(__name__) @UI_NS.route("/user/new/", methods=["GET", "POST"]) @UI_NS.route("/user/new", methods=["GET", "POST"]) def new_user(): - """ Create a new user. - """ + """Create a new user.""" if not pagure.config.config.get("ALLOW_USER_REGISTRATION", True): flask.flash("User registration is disabled.", "error") return flask.redirect(flask.url_for("auth_login")) @@ -90,8 +89,7 @@ def new_user(): @UI_NS.route("/dologin", methods=["POST"]) def do_login(): - """ Log in the user. - """ + """Log in the user.""" logout() form = forms.LoginForm() @@ -146,8 +144,7 @@ def do_login(): @UI_NS.route("/confirm//") @UI_NS.route("/confirm/") def confirm_user(token): - """ Confirm a user account. - """ + """Confirm a user account.""" user_obj = pagure.lib.query.search_user(flask.g.session, token=token) if not user_obj: flask.flash("No user associated with this token.", "error") @@ -173,7 +170,7 @@ def confirm_user(token): @UI_NS.route("/password/lost/", methods=["GET", "POST"]) @UI_NS.route("/password/lost", methods=["GET", "POST"]) def lost_password(): - """ Method to allow a user to change his/her password assuming the email + """Method to allow a user to change his/her password assuming the email is not compromised. """ form = forms.LostPasswordForm() @@ -224,8 +221,7 @@ def lost_password(): @UI_NS.route("/password/reset//", methods=["GET", "POST"]) @UI_NS.route("/password/reset/", methods=["GET", "POST"]) def reset_password(token): - """ Method to allow a user to reset his/her password. - """ + """Method to allow a user to reset his/her password.""" form = forms.ResetPasswordForm() user_obj = pagure.lib.query.search_user(flask.g.session, token=token) @@ -270,8 +266,7 @@ def reset_password(token): @UI_NS.route("/password/change", methods=["GET", "POST"]) @login_required def change_password(): - """ Method to change the password for local auth users. - """ + """Method to change the password for local auth users.""" form = forms.ChangePasswordForm() user_obj = pagure.lib.query.search_user( @@ -324,7 +319,7 @@ def change_password(): def send_confirmation_email(user): - """ Sends the confirmation email asking the user to confirm its email + """Sends the confirmation email asking the user to confirm its email address. """ if not user.emails: @@ -335,7 +330,8 @@ def send_confirmation_email(user): # A link with a secret token to confirm the registration confirmation_url = urljoin( - instance_url, flask.url_for("ui_ns.confirm_user", token=user.token), + instance_url, + flask.url_for("ui_ns.confirm_user", token=user.token), ) message = """Dear %(username)s, @@ -367,7 +363,7 @@ Your pagure admin. def send_lostpassword_email(user): - """ Sends the email with the information on how to reset his/her password + """Sends the email with the information on how to reset his/her password to the user. """ if not user.emails: @@ -408,15 +404,13 @@ Your pagure admin. def logout(): - """ Log the user out by expiring the user's session. - """ + """Log the user out by expiring the user's session.""" flask.g.fas_session_id = None flask.g.fas_user = None def _check_session_cookie(): - """ Set the user into flask.g if the user is logged in. - """ + """Set the user into flask.g if the user is logged in.""" if not hasattr(flask.g, "session") or not flask.g.session: flask.g.session = pagure.lib.model_base.create_session( flask.current_app.config["DB_URL"] diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py index 5238051..6eee55a 100644 --- a/pagure/ui/plugins.py +++ b/pagure/ui/plugins.py @@ -78,8 +78,7 @@ _log = logging.getLogger(__name__) @login_required @is_repo_admin def view_plugin(repo, plugin, username=None, namespace=None, full=True): - """ Presents the settings of the project. - """ + """Presents the settings of the project.""" repo = flask.g.repo # Private repos are not allowed to leak information outside so disabling CI diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index d661578..c0ff069 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -68,7 +68,7 @@ _log = logging.getLogger(__name__) def get_preferred_readme(tree): - """ Establish some order about which README gets displayed + """Establish some order about which README gets displayed if there are several in the repository. If none of the listed README files is availabe, display either the next file that starts with 'README' or nothing at all. @@ -90,7 +90,7 @@ def get_preferred_readme(tree): @UI_NS.route("/fork//.git") @UI_NS.route("/fork///.git") def view_repo_git(repo, username=None, namespace=None): - """ Redirect to the project index page when user wants to view + """Redirect to the project index page when user wants to view the git repo of the project """ return flask.redirect( @@ -112,8 +112,7 @@ def view_repo_git(repo, username=None, namespace=None): @UI_NS.route("/fork////") @UI_NS.route("/fork///") def view_repo(repo, username=None, namespace=None): - """ Front page of a specific repo. - """ + """Front page of a specific repo.""" repo_db = flask.g.repo repo_obj = flask.g.repo_obj @@ -297,8 +296,7 @@ def view_repo_branch(repo, branchname, username=None, namespace=None): @UI_NS.route("/fork////commits") @UI_NS.route("/fork////commits/") def view_commits(repo, branchname=None, username=None, namespace=None): - """ Displays the commits of the specified repo. - """ + """Displays the commits of the specified repo.""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -442,8 +440,7 @@ def view_commits(repo, branchname=None, username=None, namespace=None): @UI_NS.route("/fork////c/../") @UI_NS.route("/fork////c/..") def compare_commits(repo, commit1, commit2, username=None, namespace=None): - """ Compares two commits for specified repo - """ + """Compares two commits for specified repo""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -513,8 +510,7 @@ def compare_commits(repo, commit1, commit2, username=None, namespace=None): "" ) def view_file(repo, identifier, filename, username=None, namespace=None): - """ Displays the content of a file or a tree for the specified repo. - """ + """Displays the content of a file or a tree for the specified repo.""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -685,8 +681,7 @@ def view_file(repo, identifier, filename, username=None, namespace=None): def view_raw_file( repo, identifier, filename=None, username=None, namespace=None ): - """ Displays the raw content of a file of a commit for the specified repo. - """ + """Displays the raw content of a file of a commit for the specified repo.""" repo_obj = flask.g.repo_obj if repo_obj.is_empty: @@ -743,8 +738,7 @@ def view_raw_file( @UI_NS.route("/fork///blame/") @UI_NS.route("/fork////blame/") def view_blame_file(repo, filename, username=None, namespace=None): - """ Displays the blame of a file or a tree for the specified repo. - """ + """Displays the blame of a file or a tree for the specified repo.""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -826,8 +820,7 @@ def view_blame_file(repo, filename, username=None, namespace=None): @UI_NS.route("/fork///history/") @UI_NS.route("/fork////history/") def view_history_file(repo, filename, username=None, namespace=None): - """ Displays the history of a file or a tree for the specified repo. - """ + """Displays the history of a file or a tree for the specified repo.""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -880,8 +873,7 @@ def view_history_file(repo, filename, username=None, namespace=None): @UI_NS.route("/fork////c//") @UI_NS.route("/fork////c/") def view_commit(repo, commitid, username=None, namespace=None): - """ Render a commit in a repo - """ + """Render a commit in a repo""" repo = flask.g.repo if not repo: flask.abort(404, description="Project not found") @@ -953,8 +945,7 @@ def view_commit(repo, commitid, username=None, namespace=None): @UI_NS.route("/fork///c/.patch") @UI_NS.route("/fork////c/.patch") def view_commit_patch(repo, commitid, username=None, namespace=None): - """ Render a commit in a repo as patch - """ + """Render a commit in a repo as patch""" return view_commit_patch_or_diff( repo, commitid, username, namespace, diff=False ) @@ -965,8 +956,7 @@ def view_commit_patch(repo, commitid, username=None, namespace=None): @UI_NS.route("/fork///c/.diff") @UI_NS.route("/fork////c/.diff") def view_commit_diff(repo, commitid, username=None, namespace=None): - """ Render a commit in a repo as diff - """ + """Render a commit in a repo as diff""" is_js = is_true(flask.request.args.get("js")) @@ -1032,8 +1022,7 @@ def view_commit_patch_or_diff( @UI_NS.route("/fork///tree/") @UI_NS.route("/fork////tree/") def view_tree(repo, identifier=None, username=None, namespace=None): - """ Render the tree of the repo - """ + """Render the tree of the repo""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -1111,8 +1100,7 @@ def view_tree(repo, identifier=None, username=None, namespace=None): @UI_NS.route("/fork////releases/") @UI_NS.route("/fork////releases") def view_tags(repo, username=None, namespace=None): - """ Presents all the tags of the project. - """ + """Presents all the tags of the project.""" repo = flask.g.repo tags = pagure.lib.git.get_git_tags_objects(repo) @@ -1140,8 +1128,7 @@ def view_tags(repo, username=None, namespace=None): @UI_NS.route("/fork////branches/") @UI_NS.route("/fork////branches") def view_branches(repo, username=None, namespace=None): - """ Branches - """ + """Branches""" repo_db = flask.g.repo repo_obj = flask.g.repo_obj @@ -1175,8 +1162,7 @@ def view_branches(repo, username=None, namespace=None): @UI_NS.route("/fork////forks/") @UI_NS.route("/fork////forks") def view_forks(repo, username=None, namespace=None): - """ Forks - """ + """Forks""" return flask.render_template( "repo_forks.html", select="forks", username=username, repo=flask.g.repo @@ -1198,8 +1184,7 @@ def view_forks(repo, username=None, namespace=None): @login_required @is_repo_admin def new_release(repo, username=None, namespace=None): - """ Upload a new release. - """ + """Upload a new release.""" if not pagure_config.get("UPLOAD_FOLDER_PATH") or not pagure_config.get( "UPLOAD_FOLDER_URL" ): @@ -1281,8 +1266,7 @@ def new_release(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def view_settings(repo, username=None, namespace=None): - """ Presents the settings of the project. - """ + """Presents the settings of the project.""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -1376,7 +1360,7 @@ def view_settings(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def test_web_hook(repo, username=None, namespace=None): - """ Endpoint that can be called to send a test message to the web-hook + """Endpoint that can be called to send a test message to the web-hook service allowing to test the web-hooks set. """ @@ -1412,8 +1396,7 @@ def test_web_hook(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def update_project(repo, username=None, namespace=None): - """ Update the description of a project. - """ + """Update the description of a project.""" repo = flask.g.repo @@ -1471,8 +1454,7 @@ def update_project(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def update_priorities(repo, username=None, namespace=None): - """ Update the priorities of a project. - """ + """Update the priorities of a project.""" repo = flask.g.repo @@ -1570,8 +1552,7 @@ def update_priorities(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def default_priority(repo, username=None, namespace=None): - """ Update the default priority of a project. - """ + """Update the default priority of a project.""" repo = flask.g.repo @@ -1616,8 +1597,7 @@ def default_priority(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def update_milestones(repo, username=None, namespace=None): - """ Update the milestones of a project. - """ + """Update the milestones of a project.""" repo = flask.g.repo @@ -1702,8 +1682,7 @@ def update_milestones(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def change_ref_head(repo, username=None, namespace=None): - """ Change HEAD reference - """ + """Change HEAD reference""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -1738,8 +1717,7 @@ def change_ref_head(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def delete_repo(repo, username=None, namespace=None): - """ Delete the present project. - """ + """Delete the present project.""" repo = flask.g.repo del_project = pagure_config.get("ENABLE_DEL_PROJECTS", True) @@ -1784,8 +1762,7 @@ def delete_repo(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def new_repo_hook_token(repo, username=None, namespace=None): - """ Re-generate a hook token for the present project. - """ + """Re-generate a hook token for the present project.""" if not pagure_config.get("WEBHOOK", False): flask.abort(404) @@ -1828,8 +1805,7 @@ def new_repo_hook_token(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def remove_deploykey(repo, keyid, username=None, namespace=None): - """ Remove the specified deploy key from the project. - """ + """Remove the specified deploy key from the project.""" if not pagure_config.get("DEPLOY_KEY", True): flask.abort( @@ -1903,8 +1879,7 @@ def remove_deploykey(repo, keyid, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def remove_user(repo, userid, username=None, namespace=None): - """ Remove the specified user from the project. - """ + """Remove the specified user from the project.""" if not pagure_config.get("ENABLE_USER_MNGT", True): flask.abort( @@ -1972,8 +1947,7 @@ def remove_user(repo, userid, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def add_deploykey(repo, username=None, namespace=None): - """ Add the specified deploy key to the project. - """ + """Add the specified deploy key to the project.""" if not pagure_config.get("DEPLOY_KEY", True): flask.abort( @@ -2049,8 +2023,7 @@ def add_deploykey(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def add_user(repo, username=None, namespace=None): - """ Add the specified user to the project. - """ + """Add the specified user to the project.""" if not pagure_config.get("ENABLE_USER_MNGT", True): flask.abort( @@ -2136,8 +2109,7 @@ def add_user(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def remove_group_project(repo, groupid, username=None, namespace=None): - """ Remove the specified group from the project. - """ + """Remove the specified group from the project.""" if not pagure_config.get("ENABLE_USER_MNGT", True): flask.abort( @@ -2223,8 +2195,7 @@ def remove_group_project(repo, groupid, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def add_group_project(repo, username=None, namespace=None): - """ Add the specified group to the project. - """ + """Add the specified group to the project.""" if not pagure_config.get("ENABLE_USER_MNGT", True): flask.abort( @@ -2308,8 +2279,7 @@ def add_group_project(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def regenerate_git(repo, username=None, namespace=None): - """ Regenerate the specified git repo with the content in the project. - """ + """Regenerate the specified git repo with the content in the project.""" repo = flask.g.repo @@ -2378,8 +2348,7 @@ def regenerate_git(repo, username=None, namespace=None): @login_required @is_admin_sess_timedout def add_token(repo, username=None, namespace=None): - """ Add a token to a specified project. - """ + """Add a token to a specified project.""" repo = flask.g.repo @@ -2448,8 +2417,7 @@ def add_token(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def renew_api_token(repo, token_id, username=None, namespace=None): - """ Renew a token to a specified project. - """ + """Renew a token to a specified project.""" repo = flask.g.repo @@ -2518,8 +2486,7 @@ def renew_api_token(repo, token_id, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def revoke_api_token(repo, token_id, username=None, namespace=None): - """ Revokie a token to a specified project. - """ + """Revokie a token to a specified project.""" repo = flask.g.repo @@ -2579,8 +2546,7 @@ def revoke_api_token(repo, token_id, username=None, namespace=None): ) @login_required def edit_file(repo, branchname, filename, username=None, namespace=None): - """ Edit a file online. - """ + """Edit a file online.""" repo = flask.g.repo repo_obj = flask.g.repo_obj @@ -2688,8 +2654,7 @@ def edit_file(repo, branchname, filename, username=None, namespace=None): ) @login_required def delete_branch(repo, branchname, username=None, namespace=None): - """ Delete the branch of a project. - """ + """Delete the branch of a project.""" if not flask.g.repo.is_fork and not pagure_config.get( "ALLOW_DELETE_BRANCH", True ): @@ -2739,8 +2704,7 @@ def delete_branch(repo, branchname, username=None, namespace=None): @UI_NS.route("/docs/fork///") @UI_NS.route("/docs/fork////") def view_docs(repo, username=None, filename=None, namespace=None): - """ Display the documentation - """ + """Display the documentation""" repo = flask.g.repo if not pagure_config.get("DOC_APP_URL"): @@ -2761,8 +2725,7 @@ def view_docs(repo, username=None, filename=None, namespace=None): @UI_NS.route("///activity/") @UI_NS.route("///activity") def view_project_activity(repo, namespace=None): - """ Display the activity feed - """ + """Display the activity feed""" if not pagure_config.get("DATAGREPPER_URL"): flask.abort(404) @@ -2798,7 +2761,7 @@ def view_stargazers(repo, username=None, namespace=None): ) @login_required def star_project(repo, star, username=None, namespace=None): - """ Star or Unstar a project + """Star or Unstar a project :arg repo: string representing the project which has to be starred or unstarred. @@ -2847,8 +2810,7 @@ def star_project(repo, star, username=None, namespace=None): ) @login_required def watch_repo(repo, watch, username=None, namespace=None): - """ Marked for watching or unwatching - """ + """Marked for watching or unwatching""" return_point = flask.url_for("ui_ns.index") if pagure.utils.is_safe_url(flask.request.referrer): @@ -2884,8 +2846,7 @@ def watch_repo(repo, watch, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def update_public_notifications(repo, username=None, namespace=None): - """ Update the public notification settings of a project. - """ + """Update the public notification settings of a project.""" repo = flask.g.repo @@ -2938,8 +2899,7 @@ def update_public_notifications(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def update_close_status(repo, username=None, namespace=None): - """ Update the close_status of a project. - """ + """Update the close_status of a project.""" repo = flask.g.repo @@ -2984,8 +2944,7 @@ def update_close_status(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def update_quick_replies(repo, username=None, namespace=None): - """ Update the quick_replies of a project. - """ + """Update the quick_replies of a project.""" repo = flask.g.repo @@ -3033,8 +2992,7 @@ def update_quick_replies(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def update_custom_keys(repo, username=None, namespace=None): - """ Update the custom_keys of a project. - """ + """Update the custom_keys of a project.""" repo = flask.g.repo @@ -3098,8 +3056,7 @@ def update_custom_keys(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def delete_report(repo, username=None, namespace=None): - """ Delete a report from a project. - """ + """Delete a report from a project.""" repo = flask.g.repo @@ -3142,8 +3099,7 @@ def delete_report(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def move_to_repospanner(repo, username=None, namespace=None): - """ Give a project to someone else. - """ + """Give a project to someone else.""" repo = flask.g.repo if not pagure.utils.is_admin(): @@ -3206,8 +3162,7 @@ def move_to_repospanner(repo, username=None, namespace=None): @is_admin_sess_timedout @is_repo_admin def give_project(repo, username=None, namespace=None): - """ Give a project to someone else. - """ + """Give a project to someone else.""" if not pagure_config.get("ENABLE_GIVE_PROJECTS", True): flask.abort(404) @@ -3306,7 +3261,7 @@ def give_project(repo, username=None, namespace=None): @UI_NS.route("/fork////dowait/") @UI_NS.route("/fork////dowait") def project_dowait(repo, username=None, namespace=None): - """ Schedules a task that just waits 10 seconds for testing locking. + """Schedules a task that just waits 10 seconds for testing locking. This is not available unless ALLOW_PROJECT_DOWAIT is set to True, which should only ever be done in test instances. @@ -3330,8 +3285,7 @@ def project_dowait(repo, username=None, namespace=None): @UI_NS.route("/fork////stats/") @UI_NS.route("/fork////stats") def view_stats(repo, username=None, namespace=None): - """ Displays some statistics about the specified repo. - """ + """Displays some statistics about the specified repo.""" return flask.render_template( "repo_stats.html", select="stats", username=username, repo=flask.g.repo ) @@ -3343,8 +3297,7 @@ def view_stats(repo, username=None, namespace=None): @is_repo_admin @has_issue_or_pr_enabled def update_tags(repo, username=None, namespace=None): - """ Update the tags of a project. - """ + """Update the tags of a project.""" repo = flask.g.repo @@ -3448,8 +3401,7 @@ def update_tags(repo, username=None, namespace=None): @is_repo_admin @has_issue_or_pr_enabled def remove_tag(repo, username=None, namespace=None): - """ Remove the specified tag, associated with the issues, from the project. - """ + """Remove the specified tag, associated with the issues, from the project.""" repo = flask.g.repo form = pagure.forms.DeleteIssueTagForm() @@ -3501,8 +3453,7 @@ def remove_tag(repo, username=None, namespace=None): @is_repo_admin @has_issue_or_pr_enabled def edit_tag(repo, tag, username=None, namespace=None): - """ Edit the specified tag associated with the issues of a project. - """ + """Edit the specified tag associated with the issues of a project.""" repo = flask.g.repo tags = pagure.lib.query.get_tags_of_project(flask.g.session, repo) @@ -3567,8 +3518,7 @@ def edit_tag(repo, tag, username=None, namespace=None): @UI_NS.route("/fork///archive//.tar") @UI_NS.route("/fork////archive//.tar") def get_project_archive_tar(repo, ref, name, namespace=None, username=None): - """ Generate an archive or redirect the user to where it already exists - """ + """Generate an archive or redirect the user to where it already exists""" return generate_project_archive( repo, @@ -3585,8 +3535,7 @@ def get_project_archive_tar(repo, ref, name, namespace=None, username=None): @UI_NS.route("/fork///archive//.tar.gz") @UI_NS.route("/fork////archive//.tar.gz") def get_project_archive_tar_gz(repo, ref, name, namespace=None, username=None): - """ Generate an archive or redirect the user to where it already exists - """ + """Generate an archive or redirect the user to where it already exists""" return generate_project_archive( repo, ref, @@ -3602,8 +3551,7 @@ def get_project_archive_tar_gz(repo, ref, name, namespace=None, username=None): @UI_NS.route("/fork///archive//.zip") @UI_NS.route("/fork////archive//.zip") def get_project_archive_zip(repo, ref, name, namespace=None, username=None): - """ Generate an archive or redirect the user to where it already exists - """ + """Generate an archive or redirect the user to where it already exists""" return generate_project_archive( repo, ref, @@ -3617,7 +3565,7 @@ def get_project_archive_zip(repo, ref, name, namespace=None, username=None): def generate_project_archive( repo, ref, name, extension, namespace=None, username=None ): - """ Generate an archive or redirect the user to where it already + """Generate an archive or redirect the user to where it already exists. """ diff --git a/pagure/utils.py b/pagure/utils.py index 915ba49..8564179 100644 --- a/pagure/utils.py +++ b/pagure/utils.py @@ -49,8 +49,7 @@ def set_up_logging(app=None, force=False, configkey="LOGGING"): def authenticated(): - """ Utility function checking if the current user is logged in or not. - """ + """Utility function checking if the current user is logged in or not.""" fas_user = None try: fas_user = flask.g.fas_user @@ -61,7 +60,7 @@ def authenticated(): def api_authenticated(): - """ Utility function checking if the current user is logged in or not + """Utility function checking if the current user is logged in or not in the API. """ return ( @@ -73,7 +72,7 @@ def api_authenticated(): def check_api_acls(acls, optional=False): - """ Checks if the user provided an API token with its request and if + """Checks if the user provided an API token with its request and if this token allows the user to access the endpoint desired. :arg acls: A list of access control @@ -155,7 +154,7 @@ def check_api_acls(acls, optional=False): def is_safe_url(target): # pragma: no cover - """ Checks that the target url is safe and sending to the current + """Checks that the target url is safe and sending to the current website not some other malicious one. """ ref_url = urlparse(flask.request.host_url) @@ -271,8 +270,8 @@ def is_repo_committer(repo_obj, username=None, session=None): def is_repo_collaborator(repo_obj, refname, username=None, session=None): - """ Return whether the user has commit on the specified branch of the - provided repo. """ + """Return whether the user has commit on the specified branch of the + provided repo.""" committer = is_repo_committer(repo_obj, username=username, session=session) if committer: _log.debug("User is a committer") @@ -349,8 +348,8 @@ def is_repo_user(repo_obj, username=None): def get_user_repo_access(repo_obj, username): - """ return a string of the highest level of access - a user has on a repo. + """return a string of the highest level of access + a user has on a repo. """ if repo_obj.user.username == username: return "main admin" @@ -368,7 +367,7 @@ def get_user_repo_access(repo_obj, username): def login_required(function): - """ Flask decorator to retrict access to logged in user. + """Flask decorator to retrict access to logged in user. If the auth system is ``fas`` it will also require that the user sign the FPCA. """ @@ -400,7 +399,7 @@ def login_required(function): def __get_file_in_tree(repo_obj, tree, filepath, bail_on_tree=False): - """ Retrieve the entry corresponding to the provided filename in a + """Retrieve the entry corresponding to the provided filename in a given tree. """ @@ -643,7 +642,7 @@ ssh_urlpattern = re.compile(ssh_urlregex) def get_repo_path(repo): - """ Return the path of the git repository corresponding to the provided + """Return the path of the git repository corresponding to the provided Repository object from the DB. """ repopath = repo.repopath("main") @@ -654,7 +653,7 @@ def get_repo_path(repo): def get_remote_repo_path(remote_git, branch_from, ignore_non_exist=False): - """ Return the path of the remote git repository corresponding to the + """Return the path of the remote git repository corresponding to the provided information. """ repopath = os.path.join( @@ -725,7 +724,7 @@ def split_project_fullname(project_name): def get_parent_repo_path(repo, repotype="main"): - """ Return the path of the parent git repository corresponding to the + """Return the path of the parent git repository corresponding to the provided Repository object from the DB. """ if repo.parent: @@ -754,7 +753,7 @@ def is_true(value, trueish=("1", "true", "t", "y")): def validate_date(input_date, allow_empty=False): - """ Validate a given time. + """Validate a given time. The time can either be given as an unix timestamp or using the yyyy-mm-dd format. If either fail to parse, we raise a 400 error @@ -779,7 +778,7 @@ def validate_date(input_date, allow_empty=False): def validate_date_range(value): - """ Validate a given date range specified using the format since..until. + """Validate a given date range specified using the format since..until. If .. is not present in the range, it is assumed that only since was provided. """ @@ -837,7 +836,7 @@ def get_merge_options(request, merge_status): def lookup_deploykey(project, username): - """ Finds the Deploy Key specified by the username. + """Finds the Deploy Key specified by the username. Args: project (model.Project): The project to look in @@ -862,7 +861,7 @@ def lookup_deploykey(project, username): def project_has_hook_attr_value(project, hook, attr, value): - """ Finds out if project's hook has attribute of given value. + """Finds out if project's hook has attribute of given value. :arg project: The project to inspect :type project: pagure.lib.model.Project diff --git a/requirements-testing.txt b/requirements-testing.txt index 00005ee..6232f7c 100644 --- a/requirements-testing.txt +++ b/requirements-testing.txt @@ -1,6 +1,6 @@ bcrypt beautifulsoup4 -black == 19.10b0; python_version >= '3.6' # Only available on py3.6+ +black cryptography eventlet fedmsg diff --git a/tests/test_dev_data.py b/tests/test_dev_data.py index 85d7e40..6aeab47 100644 --- a/tests/test_dev_data.py +++ b/tests/test_dev_data.py @@ -30,9 +30,7 @@ class TestDevData(tests.Modeltests): maxDiff = None def test_dev_data_all(self): - """Check how dev-data --all performs - - """ + """Check how dev-data --all performs""" config_path = os.path.join(self.path, "config") with open(config_path, "w") as f: @@ -81,9 +79,7 @@ WARNING: Deleting all data from sqlite:///%s/db_dev_data.sqlite self.assertEqual(stdout, output) def test_dev_data_delete(self): - """Check how dev-data --init --delete performs - - """ + """Check how dev-data --init --delete performs""" config_path = os.path.join(self.path, "config") @@ -114,9 +110,7 @@ WARNING: Deleting all data from %s self.assertEqual(stdout.split("\n"), output.split("\n")) def test_dev_data_init(self): - """Check how dev-data --init performs - - """ + """Check how dev-data --init performs""" config_path = os.path.join(self.path, "config") diff --git a/tests/test_pagure_admin.py b/tests/test_pagure_admin.py index daceef3..d0f5ae7 100644 --- a/tests/test_pagure_admin.py +++ b/tests/test_pagure_admin.py @@ -35,8 +35,7 @@ import tests # noqa class PagureAdminAdminTokenEmptytests(tests.Modeltests): - """ Tests for pagure-admin admin-token when there is nothing in the DB - """ + """Tests for pagure-admin admin-token when there is nothing in the DB""" populate_db = False @@ -46,7 +45,7 @@ class PagureAdminAdminTokenEmptytests(tests.Modeltests): pagure.cli.admin.session = self.session def test_do_create_admin_token_no_user(self): - """ Test the do_create_admin_token function of pagure-admin without + """Test the do_create_admin_token function of pagure-admin without user. """ exp_date = datetime.date.today() + datetime.timedelta(days=300) @@ -61,7 +60,7 @@ class PagureAdminAdminTokenEmptytests(tests.Modeltests): self.assertEqual(cm.exception.args[0], 'No user "pingou" found') def test_do_list_admin_token_empty(self): - """ Test the do_list_admin_token function of pagure-admin when there + """Test the do_list_admin_token function of pagure-admin when there are not tokens in the db. """ list_args = munch.Munch( @@ -178,8 +177,7 @@ class PagureAdminAdminRefreshGitolitetests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation") @patch("pagure.lib.git_auth.get_git_auth_helper") def test_do_refresh_gitolite_one_project_and_all(self, get_helper, conf): - """ Test the do_generate_acl function for a certain project and all. - """ + """Test the do_generate_acl function for a certain project and all.""" conf.return_value = True helper = MagicMock() get_helper.return_value = helper @@ -321,8 +319,8 @@ class PagureAdminAdminTokentests(tests.Modeltests): self.assertEqual(output, "No admin tokens found\n") def test_do_list_admin_token_non_admin_acls(self): - """ Test the do_list_admin_token function of pagure-admin for a token - without any admin ACL. """ + """Test the do_list_admin_token function of pagure-admin for a token + without any admin ACL.""" exp_date = datetime.date.today() + datetime.timedelta(days=300) pagure.lib.query.add_token_to_user( self.session, @@ -415,8 +413,8 @@ class PagureAdminAdminTokentests(tests.Modeltests): ) def test_do_info_admin_token_non_admin_acl(self): - """ Test the do_info_admin_token function of pagure-admin for a - token not having any admin ACL. """ + """Test the do_info_admin_token function of pagure-admin for a + token not having any admin ACL.""" exp_date = datetime.date.today() + datetime.timedelta(days=300) pagure.lib.query.add_token_to_user( self.session, @@ -533,8 +531,8 @@ class PagureAdminAdminTokentests(tests.Modeltests): @patch("pagure.cli.admin._get_input") @patch("pagure.cli.admin._ask_confirmation") def test_do_expire_admin_token_non_admin_acls(self, conf, rinp): - """ Test the do_expire_admin_token function of pagure-admin for a token - without any admin ACL. """ + """Test the do_expire_admin_token function of pagure-admin for a token + without any admin ACL.""" # Create an admin token to use conf.return_value = True @@ -590,8 +588,8 @@ class PagureAdminAdminTokentests(tests.Modeltests): @patch("pagure.cli.admin._get_input") @patch("pagure.cli.admin._ask_confirmation") def test_do_update_admin_token_invalid_date(self, conf, rinp): - """ Test the do_update_admin_token function of pagure-admin with - an invalid date. """ + """Test the do_update_admin_token function of pagure-admin with + an invalid date.""" # Create an admin token to use conf.return_value = True @@ -637,8 +635,8 @@ class PagureAdminAdminTokentests(tests.Modeltests): @patch("pagure.cli.admin._get_input") @patch("pagure.cli.admin._ask_confirmation") def test_do_update_admin_token_invalid_date2(self, conf, rinp): - """ Test the do_update_admin_token function of pagure-admin with - an invalid date. """ + """Test the do_update_admin_token function of pagure-admin with + an invalid date.""" # Create an admin token to use conf.return_value = True @@ -686,8 +684,8 @@ class PagureAdminAdminTokentests(tests.Modeltests): @patch("pagure.cli.admin._get_input") @patch("pagure.cli.admin._ask_confirmation") def test_do_update_admin_token_invalid_date3(self, conf, rinp): - """ Test the do_update_admin_token function of pagure-admin with - an invalid date (is today). """ + """Test the do_update_admin_token function of pagure-admin with + an invalid date (is today).""" # Create an admin token to use conf.return_value = True @@ -826,8 +824,8 @@ class PagureAdminAdminTokentests(tests.Modeltests): @patch("pagure.cli.admin._get_input") @patch("pagure.cli.admin._ask_confirmation") def test_do_update_admin_token_non_admin_acls(self, conf, rinp): - """ Test the do_update_admin_token function of pagure-admin for a token - without any admin ACL. """ + """Test the do_update_admin_token function of pagure-admin for a token + without any admin ACL.""" # Create an admin token to use conf.return_value = True @@ -949,7 +947,7 @@ class PagureAdminGetWatchTests(tests.Modeltests): pagure.cli.admin.session = self.session def test_get_watch_get_project_unknown_project(self): - """ Test the get-watch function of pagure-admin with an unknown + """Test the get-watch function of pagure-admin with an unknown project. """ args = munch.Munch({"project": "foobar", "user": "pingou"}) @@ -960,7 +958,7 @@ class PagureAdminGetWatchTests(tests.Modeltests): ) def test_get_watch_get_project_invalid_project(self): - """ Test the get-watch function of pagure-admin with an invalid + """Test the get-watch function of pagure-admin with an invalid project. """ args = munch.Munch({"project": "fo/o/bar", "user": "pingou"}) @@ -972,16 +970,14 @@ class PagureAdminGetWatchTests(tests.Modeltests): ) def test_get_watch_get_project_invalid_user(self): - """ Test the get-watch function of pagure-admin on a invalid user. - """ + """Test the get-watch function of pagure-admin on a invalid user.""" args = munch.Munch({"project": "test", "user": "beebop"}) with self.assertRaises(pagure.exceptions.PagureException) as cm: pagure.cli.admin.do_get_watch_status(args) self.assertEqual(cm.exception.args[0], 'No user "beebop" found') def test_get_watch_get_project(self): - """ Test the get-watch function of pagure-admin on a regular project. - """ + """Test the get-watch function of pagure-admin on a regular project.""" args = munch.Munch({"project": "test", "user": "pingou"}) with tests.capture_output() as output: pagure.cli.admin.do_get_watch_status(args) @@ -993,8 +989,7 @@ class PagureAdminGetWatchTests(tests.Modeltests): ) def test_get_watch_get_project_not_watching(self): - """ Test the get-watch function of pagure-admin on a regular project. - """ + """Test the get-watch function of pagure-admin on a regular project.""" args = munch.Munch({"project": "test", "user": "foo"}) with tests.capture_output() as output: @@ -1005,8 +1000,7 @@ class PagureAdminGetWatchTests(tests.Modeltests): ) def test_get_watch_get_project_namespaced(self): - """ Test the get-watch function of pagure-admin on a namespaced project. - """ + """Test the get-watch function of pagure-admin on a namespaced project.""" args = munch.Munch({"project": "somenamespace/test", "user": "pingou"}) with tests.capture_output() as output: @@ -1019,8 +1013,7 @@ class PagureAdminGetWatchTests(tests.Modeltests): ) def test_get_watch_get_project_namespaced_not_watching(self): - """ Test the get-watch function of pagure-admin on a namespaced project. - """ + """Test the get-watch function of pagure-admin on a namespaced project.""" args = munch.Munch({"project": "somenamespace/test", "user": "foo"}) with tests.capture_output() as output: @@ -1090,7 +1083,7 @@ class PagureAdminUpdateWatchTests(tests.Modeltests): pagure.cli.admin.session = self.session def test_get_watch_update_project_unknown_project(self): - """ Test the update-watch function of pagure-admin on an unknown + """Test the update-watch function of pagure-admin on an unknown project. """ args = munch.Munch( @@ -1103,7 +1096,7 @@ class PagureAdminUpdateWatchTests(tests.Modeltests): ) def test_get_watch_update_project_invalid_project(self): - """ Test the update-watch function of pagure-admin on an invalid + """Test the update-watch function of pagure-admin on an invalid project. """ args = munch.Munch( @@ -1117,15 +1110,14 @@ class PagureAdminUpdateWatchTests(tests.Modeltests): ) def test_get_watch_update_project_invalid_user(self): - """ Test the update-watch function of pagure-admin on an invalid user. - """ + """Test the update-watch function of pagure-admin on an invalid user.""" args = munch.Munch({"project": "test", "user": "foob", "status": "1"}) with self.assertRaises(pagure.exceptions.PagureException) as cm: pagure.cli.admin.do_update_watch_status(args) self.assertEqual(cm.exception.args[0], 'No user "foob" found') def test_get_watch_update_project_invalid_status(self): - """ Test the update-watch function of pagure-admin with an invalid + """Test the update-watch function of pagure-admin with an invalid status. """ args = munch.Munch( @@ -1139,7 +1131,7 @@ class PagureAdminUpdateWatchTests(tests.Modeltests): ) def test_get_watch_update_project_no_effect(self): - """ Test the update-watch function of pagure-admin with a regular + """Test the update-watch function of pagure-admin with a regular project - nothing changed. """ @@ -1222,7 +1214,7 @@ class PagureAdminReadOnlyTests(tests.Modeltests): pagure.cli.admin.session = self.session def test_read_only_unknown_project(self): - """ Test the read-only function of pagure-admin on an unknown + """Test the read-only function of pagure-admin on an unknown project. """ @@ -1234,7 +1226,7 @@ class PagureAdminReadOnlyTests(tests.Modeltests): ) def test_read_only_invalid_project(self): - """ Test the read-only function of pagure-admin on an invalid + """Test the read-only function of pagure-admin on an invalid project. """ @@ -1247,7 +1239,7 @@ class PagureAdminReadOnlyTests(tests.Modeltests): ) def test_read_only(self): - """ Test the read-only function of pagure-admin to get status of + """Test the read-only function of pagure-admin to get status of a non-namespaced project. """ @@ -1261,7 +1253,7 @@ class PagureAdminReadOnlyTests(tests.Modeltests): ) def test_read_only_namespace(self): - """ Test the read-only function of pagure-admin to get status of + """Test the read-only function of pagure-admin to get status of a namespaced project. """ @@ -1278,7 +1270,7 @@ class PagureAdminReadOnlyTests(tests.Modeltests): ) def test_read_only_namespace_changed(self): - """ Test the read-only function of pagure-admin to set the status of + """Test the read-only function of pagure-admin to set the status of a namespaced project. """ @@ -1321,7 +1313,7 @@ class PagureAdminReadOnlyTests(tests.Modeltests): ) def test_read_only_no_change(self): - """ Test the read-only function of pagure-admin to set the status of + """Test the read-only function of pagure-admin to set the status of a namespaced project. """ @@ -1387,7 +1379,7 @@ class PagureNewGroupTests(tests.Modeltests): self.assertEqual(len(groups), 0) def test_missing_display_name(self): - """ Test the new-group function of pagure-admin when the display name + """Test the new-group function of pagure-admin when the display name is missing from the args. """ @@ -1410,7 +1402,7 @@ class PagureNewGroupTests(tests.Modeltests): self.assertEqual(len(groups), 0) def test_missing_username(self): - """ Test the new-group function of pagure-admin when the username + """Test the new-group function of pagure-admin when the username is missing from the args. """ @@ -1435,7 +1427,7 @@ class PagureNewGroupTests(tests.Modeltests): self.assertEqual(len(groups), 0) def test_new_group(self): - """ Test the new-group function of pagure-admin when all arguments + """Test the new-group function of pagure-admin when all arguments are provided. """ @@ -1456,7 +1448,7 @@ class PagureNewGroupTests(tests.Modeltests): @patch.dict("pagure.config.config", {"ENABLE_GROUP_MNGT": False}) @patch("pagure.cli.admin._ask_confirmation") def test_new_group_grp_mngt_off_no(self, conf): - """ Test the new-group function of pagure-admin when all arguments + """Test the new-group function of pagure-admin when all arguments are provided and ENABLE_GROUP_MNGT if off in the config and the user replies no to the question. """ @@ -1479,7 +1471,7 @@ class PagureNewGroupTests(tests.Modeltests): @patch.dict("pagure.config.config", {"ENABLE_GROUP_MNGT": False}) @patch("pagure.cli.admin._ask_confirmation") def test_new_group_grp_mngt_off_yes(self, conf): - """ Test the new-group function of pagure-admin when all arguments + """Test the new-group function of pagure-admin when all arguments are provided and ENABLE_GROUP_MNGT if off in the config and the user replies yes to the question. """ @@ -1501,7 +1493,7 @@ class PagureNewGroupTests(tests.Modeltests): @patch.dict("pagure.config.config", {"BLACKLISTED_GROUPS": ["foob"]}) def test_new_group_grp_mngt_off_yes(self): - """ Test the new-group function of pagure-admin when all arguments + """Test the new-group function of pagure-admin when all arguments are provided but the group is black listed. """ @@ -1557,7 +1549,7 @@ class PagureListGroupEmptyTests(tests.Modeltests): @patch("sys.stdout", new_callable=StringIO) def test_no_groups(self, mock_stdout): - """ Test the list-groups function of pagure-admin when there are no + """Test the list-groups function of pagure-admin when there are no groups in the database """ @@ -1616,7 +1608,7 @@ class PagureListGroupTests(tests.Modeltests): @patch("sys.stdout", new_callable=StringIO) def test_list_groups(self, mock_stdout): - """ Test the list-groups function of pagure-admin when there is one + """Test the list-groups function of pagure-admin when there is one group in the database """ @@ -1662,7 +1654,7 @@ class PagureBlockUserTests(tests.Modeltests): self.assertIsNone(user.refuse_sessions_before) def test_missing_date(self): - """ Test the block-user function of pagure-admin when the no date is + """Test the block-user function of pagure-admin when the no date is provided. """ @@ -1678,7 +1670,7 @@ class PagureBlockUserTests(tests.Modeltests): self.assertIsNone(user.refuse_sessions_before) def test_missing_username(self): - """ Test the block-user function of pagure-admin when the username + """Test the block-user function of pagure-admin when the username is missing from the args. """ @@ -1695,7 +1687,7 @@ class PagureBlockUserTests(tests.Modeltests): self.assertIsNone(user.refuse_sessions_before) def test_invalid_username(self): - """ Test the block-user function of pagure-admin when the username + """Test the block-user function of pagure-admin when the username provided does correspond to any user in the DB. """ @@ -1712,7 +1704,7 @@ class PagureBlockUserTests(tests.Modeltests): self.assertIsNone(user.refuse_sessions_before) def test_invalide_date(self): - """ Test the block-user function of pagure-admin when the provided + """Test the block-user function of pagure-admin when the provided date is incorrect. """ @@ -1733,7 +1725,7 @@ class PagureBlockUserTests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation", MagicMock(return_value=True)) def test_block_user(self): - """ Test the block-user function of pagure-admin when all arguments + """Test the block-user function of pagure-admin when all arguments are provided correctly. """ @@ -1747,7 +1739,7 @@ class PagureBlockUserTests(tests.Modeltests): self.assertIsNotNone(user.refuse_sessions_before) def test_list_blocked_user(self): - """ Test the block-user function of pagure-admin when all arguments + """Test the block-user function of pagure-admin when all arguments are provided correctly. """ @@ -1761,7 +1753,7 @@ class PagureBlockUserTests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation", MagicMock(return_value=True)) def test_list_blocked_user_with_data(self): - """ Test the block-user function of pagure-admin when all arguments + """Test the block-user function of pagure-admin when all arguments are provided correctly. """ args = munch.Munch( @@ -1783,7 +1775,7 @@ class PagureBlockUserTests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation", MagicMock(return_value=True)) def test_list_blocked_user_with_username_data(self): - """ Test the block-user function of pagure-admin when all arguments + """Test the block-user function of pagure-admin when all arguments are provided correctly. """ args = munch.Munch( @@ -1812,7 +1804,7 @@ class PagureBlockUserTests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation", MagicMock(return_value=True)) def test_list_blocked_user_with_date(self): - """ Test the block-user function of pagure-admin when all arguments + """Test the block-user function of pagure-admin when all arguments are provided correctly. """ args = munch.Munch( @@ -1827,7 +1819,7 @@ class PagureBlockUserTests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation", MagicMock(return_value=True)) def test_list_blocked_user_with_date_and_data(self): - """ Test the block-user function of pagure-admin when all arguments + """Test the block-user function of pagure-admin when all arguments are provided correctly. """ args = munch.Munch( @@ -1906,7 +1898,7 @@ class PagureAdminDeleteProjectTests(tests.Modeltests): pagure.cli.admin.session = self.session def test_delete_project_unknown_project(self): - """ Test the read-only function of pagure-admin on an unknown + """Test the read-only function of pagure-admin on an unknown project. """ @@ -1921,7 +1913,7 @@ class PagureAdminDeleteProjectTests(tests.Modeltests): ) def test_delete_project_invalid_project(self): - """ Test the read-only function of pagure-admin on an invalid + """Test the read-only function of pagure-admin on an invalid project. """ @@ -1937,7 +1929,7 @@ class PagureAdminDeleteProjectTests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation", MagicMock(return_value=True)) def test_delete_project(self): - """ Test the read-only function of pagure-admin to get status of + """Test the read-only function of pagure-admin to get status of a non-namespaced project. """ @@ -1956,7 +1948,7 @@ class PagureAdminDeleteProjectTests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation", MagicMock(return_value=True)) def test_delete_project_namespace(self): - """ Test the read-only function of pagure-admin to get status of + """Test the read-only function of pagure-admin to get status of a namespaced project. """ @@ -1979,7 +1971,7 @@ class PagureAdminDeleteProjectTests(tests.Modeltests): @patch("pagure.cli.admin._ask_confirmation", MagicMock(return_value=True)) def test_delete_project_namespace_changed(self): - """ Test the read-only function of pagure-admin to set the status of + """Test the read-only function of pagure-admin to set the status of a namespaced project. """ @@ -2027,7 +2019,7 @@ class PagureCreateBranchTests(tests.Modeltests): pagure.cli.admin.session = self.session def test_create_branch_unknown_project(self): - """ Test the read-only function of pagure-admin on an unknown + """Test the read-only function of pagure-admin on an unknown project. """ @@ -2049,7 +2041,7 @@ class PagureCreateBranchTests(tests.Modeltests): ) def test_create_branch_invalid_project(self): - """ Test the read-only function of pagure-admin on an invalid + """Test the read-only function of pagure-admin on an invalid project. """ @@ -2071,7 +2063,7 @@ class PagureCreateBranchTests(tests.Modeltests): ) def test_create_branch_commit_and_branch_from(self): - """ Test the read-only function of pagure-admin to get status of + """Test the read-only function of pagure-admin to get status of a non-namespaced project. """ @@ -2094,7 +2086,7 @@ class PagureCreateBranchTests(tests.Modeltests): ) def test_create_branch_no_branch_from(self): - """ Test the read-only function of pagure-admin to get status of + """Test the read-only function of pagure-admin to get status of a non-namespaced project. """ @@ -2115,7 +2107,7 @@ class PagureCreateBranchTests(tests.Modeltests): ) def test_create_branch_no_commit_from(self): - """ Test the read-only function of pagure-admin to get status of + """Test the read-only function of pagure-admin to get status of a non-namespaced project. """ @@ -2186,7 +2178,7 @@ class PagureSetDefaultBranchTests(tests.Modeltests): pagure.cli.admin.session = self.session def test_set_default_branch_unknown_project(self): - """ Test the set-default-branch function of pagure-admin on an unknown + """Test the set-default-branch function of pagure-admin on an unknown project. """ @@ -2201,7 +2193,7 @@ class PagureSetDefaultBranchTests(tests.Modeltests): ) def test_set_default_branch_invalid_project(self): - """ Test the set-default-branch function of pagure-admin on an invalid + """Test the set-default-branch function of pagure-admin on an invalid project. """ @@ -2216,7 +2208,7 @@ class PagureSetDefaultBranchTests(tests.Modeltests): ) def test_set_default_branch_unknown_branch(self): - """ Test the set-default-branch function of pagure-admin on an unknown + """Test the set-default-branch function of pagure-admin on an unknown branch. """ @@ -2228,8 +2220,7 @@ class PagureSetDefaultBranchTests(tests.Modeltests): ) def test_set_default_branch_invalid_branch(self): - """ Test the set-default-branch function of pagure-admin on an invalid branch. - """ + """Test the set-default-branch function of pagure-admin on an invalid branch.""" args = munch.Munch( {"project": "test", "user": None, "branch": "~invalid~"} @@ -2277,8 +2268,7 @@ class PagureAdminUpdateAclsTests(tests.Modeltests): pagure.cli.admin.session = self.session def test_update_acls(self): - """ Test the update-acls function of pagure-admin. - """ + """Test the update-acls function of pagure-admin.""" args = munch.Munch() with tests.capture_output() as output: pagure.cli.admin.do_update_acls(args) diff --git a/tests/test_pagure_flask.py b/tests/test_pagure_flask.py index 82b5dc0..ec9fead 100644 --- a/tests/test_pagure_flask.py +++ b/tests/test_pagure_flask.py @@ -57,16 +57,15 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertTrue(output.endswith("repos_test2.git_master")) def test_is_repo_committer_logged_out(self): - """ Test is_repo_committer in pagure when there is no logged in user. - """ + """Test is_repo_committer in pagure when there is no logged in user.""" repo = pagure.lib.query._get_project(self.session, "test") with self.app.application.app_context(): output = pagure.utils.is_repo_committer(repo) self.assertFalse(output) def test_is_repo_committer_logged_in(self): - """ Test is_repo_committer in pagure with the appropriate user logged - in. """ + """Test is_repo_committer in pagure with the appropriate user logged + in.""" repo = pagure.lib.query._get_project(self.session, "test") g = munch.Munch() @@ -78,8 +77,8 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertTrue(output) def test_is_repo_committer_logged_in_in_group(self): - """ Test is_repo_committer in pagure with the appropriate user logged - in. """ + """Test is_repo_committer in pagure with the appropriate user logged + in.""" # Create group msg = pagure.lib.query.add_group( self.session, @@ -127,8 +126,8 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertTrue(output) def test_is_repo_committer_logged_in_in_ticket_group(self): - """ Test is_repo_committer in pagure with the appropriate user logged - in. """ + """Test is_repo_committer in pagure with the appropriate user logged + in.""" # Create group msg = pagure.lib.query.add_group( self.session, @@ -180,8 +179,7 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertFalse(output) def test_is_repo_committer_logged_in_wrong_user(self): - """ Test is_repo_committer in pagure with the wrong user logged in. - """ + """Test is_repo_committer in pagure with the wrong user logged in.""" repo = pagure.lib.query._get_project(self.session, "test") g = munch.Munch() @@ -197,7 +195,7 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): @mock.patch.dict("pagure.config.config", {"EXTERNAL_COMMITTER": config}) def test_is_repo_committer_external_committer_generic_no_member(self): - """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER + """Test is_repo_committer in pagure with EXTERNAL_COMMITTER configured to give access to all the provenpackager, but the user is not one. """ @@ -214,7 +212,7 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): @mock.patch.dict("pagure.config.config", {"EXTERNAL_COMMITTER": config}) def test_is_repo_committer_external_committer_generic_member(self): - """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER + """Test is_repo_committer in pagure with EXTERNAL_COMMITTER configured to give access to all the provenpackager, and the user is one """ @@ -233,7 +231,7 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): @mock.patch.dict("pagure.config.config", {"EXTERNAL_COMMITTER": config}) def test_is_repo_committer_external_committer_excluding_one(self): - """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER + """Test is_repo_committer in pagure with EXTERNAL_COMMITTER configured to give access to all the provenpackager but for this one repo """ @@ -250,7 +248,7 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): @mock.patch.dict("pagure.config.config", {"EXTERNAL_COMMITTER": config}) def test_is_repo_committer_owner_external_committer_excluding_one(self): - """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER + """Test is_repo_committer in pagure with EXTERNAL_COMMITTER configured to give access to all the provenpackager but for this one repo, but the user is still a direct committer """ @@ -269,7 +267,7 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): @mock.patch.dict("pagure.config.config", {"EXTERNAL_COMMITTER": config}) def test_is_repo_committer_external_committer_restricted_not_member(self): - """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER + """Test is_repo_committer in pagure with EXTERNAL_COMMITTER configured to give access the provenpackager just for one repo """ repo = pagure.lib.query._get_project(self.session, "test") @@ -284,7 +282,7 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): @mock.patch.dict("pagure.config.config", {"EXTERNAL_COMMITTER": config}) def test_is_repo_committer_external_committer_restricting_to_one(self): - """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER + """Test is_repo_committer in pagure with EXTERNAL_COMMITTER configured to give access the provenpackager just for one repo """ repo = pagure.lib.query._get_project(self.session, "test") @@ -302,7 +300,7 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): def test_is_repo_committer_external_committer_restricting_another_one( self, ): - """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER + """Test is_repo_committer in pagure with EXTERNAL_COMMITTER configured to give access the provenpackager just for one repo not this one """ @@ -318,16 +316,15 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertFalse(output) def test_is_repo_collaborator_logged_out(self): - """ Test is_repo_committer in pagure when there is no logged in user. - """ + """Test is_repo_committer in pagure when there is no logged in user.""" repo = pagure.lib.query._get_project(self.session, "test") with self.app.application.app_context(): output = pagure.utils.is_repo_collaborator(repo, "master") self.assertFalse(output) def test_is_repo_collaborator_logged_in(self): - """ Test is_repo_collaborator in pagure with the appropriate user logged - in. """ + """Test is_repo_collaborator in pagure with the appropriate user logged + in.""" repo = pagure.lib.query._get_project(self.session, "test") g = munch.Munch() @@ -341,8 +338,8 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertTrue(output) def test_is_repo_collaborator_invalid_username(self): - """ Test is_repo_collaborator in pagure with the appropriate user logged - in. """ + """Test is_repo_collaborator in pagure with the appropriate user logged + in.""" repo = pagure.lib.query._get_project(self.session, "test") g = munch.Munch() @@ -357,8 +354,8 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): @mock.patch.dict("pagure.config.config", {"PAGURE_ADMIN_USERS": ["foo"]}) def test_is_repo_collaborator_admin_user(self): - """ Test is_repo_collaborator in pagure with the appropriate user logged - in. """ + """Test is_repo_collaborator in pagure with the appropriate user logged + in.""" repo = pagure.lib.query._get_project(self.session, "test") g = munch.Munch() @@ -372,8 +369,8 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertTrue(output) def test_is_repo_collaborator_not_in_project(self): - """ Test is_repo_collaborator in pagure with the appropriate user logged - in. """ + """Test is_repo_collaborator in pagure with the appropriate user logged + in.""" repo = pagure.lib.query._get_project(self.session, "test") g = munch.Munch() @@ -387,8 +384,8 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertFalse(output) def test_is_repo_collaborator_in_project(self): - """ Test is_repo_collaborator in pagure with the appropriate user logged - in. """ + """Test is_repo_collaborator in pagure with the appropriate user logged + in.""" repo = pagure.lib.query._get_project(self.session, "test") # Add user foo to project test @@ -431,8 +428,8 @@ class PagureGetRemoteRepoPath(tests.SimplePagureTest): self.assertTrue(output) def test_is_repo_collaborator_logged_in_in_group(self): - """ Test is_repo_committer in pagure with the appropriate user logged - in. """ + """Test is_repo_committer in pagure with the appropriate user logged + in.""" # Create group msg = pagure.lib.query.add_group( self.session, diff --git a/tests/test_pagure_flask_api_auth.py b/tests/test_pagure_flask_api_auth.py index d5c49b6..051ba1c 100644 --- a/tests/test_pagure_flask_api_auth.py +++ b/tests/test_pagure_flask_api_auth.py @@ -31,8 +31,7 @@ class PagureFlaskApiAuthtests(tests.SimplePagureTest): """ Tests for the authentication in the flask API of pagure """ def test_auth_no_data(self): - """ Test the authentication when there is nothing in the database. - """ + """Test the authentication when there is nothing in the database.""" output = self.app.post("/api/0/foo/new_issue") self.assertEqual(output.status_code, 401) @@ -53,8 +52,7 @@ class PagureFlaskApiAuthtests(tests.SimplePagureTest): self.assertEqual(pagure.api.APIERROR.EINVALIDTOK.value, data["error"]) def test_auth_noacl(self): - """ Test the authentication when the token does not have any ACL. - """ + """Test the authentication when the token does not have any ACL.""" tests.create_projects(self.session) tests.create_tokens(self.session) @@ -77,8 +75,7 @@ class PagureFlaskApiAuthtests(tests.SimplePagureTest): self.assertEqual(pagure.api.APIERROR.EINVALIDTOK.value, data["error"]) def test_auth_expired(self): - """ Test the authentication when the token has expired. - """ + """Test the authentication when the token has expired.""" tests.create_projects(self.session) tests.create_tokens(self.session) @@ -101,8 +98,7 @@ class PagureFlaskApiAuthtests(tests.SimplePagureTest): self.assertEqual(pagure.api.APIERROR.EINVALIDTOK.value, data["error"]) def test_auth(self): - """ Test the token based authentication. - """ + """Test the token based authentication.""" tests.create_projects(self.session) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) diff --git a/tests/test_pagure_flask_api_boards.py b/tests/test_pagure_flask_api_boards.py index cf6cfd6..3496c5e 100644 --- a/tests/test_pagure_flask_api_boards.py +++ b/tests/test_pagure_flask_api_boards.py @@ -326,7 +326,11 @@ class PagureFlaskApiBoardstests(tests.SimplePagureTest): ) # Remove one of the 2 boards - data = json.dumps({"dev": {"active": True, "tag": "dev"},}) + data = json.dumps( + { + "dev": {"active": True, "tag": "dev"}, + } + ) output = self.app.post( "/api/0/test/boards", headers=headers, data=data ) @@ -395,7 +399,7 @@ class PagureFlaskApiBoardstests(tests.SimplePagureTest): class PagureFlaskApiBoardsWithBoardtests(tests.SimplePagureTest): - """ Tests for flask API Boards controller of pagure for the tests + """Tests for flask API Boards controller of pagure for the tests requiring a pre-existing board. """ @@ -447,7 +451,11 @@ class PagureFlaskApiBoardsWithBoardtests(tests.SimplePagureTest): } # Associate the existing board with an invalid tag - data = json.dumps({"dev": {"active": True, "tag": "invalid"},}) + data = json.dumps( + { + "dev": {"active": True, "tag": "invalid"}, + } + ) output = self.app.post( "/api/0/test/boards", headers=headers, data=data ) @@ -521,7 +529,8 @@ class PagureFlaskApiBoardsWithBoardtests(tests.SimplePagureTest): self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( - data, {"boards": []}, + data, + {"boards": []}, ) def test_api_board_delete_html_input(self): @@ -537,7 +546,8 @@ class PagureFlaskApiBoardsWithBoardtests(tests.SimplePagureTest): self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( - data, {"boards": []}, + data, + {"boards": []}, ) def test_api_board_api_board_status_no_data(self): @@ -1043,7 +1053,7 @@ class PagureFlaskApiBoardsWithBoardtests(tests.SimplePagureTest): class PagureFlaskApiBoardsWithBoardAndIssuetests(tests.SimplePagureTest): - """ Tests for flask API Boards controller of pagure for the tests + """Tests for flask API Boards controller of pagure for the tests requiring a pre-existing board and issues. """ @@ -1130,7 +1140,14 @@ class PagureFlaskApiBoardsWithBoardAndIssuetests(tests.SimplePagureTest): "Content-Type": "application/json", } - data = json.dumps({"12": {"status": "In Progress", "rank": 2,}}) + data = json.dumps( + { + "12": { + "status": "In Progress", + "rank": 2, + } + } + ) output = self.app.post( "/api/0/test/boards/invalid/add_issue", headers=headers, data=data ) @@ -1193,7 +1210,13 @@ class PagureFlaskApiBoardsWithBoardAndIssuetests(tests.SimplePagureTest): "Content-Type": "application/json", } - data = json.dumps({"12": {"rank": 2,}}) + data = json.dumps( + { + "12": { + "rank": 2, + } + } + ) output = self.app.post( "/api/0/test/boards/dev/add_issue", headers=headers, data=data ) @@ -1290,7 +1313,14 @@ class PagureFlaskApiBoardsWithBoardAndIssuetests(tests.SimplePagureTest): "Content-Type": "application/json", } - data = json.dumps({"12": {"status": "In Progress", "rank": 2,}}) + data = json.dumps( + { + "12": { + "status": "In Progress", + "rank": 2, + } + } + ) output = self.app.post( "/api/0/test/boards/invalid/update_issue", headers=headers, @@ -1355,7 +1385,13 @@ class PagureFlaskApiBoardsWithBoardAndIssuetests(tests.SimplePagureTest): "Content-Type": "application/json", } - data = json.dumps({"12": {"rank": 2,}}) + data = json.dumps( + { + "12": { + "rank": 2, + } + } + ) output = self.app.post( "/api/0/test/boards/dev/add_issue", headers=headers, data=data ) @@ -1453,7 +1489,9 @@ class PagureFlaskApiBoardsWithBoardAndIssuetests(tests.SimplePagureTest): } data = json.dumps( - {self.tickets_uid[1]: {"status": "Done", "rank": 2},} + { + self.tickets_uid[1]: {"status": "Done", "rank": 2}, + } ) output = self.app.post( "/api/0/test/boards/dev/update_issue", headers=headers, data=data @@ -1467,7 +1505,9 @@ class PagureFlaskApiBoardsWithBoardAndIssuetests(tests.SimplePagureTest): self.assertEqual(repo.issues[1].close_status, "Fixed") data = json.dumps( - {self.tickets_uid[1]: {"status": "In Progress", "rank": 2},} + { + self.tickets_uid[1]: {"status": "In Progress", "rank": 2}, + } ) output = self.app.post( "/api/0/test/boards/dev/update_issue", headers=headers, data=data @@ -1488,7 +1528,11 @@ class PagureFlaskApiBoardsWithBoardAndIssuetests(tests.SimplePagureTest): "Content-Type": "application/json", } - data = json.dumps({"2": {"status": "In Progress", "rank": 2},}) + data = json.dumps( + { + "2": {"status": "In Progress", "rank": 2}, + } + ) output = self.app.post( "/api/0/test/boards/dev/add_issue", headers=headers, data=data ) diff --git a/tests/test_pagure_flask_api_fork.py b/tests/test_pagure_flask_api_fork.py index 4b54d89..f8ab7dd 100644 --- a/tests/test_pagure_flask_api_fork.py +++ b/tests/test_pagure_flask_api_fork.py @@ -41,8 +41,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_views_pr_disabled(self): - """ Test the api_pull_request_views method of the flask api when PR - are disabled. """ + """Test the api_pull_request_views method of the flask api when PR + are disabled.""" tests.create_projects(self.session) tests.create_tokens(self.session) @@ -86,8 +86,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_views_pr_closed(self): - """ Test the api_pull_request_views method of the flask api to list - the closed PRs. """ + """Test the api_pull_request_views method of the flask api to list + the closed PRs.""" tests.create_projects(self.session) tests.create_tokens(self.session) @@ -266,8 +266,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_views_all_pr(self): - """ Test the api_pull_request_views method of the flask api to list - all PRs. """ + """Test the api_pull_request_views method of the flask api to list + all PRs.""" tests.create_projects(self.session) tests.create_tokens(self.session) @@ -542,8 +542,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_pull_request_view_tag_filtered(self, send_email): - """ Test the api_pull_request_view method of the flask api to list - tag filtered open PRs. """ + """Test the api_pull_request_view method of the flask api to list + tag filtered open PRs.""" send_email.return_value = True tests.create_projects(self.session) tests.create_tokens(self.session) @@ -1225,8 +1225,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_pull_request_merge_pr_disabled(self, send_email): - """ Test the api_pull_request_merge method of the flask api when PR - are disabled. """ + """Test the api_pull_request_merge method of the flask api when PR + are disabled.""" send_email.return_value = True tests.create_projects(self.session) @@ -1283,8 +1283,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_pull_request_merge_only_assigned(self, send_email): - """ Test the api_pull_request_merge method of the flask api when - only assignee can merge the PR and the PR isn't assigned. """ + """Test the api_pull_request_merge method of the flask api when + only assignee can merge the PR and the PR isn't assigned.""" send_email.return_value = True tests.create_projects(self.session) @@ -1343,9 +1343,9 @@ class PagureFlaskApiForktests(tests.Modeltests): def test_api_pull_request_merge_only_assigned_not_assignee( self, send_email ): - """ Test the api_pull_request_merge method of the flask api when + """Test the api_pull_request_merge method of the flask api when only assignee can merge the PR and the PR isn't assigned to the - user asking to merge. """ + user asking to merge.""" send_email.return_value = True tests.create_projects(self.session) @@ -1405,8 +1405,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_pull_request_merge_minimal_score(self, send_email): - """ Test the api_pull_request_merge method of the flask api when - a PR requires a certain minimal score to be merged. """ + """Test the api_pull_request_merge method of the flask api when + a PR requires a certain minimal score to be merged.""" send_email.return_value = True tests.create_projects(self.session) @@ -1884,8 +1884,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_add_comment_wrong_user(self): - """ Test the api_pull_request_add_comment method of the flask api - when the user is not found in the DB. """ + """Test the api_pull_request_add_comment method of the flask api + when the user is not found in the DB.""" tests.create_projects(self.session) tests.create_tokens(self.session, project_id=None) @@ -1931,8 +1931,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_add_comment_pr_disabled(self): - """ Test the api_pull_request_add_comment method of the flask api - when PRs are disabled. """ + """Test the api_pull_request_add_comment method of the flask api + when PRs are disabled.""" tests.create_projects(self.session) tests.create_tokens(self.session, project_id=None) @@ -2391,8 +2391,8 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_api_subscribe_pull_request_logged_in(self, p_send_email, p_ugt): - """ Test the api_subscribe_pull_request method of the flask api - when the user is logged in via the UI. """ + """Test the api_subscribe_pull_request method of the flask api + when the user is logged in via the UI.""" p_send_email.return_value = True p_ugt.return_value = True @@ -2468,7 +2468,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_invalid_project(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when not the project doesn't exist. """ @@ -2502,7 +2502,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_missing_title(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when not title is submitted. """ @@ -2541,7 +2541,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_missing_branch_to(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when not branch to is submitted. """ @@ -2580,7 +2580,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_missing_branch_from(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when not branch from is submitted. """ @@ -2619,7 +2619,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_pr_disabled(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when the parent repo disabled pull-requests. """ @@ -2666,7 +2666,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_signed_pr(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when the parent repo enforces signed-off pull-requests. """ @@ -2714,7 +2714,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_invalid_branch_from(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when the branch from does not exist. """ @@ -2762,7 +2762,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_invalid_token(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when queried with an invalid token. """ @@ -2803,7 +2803,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_invalid_access(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when the user opening the PR doesn't have commit access. """ @@ -2843,7 +2843,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_invalid_branch_to(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when the branch to does not exist. """ @@ -2959,7 +2959,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_from_branch_to_origin(self): """Test the api_pull_request_create method from a fork to a master, - with project token of a origin with all the acls""" + with project token of a origin with all the acls""" tests.create_projects(self.session) tests.create_projects( @@ -3182,7 +3182,7 @@ class PagureFlaskApiForktests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_api_pull_request_open_missing_initial_comment(self): - """ Test the api_pull_request_create method of the flask api when + """Test the api_pull_request_create method of the flask api when not initial comment is submitted. """ @@ -3337,8 +3337,7 @@ class PagureFlaskApiForktests(tests.Modeltests): class PagureFlaskApiForkPRDiffStatstests(tests.Modeltests): - """ Tests for the flask API of pagure for the diff stats endpoint of PRs - """ + """Tests for the flask API of pagure for the diff stats endpoint of PRs""" maxDiff = None @@ -3530,8 +3529,7 @@ class PagureFlaskApiForkPRDiffStatstests(tests.Modeltests): class PagureApiThresholdReachedTests(tests.Modeltests): - """ Test the behavior of the threshold_reached value returned by the API. - """ + """Test the behavior of the threshold_reached value returned by the API.""" maxDiff = None @@ -3712,8 +3710,7 @@ class PagureApiThresholdReachedTests(tests.Modeltests): } def test_api_pull_request_no_comments(self): - """ Check the value of threshold_reach when the PR has no comments. - """ + """Check the value of threshold_reach when the PR has no comments.""" # Check the PR with 0 comment: output = self.app.get("/api/0/test/pull-request/1") @@ -3724,8 +3721,7 @@ class PagureApiThresholdReachedTests(tests.Modeltests): self.assertDictEqual(data, self.expected_data) def test_api_pull_request_one_comments(self): - """ Check the value of threshold_reach when the PR has one comment. - """ + """Check the value of threshold_reach when the PR has one comment.""" # Check the PR with 1 comment: headers = {"Authorization": "token aaabbbcccddd"} data = {"comment": "This is a very interesting solution :thumbsup:"} @@ -3744,7 +3740,7 @@ class PagureApiThresholdReachedTests(tests.Modeltests): self.assertDictEqual(data, self.expected_data) def test_api_pull_request_two_comments_one_person(self): - """ Check the value of threshold_reach when the PR has two comments + """Check the value of threshold_reach when the PR has two comments but from the same person. """ # Add two comments from the same user: @@ -3774,7 +3770,7 @@ class PagureApiThresholdReachedTests(tests.Modeltests): self.assertDictEqual(data, self.expected_data) def test_api_pull_request_two_comments_two_persons(self): - """ Check the value of threshold_reach when the PR has two comments + """Check the value of threshold_reach when the PR has two comments from two different persons. """ # Add two comments from two users: @@ -3805,7 +3801,7 @@ class PagureApiThresholdReachedTests(tests.Modeltests): self.assertDictEqual(data, self.expected_data) def test_api_pull_request_three_comments_two_persons_changed_to_no(self): - """ Check the value of threshold_reach when the PR has three + """Check the value of threshold_reach when the PR has three comments from two person among which one changed their mind from +1 to -1. """ @@ -3847,7 +3843,7 @@ class PagureApiThresholdReachedTests(tests.Modeltests): self.assertDictEqual(data, self.expected_data) def test_api_pull_request_three_comments_two_persons_changed_to_yes(self): - """ Check the value of threshold_reach when the PR has three + """Check the value of threshold_reach when the PR has three comments from two person among which one changed their mind from -1 to +1 """ @@ -3888,8 +3884,7 @@ class PagureApiThresholdReachedTests(tests.Modeltests): class PagureFlaskApiForkGetCommenttests(tests.Modeltests): - """ Tests for the flask API of pagure for the comment endpoint of PRs - """ + """Tests for the flask API of pagure for the comment endpoint of PRs""" maxDiff = None diff --git a/tests/test_pagure_flask_api_fork_assign.py b/tests/test_pagure_flask_api_fork_assign.py index 014f239..514d6ab 100644 --- a/tests/test_pagure_flask_api_fork_assign.py +++ b/tests/test_pagure_flask_api_fork_assign.py @@ -101,8 +101,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): self.assertEqual(output.status_code, 200) def test_api_assign_pr_invalid_project_namespace(self): - """ Test api_pull_request_assign method when the project doesn't exist. - """ + """Test api_pull_request_assign method when the project doesn't exist.""" headers = {"Authorization": "token aaabbbcccddd"} @@ -123,8 +122,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): ) def test_api_assign_pr_invalid_project(self): - """ Test api_pull_request_assign method when the project doesn't exist. - """ + """Test api_pull_request_assign method when the project doesn't exist.""" headers = {"Authorization": "token aaabbbcccddd"} @@ -139,7 +137,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): ) def test_api_assign_pr_invalid_project_token(self): - """ Test api_pull_request_assign method when the token doesn't correspond + """Test api_pull_request_assign method when the token doesn't correspond to the project. """ @@ -158,8 +156,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): ) def test_api_assign_pr_invalid_pr(self): - """ Test api_pull_request_assign method when asking for an invalid PR - """ + """Test api_pull_request_assign method when asking for an invalid PR""" headers = {"Authorization": "token aaabbbcccddd"} @@ -174,8 +171,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): ) def test_api_assign_pr_no_input(self): - """ Test api_pull_request_assign method when no input is specified - """ + """Test api_pull_request_assign method when no input is specified""" headers = {"Authorization": "token aaabbbcccddd"} @@ -188,8 +184,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): self.assertDictEqual(data, {"message": "Nothing to change"}) def test_api_assign_pr_assigned(self): - """ Test api_pull_request_assign method when with valid input - """ + """Test api_pull_request_assign method when with valid input""" headers = {"Authorization": "token aaabbbcccddd"} @@ -204,8 +199,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): self.assertDictEqual(data, {"message": "Request assigned"}) def test_api_assign_pr_unassigned(self): - """ Test api_pull_request_assign method when unassigning - """ + """Test api_pull_request_assign method when unassigning""" self.test_api_assign_pr_assigned() headers = {"Authorization": "token aaabbbcccddd"} @@ -220,8 +214,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): self.assertDictEqual(data, {"message": "Request assignee reset"}) def test_api_assign_pr_unassigned_twice(self): - """ Test api_pull_request_assign method when unassigning - """ + """Test api_pull_request_assign method when unassigning""" self.test_api_assign_pr_unassigned() headers = {"Authorization": "token aaabbbcccddd"} data = {"assignee": None} @@ -235,7 +228,7 @@ class PagureFlaskApiForkAssigntests(tests.SimplePagureTest): self.assertDictEqual(data, {"message": "Nothing to change"}) def test_api_assign_pr_unassigned_empty_string(self): - """ Test api_pull_request_assign method when unassigning with an + """Test api_pull_request_assign method when unassigning with an empty string """ self.test_api_assign_pr_assigned() diff --git a/tests/test_pagure_flask_api_fork_update.py b/tests/test_pagure_flask_api_fork_update.py index 70b4956..48e7b36 100644 --- a/tests/test_pagure_flask_api_fork_update.py +++ b/tests/test_pagure_flask_api_fork_update.py @@ -101,8 +101,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): self.assertEqual(output.status_code, 200) def test_api_pull_request_update_invalid_project_namespace(self): - """ Test api_pull_request_update method when the project doesn't exist. - """ + """Test api_pull_request_update method when the project doesn't exist.""" headers = {"Authorization": "token aaabbbcccddd"} @@ -123,8 +122,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): ) def test_api_pull_request_update_invalid_project(self): - """ Test api_pull_request_update method when the project doesn't exist. - """ + """Test api_pull_request_update method when the project doesn't exist.""" headers = {"Authorization": "token aaabbbcccddd"} @@ -137,7 +135,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): ) def test_api_pull_request_update_invalid_project_token(self): - """ Test api_pull_request_update method when the token doesn't correspond + """Test api_pull_request_update method when the token doesn't correspond to the project. """ @@ -154,8 +152,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): ) def test_api_pull_request_update_invalid_pr(self): - """ Test api_assign_pull_request method when asking for an invalid PR - """ + """Test api_assign_pull_request method when asking for an invalid PR""" headers = {"Authorization": "token aaabbbcccddd"} @@ -168,8 +165,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): ) def test_api_pull_request_update_no_input(self): - """ Test api_assign_pull_request method when no input is specified - """ + """Test api_assign_pull_request method when no input is specified""" headers = {"Authorization": "token aaabbbcccddd"} @@ -187,8 +183,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): ) def test_api_pull_request_update_insufficient_input(self): - """ Test api_assign_pull_request method when no input is specified - """ + """Test api_assign_pull_request method when no input is specified""" headers = {"Authorization": "token aaabbbcccddd"} data = {"initial_comment": "will not work"} @@ -209,8 +204,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): ) def test_api_pull_request_update_edited(self): - """ Test api_assign_pull_request method when with valid input - """ + """Test api_assign_pull_request method when with valid input""" headers = {"Authorization": "token aaabbbcccddd"} @@ -390,8 +384,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): ) def test_api_pull_request_update_edited_no_comment(self): - """ Test api_assign_pull_request method when with valid input - """ + """Test api_assign_pull_request method when with valid input""" headers = {"Authorization": "token aaabbbcccddd"} @@ -568,8 +561,7 @@ class PagureFlaskApiForkUpdatetests(tests.SimplePagureTest): ) def test_api_pull_request_update_edited_linked(self): - """ Test api_assign_pull_request method when with valid input - """ + """Test api_assign_pull_request method when with valid input""" project = pagure.lib.query.get_authorized_project(self.session, "test") self.assertEqual(len(project.requests), 1) self.assertEqual(len(project.requests[0].related_issues), 0) diff --git a/tests/test_pagure_flask_api_group.py b/tests/test_pagure_flask_api_group.py index 8b739ea..fd1c363 100644 --- a/tests/test_pagure_flask_api_group.py +++ b/tests/test_pagure_flask_api_group.py @@ -149,8 +149,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_authenticated(self): """ - Test the api_view_group method of the flask api with an - authenticated user. The tested group has one member. + Test the api_view_group method of the flask api with an + authenticated user. The tested group has one member. """ tests.create_tokens(self.session) @@ -180,8 +180,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_unauthenticated(self): """ - Test the api_view_group method of the flask api with an - unauthenticated user. The tested group has one member. + Test the api_view_group method of the flask api with an + unauthenticated user. The tested group has one member. """ output = self.app.get("/api/0/group/some_group") self.assertEqual(output.status_code, 200) @@ -206,8 +206,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_two_members_authenticated(self): """ - Test the api_view_group method of the flask api with an - authenticated user. The tested group has two members. + Test the api_view_group method of the flask api with an + authenticated user. The tested group has two members. """ user = pagure.lib.model.User( user="mprahl", @@ -257,8 +257,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_no_group_error(self): """ - Test the api_view_group method of the flask api - The tested group has one member. + Test the api_view_group method of the flask api + The tested group has one member. """ output = self.app.get("/api/0/group/some_group3") self.assertEqual(output.status_code, 404) @@ -268,8 +268,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_w_projects_and_acl(self): """ - Test the api_view_group method with project info and restricted - to the admin ACL + Test the api_view_group method with project info and restricted + to the admin ACL """ tests.create_tokens(self.session) @@ -381,8 +381,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_w_projects_and_acl_commit(self): """ - Test the api_view_group method with project info and restricted - to the commit ACL + Test the api_view_group method with project info and restricted + to the commit ACL """ output = self.app.get("/api/0/group/some_group?projects=1&acl=commit") @@ -471,8 +471,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_w_projects_and_acl_ticket(self): """ - Test the api_view_group method with project info and restricted - to the ticket ACL + Test the api_view_group method with project info and restricted + to the ticket ACL """ output = self.app.get("/api/0/group/some_group?projects=1&acl=ticket") @@ -561,8 +561,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_w_projects_and_acl_admin_no_project(self): """ - Test the api_view_group method with project info and restricted - to the admin ACL + Test the api_view_group method with project info and restricted + to the admin ACL """ # Make the group having only commit access @@ -615,8 +615,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_w_projects_and_acl_commit_no_project(self): """ - Test the api_view_group method with project info and restricted - to the commit ACL + Test the api_view_group method with project info and restricted + to the commit ACL """ # Make the group having only ticket access @@ -669,8 +669,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest): def test_api_view_group_w_projects_and_acl_ticket_no_project(self): """ - Test the api_view_group method with project info and restricted - to the ticket ACL + Test the api_view_group method with project info and restricted + to the ticket ACL """ # Create a group not linked to any project diff --git a/tests/test_pagure_flask_api_issue.py b/tests/test_pagure_flask_api_issue.py index 01be4b4..74d02eb 100644 --- a/tests/test_pagure_flask_api_issue.py +++ b/tests/test_pagure_flask_api_issue.py @@ -1937,7 +1937,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): ) def test_api_view_issues_reversed(self): - """ Test the api_view_issues method of the flask api. in reversed + """Test the api_view_issues method of the flask api. in reversed order. """ @@ -1983,7 +1983,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): self.assertDictEqual(data, expected) def test_api_view_issues_milestone(self): - """ Test the api_view_issues method of the flask api when filtering + """Test the api_view_issues method of the flask api when filtering for a milestone. """ tests.create_projects(self.session) @@ -2103,7 +2103,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): ) def test_api_view_issues_priority(self): - """ Test the api_view_issues method of the flask api when filtering + """Test the api_view_issues method of the flask api when filtering for a priority. """ tests.create_projects(self.session) @@ -2266,7 +2266,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): ) def test_api_view_issues_priority_invalid(self): - """ Test the api_view_issues method of the flask api when filtering + """Test the api_view_issues method of the flask api when filtering for an invalid priority. """ tests.create_projects(self.session) @@ -2289,7 +2289,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): ) def test_api_view_issues_no_stones(self): - """ Test the api_view_issues method of the flask api when filtering + """Test the api_view_issues method of the flask api when filtering with no_stones. """ tests.create_projects(self.session) @@ -4854,8 +4854,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): ) def test_api_view_user_issues_pingou(self): - """ Test the api_view_user_issues method of the flask api for pingou. - """ + """Test the api_view_user_issues method of the flask api for pingou.""" self.test_api_new_issue() # Create private issue @@ -4984,8 +4983,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): self.assertEqual(data["total_issues_created_pages"], 1) def test_api_view_user_issues_foo(self): - """ Test the api_view_user_issues method of the flask api for foo. - """ + """Test the api_view_user_issues method of the flask api for foo.""" self.test_api_new_issue() # Create private issue @@ -5030,8 +5028,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): self.assertEqual(data["total_issues_created_pages"], 1) def test_api_view_user_issues_foo_invalid_page(self): - """ Test the api_view_user_issues method of the flask api for foo. - """ + """Test the api_view_user_issues method of the flask api for foo.""" self.test_api_new_issue() output = self.app.get("/api/0/user/foo/issues?page=0") @@ -5059,8 +5056,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): ) def test_api_view_user_issues_foo_no_assignee(self): - """ Test the api_view_user_issues method of the flask api for foo. - """ + """Test the api_view_user_issues method of the flask api for foo.""" self.test_api_new_issue() output = self.app.get("/api/0/user/foo/issues?assignee=0") @@ -5091,8 +5087,7 @@ class PagureFlaskApiIssuetests(tests.SimplePagureTest): self.assertEqual(data["total_issues_created_pages"], 1) def test_api_view_user_issues_pingou_no_author(self): - """ Test the api_view_user_issues method of the flask api for pingou. - """ + """Test the api_view_user_issues method of the flask api for pingou.""" self.test_api_new_issue() output = self.app.get("/api/0/user/pingou/issues?author=0") diff --git a/tests/test_pagure_flask_api_issue_change_status.py b/tests/test_pagure_flask_api_issue_change_status.py index a15b337..d69f119 100644 --- a/tests/test_pagure_flask_api_issue_change_status.py +++ b/tests/test_pagure_flask_api_issue_change_status.py @@ -31,7 +31,7 @@ import tests class PagureFlaskApiIssueChangeStatustests(tests.Modeltests): - """ Tests for the flask API of pagure for changing the status of an + """Tests for the flask API of pagure for changing the status of an issue """ diff --git a/tests/test_pagure_flask_api_issue_comment.py b/tests/test_pagure_flask_api_issue_comment.py index 6c8f007..702a51e 100644 --- a/tests/test_pagure_flask_api_issue_comment.py +++ b/tests/test_pagure_flask_api_issue_comment.py @@ -28,7 +28,7 @@ import tests # noqa: E402 class PagureFlaskApiIssueCommenttests(tests.Modeltests): - """ Tests for the flask API of pagure for changing the status of an + """Tests for the flask API of pagure for changing the status of an issue """ diff --git a/tests/test_pagure_flask_api_issue_create.py b/tests/test_pagure_flask_api_issue_create.py index a13b5a1..0b4b279 100644 --- a/tests/test_pagure_flask_api_issue_create.py +++ b/tests/test_pagure_flask_api_issue_create.py @@ -27,8 +27,7 @@ import tests # noqa: E402 class PagureFlaskApiIssueCreatetests(tests.Modeltests): - """ Tests for the flask API of pagure for creating an issue - """ + """Tests for the flask API of pagure for creating an issue""" @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def setUp(self): @@ -67,7 +66,7 @@ class PagureFlaskApiIssueCreatetests(tests.Modeltests): tests.create_tokens_acl(self.session, token_id="project-specific-foo") def test_create_issue_own_project_no_data(self): - """ Test creating a new ticket on a project for which you're the + """Test creating a new ticket on a project for which you're the main maintainer. """ @@ -91,7 +90,7 @@ class PagureFlaskApiIssueCreatetests(tests.Modeltests): ) def test_create_issue_own_project_incomplete_data(self): - """ Test creating a new ticket on a project for which you're the + """Test creating a new ticket on a project for which you're the main maintainer. """ @@ -116,7 +115,7 @@ class PagureFlaskApiIssueCreatetests(tests.Modeltests): ) def test_create_issue_own_project(self): - """ Test creating a new ticket on a project for which you're the + """Test creating a new ticket on a project for which you're the main maintainer. """ @@ -174,7 +173,7 @@ class PagureFlaskApiIssueCreatetests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_create_issue_someone_else_project_project_less_token(self): - """ Test creating a new ticket on a project with which you have + """Test creating a new ticket on a project with which you have nothing to do. """ @@ -232,7 +231,7 @@ class PagureFlaskApiIssueCreatetests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_create_issue_project_specific_token(self): - """ Test creating a new ticket on a project with a regular + """Test creating a new ticket on a project with a regular project-specific token. """ @@ -290,7 +289,7 @@ class PagureFlaskApiIssueCreatetests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_create_issue_invalid_project_specific_token(self): - """ Test creating a new ticket on a project with a regular + """Test creating a new ticket on a project with a regular project-specific token but for another project. """ diff --git a/tests/test_pagure_flask_api_issue_custom_fields.py b/tests/test_pagure_flask_api_issue_custom_fields.py index a86892b..09a8ad7 100644 --- a/tests/test_pagure_flask_api_issue_custom_fields.py +++ b/tests/test_pagure_flask_api_issue_custom_fields.py @@ -51,7 +51,7 @@ class PagureFlaskApiCustomFieldIssuetests(tests.Modeltests): self.session.commit() def test_api_update_custom_field_bad_request(self): - """ Test the api_update_custom_field method of the flask api. + """Test the api_update_custom_field method of the flask api. This test that a badly form request returns the correct error. """ @@ -73,7 +73,7 @@ class PagureFlaskApiCustomFieldIssuetests(tests.Modeltests): ) def test_api_update_custom_field_wrong_field(self): - """ Test the api_update_custom_field method of the flask api. + """Test the api_update_custom_field method of the flask api. This test that an invalid field retruns the correct error. """ @@ -98,7 +98,7 @@ class PagureFlaskApiCustomFieldIssuetests(tests.Modeltests): MagicMock(side_effect=pagure.exceptions.PagureException("error")), ) def test_api_update_custom_field_raise_error(self): - """ Test the api_update_custom_field method of the flask api. + """Test the api_update_custom_field method of the flask api. This test the successful requests scenarii. """ @@ -132,7 +132,7 @@ class PagureFlaskApiCustomFieldIssuetests(tests.Modeltests): self.assertDictEqual(data, {"error": "error", "error_code": "ENOCODE"}) def test_api_update_custom_field(self): - """ Test the api_update_custom_field method of the flask api. + """Test the api_update_custom_field method of the flask api. This test the successful requests scenarii. """ diff --git a/tests/test_pagure_flask_api_plugins_install.py b/tests/test_pagure_flask_api_plugins_install.py index 96a12fe..4ab759d 100644 --- a/tests/test_pagure_flask_api_plugins_install.py +++ b/tests/test_pagure_flask_api_plugins_install.py @@ -27,8 +27,7 @@ import tests # noqa: E402 class PagureFlaskApiPluginInstalltests(tests.Modeltests): - """ Tests for the flask API of pagure for installing a plugin - """ + """Tests for the flask API of pagure for installing a plugin""" @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def setUp(self): @@ -64,7 +63,7 @@ class PagureFlaskApiPluginInstalltests(tests.Modeltests): tests.create_tokens_acl(self.session, token_id="project-specific-foo") def test_install_plugin_own_project_no_data(self): - """ Test installing a new plugin on a project for which you're the + """Test installing a new plugin on a project for which you're the main maintainer. """ @@ -86,7 +85,7 @@ class PagureFlaskApiPluginInstalltests(tests.Modeltests): ) def test_install_plugin_own_project(self): - """ Test installing a new plugin on a project for which you're the + """Test installing a new plugin on a project for which you're the main maintainer. """ @@ -112,7 +111,7 @@ class PagureFlaskApiPluginInstalltests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_install_plugin_someone_else_project_project_less_token(self): - """ Test installing a new plugin on a project with which you have + """Test installing a new plugin on a project with which you have nothing to do. """ @@ -138,7 +137,7 @@ class PagureFlaskApiPluginInstalltests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_install_plugin_project_specific_token(self): - """ Test installing a new plugin on a project with a regular + """Test installing a new plugin on a project with a regular project-specific token. """ @@ -164,7 +163,7 @@ class PagureFlaskApiPluginInstalltests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_install_plugin_invalid_project_specific_token(self): - """ Test installing a new plugin on a project with a regular + """Test installing a new plugin on a project with a regular project-specific token but for another project. """ diff --git a/tests/test_pagure_flask_api_plugins_remove.py b/tests/test_pagure_flask_api_plugins_remove.py index 4f3a141..1bd990d 100644 --- a/tests/test_pagure_flask_api_plugins_remove.py +++ b/tests/test_pagure_flask_api_plugins_remove.py @@ -28,8 +28,7 @@ import tests # noqa: E402 class PagureFlaskApiPluginRemovetests(tests.Modeltests): - """ Tests for the flask API of pagure for removing a plugin - """ + """Tests for the flask API of pagure for removing a plugin""" @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def setUp(self): @@ -77,7 +76,7 @@ class PagureFlaskApiPluginRemovetests(tests.Modeltests): tests.create_tokens_acl(self.session, token_id="project-specific-foo") def test_remove_plugin_own_project_plugin_not_installed(self): - """ Test removing a plugin from a project for which you're the + """Test removing a plugin from a project for which you're the main maintainer and the plugin is not installed. """ @@ -98,7 +97,7 @@ class PagureFlaskApiPluginRemovetests(tests.Modeltests): ) def test_remove_plugin_own_project(self): - """ Test removing a plugin from a project for which you're the + """Test removing a plugin from a project for which you're the main maintainer. """ @@ -121,7 +120,7 @@ class PagureFlaskApiPluginRemovetests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_remove_plugin_someone_else_project_project_less_token(self): - """ Test removing a plugin from a project with which you have + """Test removing a plugin from a project with which you have nothing to do. """ @@ -144,7 +143,7 @@ class PagureFlaskApiPluginRemovetests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_remove_plugin_project_specific_token(self): - """ Test removing a plugin from a project with a regular + """Test removing a plugin from a project with a regular project-specific token. """ @@ -167,7 +166,7 @@ class PagureFlaskApiPluginRemovetests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_remove_plugin_invalid_project_specific_token(self): - """ Test removing a plugin from a project with a regular + """Test removing a plugin from a project with a regular project-specific token but for another project. """ diff --git a/tests/test_pagure_flask_api_plugins_view.py b/tests/test_pagure_flask_api_plugins_view.py index 8cdf91a..00466e1 100644 --- a/tests/test_pagure_flask_api_plugins_view.py +++ b/tests/test_pagure_flask_api_plugins_view.py @@ -25,12 +25,10 @@ import tests # noqa: E402 class PagureFlaskApiPluginViewtests(tests.Modeltests): - """ Tests for the flask API of pagure for viewing plugins - """ + """Tests for the flask API of pagure for viewing plugins""" def test_view_plugin(self): - """ Test viewing every plugin available in pagure. - """ + """Test viewing every plugin available in pagure.""" output = self.app.get("/api/0/_plugins") self.assertEqual(output.status_code, 200) @@ -76,8 +74,7 @@ class PagureFlaskApiPluginViewtests(tests.Modeltests): @patch.dict("pagure.config.config", {"DISABLED_PLUGINS": ["IRC"]}) def test_view_plugin_disabled(self): - """ Test viewing every plugin available in pagure with one plugin disabled. - """ + """Test viewing every plugin available in pagure with one plugin disabled.""" output = self.app.get("/api/0/_plugins") self.assertEqual(output.status_code, 200) diff --git a/tests/test_pagure_flask_api_plugins_view_project.py b/tests/test_pagure_flask_api_plugins_view_project.py index 09d887e..1207e0f 100644 --- a/tests/test_pagure_flask_api_plugins_view_project.py +++ b/tests/test_pagure_flask_api_plugins_view_project.py @@ -27,8 +27,7 @@ import tests # noqa: E402 class PagureFlaskApiPluginViewProjecttests(tests.Modeltests): - """ Tests for the flask API of pagure for viewing enabled plugins on project - """ + """Tests for the flask API of pagure for viewing enabled plugins on project""" @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def setUp(self): @@ -38,8 +37,7 @@ class PagureFlaskApiPluginViewProjecttests(tests.Modeltests): tests.create_projects(self.session) def test_view_plugin_on_project(self): - """ Test viewing plugins on a project. - """ + """Test viewing plugins on a project.""" # Install plugin repo = pagure.lib.query.get_authorized_project(self.session, "test") @@ -66,7 +64,7 @@ class PagureFlaskApiPluginViewProjecttests(tests.Modeltests): ) def test_viewing_plugin_on_project_no_plugin(self): - """ Test viewing plugins on a project, which doesn't + """Test viewing plugins on a project, which doesn't have any installed. """ diff --git a/tests/test_pagure_flask_api_pr_flag.py b/tests/test_pagure_flask_api_pr_flag.py index 5d6c2e5..4dfc20a 100644 --- a/tests/test_pagure_flask_api_pr_flag.py +++ b/tests/test_pagure_flask_api_pr_flag.py @@ -908,7 +908,7 @@ class PagureFlaskApiPRFlagtests(tests.Modeltests): class PagureFlaskApiPRFlagUserTokentests(tests.Modeltests): - """ Tests for the flask API of pagure for flagging pull-requests using + """Tests for the flask API of pagure for flagging pull-requests using an user token (ie: not restricted to a specific project). """ @@ -1004,8 +1004,7 @@ class PagureFlaskApiPRFlagUserTokentests(tests.Modeltests): ) def test_no_comment(self): - """ Test flagging an existing PR but without all the required info. - """ + """Test flagging an existing PR but without all the required info.""" headers = {"Authorization": "token aaabbbcccddd"} data = { @@ -1038,8 +1037,7 @@ class PagureFlaskApiPRFlagUserTokentests(tests.Modeltests): self.assertEqual(len(request.flags), 0) def test_invalid_status(self): - """ Test flagging an existing PR but with an invalid status. - """ + """Test flagging an existing PR but with an invalid status.""" headers = {"Authorization": "token aaabbbcccddd"} data = { @@ -1074,7 +1072,7 @@ class PagureFlaskApiPRFlagUserTokentests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_flag_pr_no_status(self, mock_email): - """ Test flagging an existing PR without providing a status. + """Test flagging an existing PR without providing a status. Also check that no notifications have been sent. """ @@ -1143,8 +1141,7 @@ class PagureFlaskApiPRFlagUserTokentests(tests.Modeltests): mock_email.assert_not_called() def test_editing_flag(self): - """ Test flagging an existing PR without providing a status. - """ + """Test flagging an existing PR without providing a status.""" headers = {"Authorization": "token aaabbbcccddd"} data = { @@ -1268,8 +1265,7 @@ class PagureFlaskApiPRFlagUserTokentests(tests.Modeltests): class PagureFlaskApiGetPRFlagtests(tests.Modeltests): - """ Tests for the flask API of pagure for retrieving pull-requests flags - """ + """Tests for the flask API of pagure for retrieving pull-requests flags""" maxDiff = None diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index 3c60b0f..b795e52 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -122,7 +122,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): shutil.rmtree(newpath) def test_api_git_branches_no_repo(self): - """ Test the api_git_branches method of the flask api when there is no + """Test the api_git_branches method of the flask api when there is no repo on a project. """ tests.create_projects(self.session) @@ -130,8 +130,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertEqual(output.status_code, 404) def test_api_git_urls(self): - """ Test the api_project_git_urls method of the flask api. - """ + """Test the api_project_git_urls method of the flask api.""" tests.create_projects(self.session) output = self.app.get("/api/0/test/git/urls") self.assertEqual(output.status_code, 200) @@ -146,7 +145,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertDictEqual(data, expected_rv) def test_api_git_urls_no_project(self): - """ Test the api_project_git_urls method of the flask api when there is + """Test the api_project_git_urls method of the flask api when there is no project. """ output = self.app.get("/api/0/test1234/git/urls") @@ -160,7 +159,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_api_git_urls_private_project(self): - """ Test the api_project_git_urls method of the flask api when the + """Test the api_project_git_urls method of the flask api when the project is private. """ tests.create_projects(self.session) @@ -187,7 +186,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_api_git_urls_private_project_no_login(self): - """ Test the api_project_git_urls method of the flask api when the + """Test the api_project_git_urls method of the flask api when the project is private and the user is not logged in. """ tests.create_projects(self.session) @@ -1202,7 +1201,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertDictEqual(data, expected_data) def test_api_project_group_but_no_group(self): - """ Test the api_project method of the flask api when asking for + """Test the api_project method of the flask api when asking for group details while there are none associated. """ tests.create_projects(self.session) @@ -1438,8 +1437,8 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertDictEqual(data, expected_data) def test_api_projects_pagination_per_page(self): - """ Test the api_projects method of the flask api with pagination and - the `per_page` argument set. """ + """Test the api_projects method of the flask api with pagination and + the `per_page` argument set.""" tests.create_projects(self.session) output = self.app.get("/api/0/projects?page=2&per_page=2") @@ -1520,24 +1519,24 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertDictEqual(data, expected_data) def test_api_projects_pagination_invalid_page(self): - """ Test the api_projects method of the flask api when an invalid page - value is entered. """ + """Test the api_projects method of the flask api when an invalid page + value is entered.""" tests.create_projects(self.session) output = self.app.get("/api/0/projects?page=-3") self.assertEqual(output.status_code, 400) def test_api_projects_pagination_invalid_page_str(self): - """ Test the api_projects method of the flask api when an invalid type - for the page value is entered. """ + """Test the api_projects method of the flask api when an invalid type + for the page value is entered.""" tests.create_projects(self.session) output = self.app.get("/api/0/projects?page=abcd") self.assertEqual(output.status_code, 400) def test_api_projects_pagination_invalid_per_page_too_low(self): - """ Test the api_projects method of the flask api when a per_page - value is below 1. """ + """Test the api_projects method of the flask api when a per_page + value is below 1.""" tests.create_projects(self.session) output = self.app.get("/api/0/projects?page=1&per_page=0") @@ -1548,8 +1547,8 @@ class PagureFlaskApiProjecttests(tests.Modeltests): ) def test_api_projects_pagination_invalid_per_page_too_high(self): - """ Test the api_projects method of the flask api when a per_page - value is above 100. """ + """Test the api_projects method of the flask api when a per_page + value is above 100.""" tests.create_projects(self.session) output = self.app.get("/api/0/projects?page=1&per_page=101") @@ -1560,16 +1559,16 @@ class PagureFlaskApiProjecttests(tests.Modeltests): ) def test_api_projects_pagination_invalid_per_page_str(self): - """ Test the api_projects method of the flask api when an invalid type - for the per_page value is entered. """ + """Test the api_projects method of the flask api when an invalid type + for the per_page value is entered.""" tests.create_projects(self.session) output = self.app.get("/api/0/projects?page=1&per_page=abcd") self.assertEqual(output.status_code, 400) def test_api_projects_pagination_beyond_last_page(self): - """ Test the api_projects method of the flask api when a page value - that is larger than the last page is entered. """ + """Test the api_projects method of the flask api when a page value + that is larger than the last page is entered.""" tests.create_projects(self.session) output = self.app.get("/api/0/projects?page=99999") @@ -1613,8 +1612,8 @@ class PagureFlaskApiProjecttests(tests.Modeltests): ) def test_api_modify_project_main_admin(self): - """ Test the api_modify_project method of the flask api when the - request is to change the main_admin of the project. """ + """Test the api_modify_project method of the flask api when the + request is to change the main_admin of the project.""" tests.create_projects(self.session) tests.create_tokens(self.session, project_id=None) tests.create_tokens_acl(self.session, "aaabbbcccddd", "modify_project") @@ -1673,9 +1672,9 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_project_main_admin_retain_access(self): - """ Test the api_modify_project method of the flask api when the + """Test the api_modify_project method of the flask api when the request is to change the main_admin of the project and retain_access - is true. """ + is true.""" tests.create_projects(self.session) tests.create_tokens(self.session, project_id=None) tests.create_tokens_acl(self.session, "aaabbbcccddd", "modify_project") @@ -1736,9 +1735,9 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_project_main_admin_retain_access_already_user(self): - """ Test the api_modify_project method of the flask api when the + """Test the api_modify_project method of the flask api when the request is to change the main_admin of the project and retain_access - is true and the user becoming the main_admin already has access. """ + is true and the user becoming the main_admin already has access.""" tests.create_projects(self.session) tests.create_tokens(self.session, project_id=None) tests.create_tokens_acl(self.session, "aaabbbcccddd", "modify_project") @@ -1809,8 +1808,8 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_project_main_admin_json(self): - """ Test the api_modify_project method of the flask api when the - request is to change the main_admin of the project using JSON. """ + """Test the api_modify_project method of the flask api when the + request is to change the main_admin of the project using JSON.""" tests.create_projects(self.session) tests.create_tokens(self.session, project_id=None) tests.create_tokens_acl(self.session, "aaabbbcccddd", "modify_project") @@ -1875,9 +1874,9 @@ class PagureFlaskApiProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"PAGURE_ADMIN_USERS": "foo"}) def test_api_modify_project_main_admin_as_site_admin(self): - """ Test the api_modify_project method of the flask api when the + """Test the api_modify_project method of the flask api when the request is to change the main_admin of the project and the user is a - Pagure site admin. """ + Pagure site admin.""" tests.create_projects(self.session) tests.create_tokens(self.session, user_id=2, project_id=None) tests.create_tokens_acl(self.session, "aaabbbcccddd", "modify_project") @@ -1946,7 +1945,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertNotEqual(date_before, project.date_modified) def test_api_modify_project_main_admin_not_main_admin(self): - """ Test the api_modify_project method of the flask api when the + """Test the api_modify_project method of the flask api when the requester is not the main_admin of the project and requests to change the main_admin. """ @@ -1975,7 +1974,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): ) def test_api_modify_project_not_admin(self): - """ Test the api_modify_project method of the flask api when the + """Test the api_modify_project method of the flask api when the requester is not an admin of the project. """ tests.create_projects(self.session) @@ -1996,7 +1995,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): ) def test_api_modify_project_invalid_request(self): - """ Test the api_modify_project method of the flask api when the + """Test the api_modify_project method of the flask api when the request data is invalid. """ tests.create_projects(self.session) @@ -2015,7 +2014,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): ) def test_api_modify_project_invalid_keys(self): - """ Test the api_modify_project method of the flask api when the + """Test the api_modify_project method of the flask api when the request data contains an invalid key. """ tests.create_projects(self.session) @@ -2036,7 +2035,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): ) def test_api_modify_project_invalid_new_main_admin(self): - """ Test the api_modify_project method of the flask api when the + """Test the api_modify_project method of the flask api when the request is to change the main_admin of the project to a main_admin that doesn't exist. """ @@ -2579,8 +2578,8 @@ class PagureFlaskApiProjecttests(tests.Modeltests): ) def test_api_generate_acls_wait_true(self): - """ Test the api_generate_acls method of the flask api when wait is - set to True """ + """Test the api_generate_acls method of the flask api when wait is + set to True""" tests.create_projects(self.session) tests.create_tokens(self.session, project_id=None) tests.create_tokens_acl( @@ -2608,8 +2607,8 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertTrue(task_result.get.called) def test_api_generate_acls_no_project(self): - """ Test the api_generate_acls method of the flask api when the project - doesn't exist """ + """Test the api_generate_acls method of the flask api when the project + doesn't exist""" tests.create_projects(self.session) tests.create_tokens(self.session, project_id=None) tests.create_tokens_acl( @@ -2700,8 +2699,8 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertIn("test123", repo_obj.listall_branches()) def test_api_new_git_branch_already_exists(self): - """ Test the api_new_branch method of the flask api when branch already - exists """ + """Test the api_new_branch method of the flask api when branch already + exists""" tests.create_projects(self.session) repo_path = os.path.join(self.path, "repos") tests.create_projects_git(repo_path, bare=True) @@ -2745,8 +2744,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): class PagureFlaskApiProjectFlagtests(tests.Modeltests): - """ Tests for the flask API of pagure for flagging commit in project - """ + """Tests for the flask API of pagure for flagging commit in project""" def setUp(self): """ Set up the environnment, ran before every tests. """ @@ -3201,7 +3199,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_flag_commit_without_uid(self, mock_email): - """ Test flagging a commit with missing info. + """Test flagging a commit with missing info. Also ensure notifications aren't sent when they are not asked for. """ @@ -3340,8 +3338,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): }, ) def test_flag_commit_with_custom_flags(self): - """ Test flagging when custom flags are set up - """ + """Test flagging when custom flags are set up""" repo_obj = pygit2.Repository(self.git_path) commit = repo_obj.revparse_single("HEAD") @@ -3473,8 +3470,7 @@ class PagureFlaskApiProjectFlagtests(tests.Modeltests): class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): - """ Tests for the flask API of pagure for modifying ACLs in a project - """ + """Tests for the flask API of pagure for modifying ACLs in a project""" maxDiff = None @@ -3492,8 +3488,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): ) def test_api_modify_acls_no_project(self): - """ Test the api_modify_acls method of the flask api when the project - doesn't exist """ + """Test the api_modify_acls method of the flask api when the project + doesn't exist""" headers = {"Authorization": "token aaabbbcccddd"} data = {"user_type": "user", "name": "bar", "acl": "commit"} @@ -3509,8 +3505,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_no_user(self): - """ Test the api_modify_acls method of the flask api when the user - doesn't exist """ + """Test the api_modify_acls method of the flask api when the user + doesn't exist""" headers = {"Authorization": "token aaabbbcccddd"} data = {"user_type": "user", "name": "nosuchuser", "acl": "commit"} @@ -3526,8 +3522,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_no_group(self): - """ Test the api_modify_acls method of the flask api when the group - doesn't exist """ + """Test the api_modify_acls method of the flask api when the group + doesn't exist""" headers = {"Authorization": "token aaabbbcccddd"} data = {"user_type": "group", "name": "nosuchgroup", "acl": "commit"} @@ -3543,8 +3539,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_no_permission(self): - """ Test the api_modify_acls method of the flask api when the user - doesn't have permissions """ + """Test the api_modify_acls method of the flask api when the user + doesn't have permissions""" item = pagure.lib.model.Token( id="foo_token2", user_id=2, @@ -3571,8 +3567,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_neither_user_nor_group(self): - """ Test the api_modify_acls method of the flask api when neither - user nor group was set """ + """Test the api_modify_acls method of the flask api when neither + user nor group was set""" headers = {"Authorization": "token aaabbbcccddd"} data = {"acl": "commit"} @@ -3596,8 +3592,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_invalid_acl(self): - """ Test the api_modify_acls method of the flask api when the ACL - doesn't exist. Must be one of ticket, commit or admin. """ + """Test the api_modify_acls method of the flask api when the ACL + doesn't exist. Must be one of ticket, commit or admin.""" headers = {"Authorization": "token aaabbbcccddd"} data = {"user_type": "user", "name": "bar", "acl": "invalidacl"} @@ -3614,8 +3610,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_user(self): - """ Test the api_modify_acls method of the flask api for - setting an ACL for a user. """ + """Test the api_modify_acls method of the flask api for + setting an ACL for a user.""" headers = {"Authorization": "token aaabbbcccddd"} data = {"user_type": "user", "name": "foo", "acl": "commit"} @@ -3671,8 +3667,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_group(self): - """ Test the api_modify_acls method of the flask api for - setting an ACL for a group. """ + """Test the api_modify_acls method of the flask api for + setting an ACL for a group.""" headers = {"Authorization": "token aaabbbcccddd"} # Create a group @@ -3743,8 +3739,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_no_acl(self): - """ Test the api_modify_acls method of the flask api when no ACL - are specified. """ + """Test the api_modify_acls method of the flask api when no ACL + are specified.""" headers = {"Authorization": "token aaabbbcccddd"} project = pagure.lib.query._get_project(self.session, "test") @@ -3768,9 +3764,9 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_remove_own_acl_no_access(self): - """ Test the api_modify_acls method of the flask api when no ACL + """Test the api_modify_acls method of the flask api when no ACL are specified, so the user tries to remove their own access but the - user is the project owner. """ + user is the project owner.""" headers = {"Authorization": "token aaabbbcccddd"} data = {"user_type": "user", "name": "pingou"} @@ -3788,9 +3784,9 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): self.assertEqual(data, expected_output) def test_api_modify_acls_remove_own_acl_(self): - """ Test the api_modify_acls method of the flask api when no ACL + """Test the api_modify_acls method of the flask api when no ACL are specified, so the user tries to remove their own access but the - user is the project owner. """ + user is the project owner.""" # Add the user `foo` to the project self.test_api_modify_acls_user() @@ -3885,8 +3881,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): ) def test_api_modify_acls_remove_someone_else_acl(self): - """ Test the api_modify_acls method of the flask api an admin tries - to remove access from someone else. """ + """Test the api_modify_acls method of the flask api an admin tries + to remove access from someone else.""" # Add the user `foo` to the project self.test_api_modify_acls_user() @@ -3966,8 +3962,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): ) def test_api_modify_acls_add_remove_group(self): - """ Test the api_modify_acls method of the flask api for - setting an ACL for a group. """ + """Test the api_modify_acls method of the flask api for + setting an ACL for a group.""" headers = {"Authorization": "token aaabbbcccddd"} # Create a group @@ -4118,8 +4114,8 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): ) def test_api_modify_acls_remove_group_not_in_project(self): - """ Test the api_modify_acls method of the flask api for - setting an ACL for a group. """ + """Test the api_modify_acls method of the flask api for + setting an ACL for a group.""" headers = {"Authorization": "token aaabbbcccddd"} # Create a group @@ -4204,8 +4200,7 @@ class PagureFlaskApiProjectModifyAclTests(tests.Modeltests): class PagureFlaskApiProjectOptionsTests(tests.Modeltests): - """ Tests for the flask API of pagure for modifying options ofs a project - """ + """Tests for the flask API of pagure for modifying options ofs a project""" maxDiff = None @@ -4285,8 +4280,7 @@ class PagureFlaskApiProjectOptionsTests(tests.Modeltests): ) def test_api_modify_project_options_wrong_project(self): - """ Test accessing api_modify_project_options w/ an invalid project. - """ + """Test accessing api_modify_project_options w/ an invalid project.""" headers = {"Authorization": "token aaabbbcccddd"} output = self.app.post( @@ -4487,8 +4481,8 @@ class PagureFlaskApiProjectOptionsTests(tests.Modeltests): self.assertEqual(after, before) def test_api_modify_project_options_json(self): - """ Test accessing api_modify_project_options w/ auth header and - input submitted as JSON instead of HTML arguments. """ + """Test accessing api_modify_project_options w/ auth header and + input submitted as JSON instead of HTML arguments.""" # check before headers = {"Authorization": "token aaabbbcccddd"} @@ -4549,8 +4543,7 @@ class PagureFlaskApiProjectOptionsTests(tests.Modeltests): class PagureFlaskApiProjectCreateAPITokenTests(tests.Modeltests): - """ Tests for the flask API of pagure for creating user project API token - """ + """Tests for the flask API of pagure for creating user project API token""" maxDiff = None @@ -4639,7 +4632,7 @@ class PagureFlaskApiProjectCreateAPITokenTests(tests.Modeltests): ) def test_api_createapitoken_as_unauthorized(self): - """ Test accessing api_project_create_token as project admin + """Test accessing api_project_create_token as project admin but with unauthorized token ACL. """ @@ -4683,7 +4676,7 @@ class PagureFlaskApiProjectCreateAPITokenTests(tests.Modeltests): self.assertEqual(output.status_code, 401) def test_api_createapitoken_as_unauthorized_2(self): - """ Test accessing api_project_create_token as project user + """Test accessing api_project_create_token as project user with unauthorized token ACL. """ @@ -4728,8 +4721,7 @@ class PagureFlaskApiProjectCreateAPITokenTests(tests.Modeltests): class PagureFlaskApiProjectConnectorTests(tests.Modeltests): - """ Tests for the flask API of pagure for getting connector of a project - """ + """Tests for the flask API of pagure for getting connector of a project""" maxDiff = None @@ -4848,7 +4840,7 @@ class PagureFlaskApiProjectConnectorTests(tests.Modeltests): ) def test_api_get_project_connector_as_unauthorized(self): - """ Test accessing api_get_project_connector as project admin + """Test accessing api_get_project_connector as project admin but with unauthorized token ACL """ @@ -4883,7 +4875,7 @@ class PagureFlaskApiProjectConnectorTests(tests.Modeltests): self.assertEqual(output.status_code, 401) def test_api_get_project_connector_as_unauthorized_2(self): - """ Test accessing api_get_project_connector as project + """Test accessing api_get_project_connector as project but with unauthorized token ACL """ @@ -4919,8 +4911,7 @@ class PagureFlaskApiProjectConnectorTests(tests.Modeltests): class PagureFlaskApiProjectWebhookTokenTests(tests.Modeltests): - """ Tests for the flask API of pagure for getting webhook token of a project - """ + """Tests for the flask API of pagure for getting webhook token of a project""" maxDiff = None @@ -4998,8 +4989,7 @@ class PagureFlaskApiProjectWebhookTokenTests(tests.Modeltests): class PagureFlaskApiProjectCommitInfotests(tests.Modeltests): - """ Tests for the flask API of pagure for commit info - """ + """Tests for the flask API of pagure for commit info""" def setUp(self): """ Set up the environnment, ran before every tests. """ @@ -5059,8 +5049,7 @@ class PagureFlaskApiProjectCommitInfotests(tests.Modeltests): class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): - """ Tests for the flask API of pagure for git branches - """ + """Tests for the flask API of pagure for git branches""" maxDiff = None @@ -5123,13 +5112,15 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): "pats-win-49": self.commit.hex, "pats-win-51": self.commit.hex, }, - "default": {"master": self.commit.hex,}, + "default": { + "master": self.commit.hex, + }, "total_branches": 3, }, ) def test_api_git_branches_empty_repo(self): - """ Test the api_git_branches method of the flask api when the repo is + """Test the api_git_branches method of the flask api when the repo is empty. """ # Check that no branches show up on the API @@ -5175,7 +5166,9 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): "pats-win-49": self.commit.hex, "pats-win-51": self.commit.hex, }, - "default": {"pats-win-49": self.commit.hex,}, + "default": { + "pats-win-49": self.commit.hex, + }, "total_branches": 3, }, ) @@ -5199,7 +5192,9 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): "pats-win-49": self.commit.hex, "pats-win-51": self.commit.hex, }, - "default": {"pats-win-49": self.commit.hex,}, + "default": { + "pats-win-49": self.commit.hex, + }, "total_branches": 3, }, ) @@ -5228,7 +5223,9 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): headers = {"Authorization": "token aaabbbcccddd"} data = {"branch_name": "main"} output = self.app.post( - "/api/0/test/git/branches", data=data, headers=headers, + "/api/0/test/git/branches", + data=data, + headers=headers, ) self.assertEqual(output.status_code, 401) data = json.loads(output.get_data(as_text=True)) @@ -5244,7 +5241,7 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): ) def test_api_set_git_default_branch_empty_repo(self): - """ Test the api_git_branches method of the flask api when the repo is + """Test the api_git_branches method of the flask api when the repo is empty. """ headers = {"Authorization": "token foo_token"} @@ -5264,8 +5261,7 @@ class PagureFlaskApiProjectGitBranchestests(tests.Modeltests): class PagureFlaskApiProjectCreateProjectTests(tests.Modeltests): - """ Tests for the flask API of pagure for git branches - """ + """Tests for the flask API of pagure for git branches""" maxDiff = None @@ -5561,8 +5557,8 @@ class PagureFlaskApiProjectCreateProjectTests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_api_new_project_private(self): - """ Test the api_new_project method of the flask api to create - a private project. """ + """Test the api_new_project method of the flask api to create + a private project.""" headers = {"Authorization": "token aaabbbcccddd"} diff --git a/tests/test_pagure_flask_api_project_blockuser.py b/tests/test_pagure_flask_api_project_blockuser.py index 10ecb91..45bdabe 100644 --- a/tests/test_pagure_flask_api_project_blockuser.py +++ b/tests/test_pagure_flask_api_project_blockuser.py @@ -79,8 +79,7 @@ class PagureFlaskApiProjectBlockuserTests(tests.SimplePagureTest): super(PagureFlaskApiProjectBlockuserTests, self).tearDown() def test_api_blockuser_no_token(self): - """ Test api_project_block_user method when no token is provided. - """ + """Test api_project_block_user method when no token is provided.""" # No token output = self.app.post("/api/0/test/blockuser") @@ -98,8 +97,7 @@ class PagureFlaskApiProjectBlockuserTests(tests.SimplePagureTest): ) def test_api_blockuser_invalid_token(self): - """ Test api_project_block_user method when the token provided is invalid. - """ + """Test api_project_block_user method when the token provided is invalid.""" headers = {"Authorization": "token aaabbbcccd"} @@ -119,8 +117,7 @@ class PagureFlaskApiProjectBlockuserTests(tests.SimplePagureTest): ) def test_api_blockuser_no_data(self): - """ Test api_project_block_user method when no data is provided. - """ + """Test api_project_block_user method when no data is provided.""" headers = {"Authorization": "token aaabbbcccddd"} @@ -131,7 +128,7 @@ class PagureFlaskApiProjectBlockuserTests(tests.SimplePagureTest): self.assertDictEqual(data, {"message": "User(s) blocked"}) def test_api_blockuser_invalid_user(self): - """ Test api_project_block_user method when the data provided includes + """Test api_project_block_user method when the data provided includes an invalid username. """ @@ -149,7 +146,7 @@ class PagureFlaskApiProjectBlockuserTests(tests.SimplePagureTest): ) def test_api_blockuser_insufficient_rights(self): - """ Test api_project_block_user method when the user doing the action + """Test api_project_block_user method when the user doing the action does not have admin priviledges. """ @@ -172,8 +169,7 @@ class PagureFlaskApiProjectBlockuserTests(tests.SimplePagureTest): ) def test_api_blockuser_with_data(self): - """ Test api_pull_request_assign method when the project doesn't exist. - """ + """Test api_pull_request_assign method when the project doesn't exist.""" self.blocked_users = ["foo"] headers = {"Authorization": "token aaabbbcccddd"} @@ -199,8 +195,7 @@ class PagureFlaskApiProjectBlockuserTests(tests.SimplePagureTest): self.assertDictEqual(data, {"message": "User(s) blocked"}) def test_api_blockeduser_api(self): - """ Test doing a POST request to the API when the user is blocked. - """ + """Test doing a POST request to the API when the user is blocked.""" self.blocked_users = ["pingou"] headers = {"Authorization": "token aaabbbcccddd"} @@ -232,8 +227,7 @@ class PagureFlaskApiProjectBlockuserTests(tests.SimplePagureTest): ) def test_ui_new_issue_user_blocked(self): - """ Test doing a POST request to the UI when the user is blocked. - """ + """Test doing a POST request to the UI when the user is blocked.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): diff --git a/tests/test_pagure_flask_api_project_contributors.py b/tests/test_pagure_flask_api_project_contributors.py index ed1762d..c40154f 100644 --- a/tests/test_pagure_flask_api_project_contributors.py +++ b/tests/test_pagure_flask_api_project_contributors.py @@ -34,8 +34,7 @@ import tests class PagureFlaskApiProjectContributorsTests(tests.SimplePagureTest): - """ Tests for the flask API of pagure for listing contributors of a project - """ + """Tests for the flask API of pagure for listing contributors of a project""" maxDiff = None diff --git a/tests/test_pagure_flask_api_project_update_watch.py b/tests/test_pagure_flask_api_project_update_watch.py index d69616d..f699e62 100644 --- a/tests/test_pagure_flask_api_project_update_watch.py +++ b/tests/test_pagure_flask_api_project_update_watch.py @@ -30,7 +30,7 @@ import tests class PagureFlaskApiProjectUpdateWatchTests(tests.Modeltests): - """ Tests for the flask API of pagure for changing the watch status on + """Tests for the flask API of pagure for changing the watch status on a project via the API """ @@ -268,7 +268,8 @@ class PagureFlaskApiProjectUpdateWatchTests(tests.Modeltests): self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( - data, {"message": "Watch status reset", "status": "ok"}, + data, + {"message": "Watch status reset", "status": "ok"}, ) @patch("pagure.utils.is_admin", MagicMock(return_value=True)) diff --git a/tests/test_pagure_flask_api_ui_private_repo.py b/tests/test_pagure_flask_api_ui_private_repo.py index 7ea787d..e5669ee 100644 --- a/tests/test_pagure_flask_api_ui_private_repo.py +++ b/tests/test_pagure_flask_api_ui_private_repo.py @@ -266,7 +266,7 @@ class PagurePrivateRepotest(tests.Modeltests): def set_up_git_repo( self, new_project=None, branch_from="feature", mtype="FF" ): - """ Set up the git repo and create the corresponding PullRequest + """Set up the git repo and create the corresponding PullRequest object. """ diff --git a/tests/test_pagure_flask_api_user.py b/tests/test_pagure_flask_api_user.py index e62e6eb..27bd122 100644 --- a/tests/test_pagure_flask_api_user.py +++ b/tests/test_pagure_flask_api_user.py @@ -65,8 +65,8 @@ class PagureFlaskApiUSertests(tests.Modeltests): def test_api_view_user(self): """ - Test the api_view_user method of the flask api - The tested user has no project or forks. + Test the api_view_user method of the flask api + The tested user has no project or forks. """ output = self.app.get("/api/0/user/pingou") self.assertEqual(output.status_code, 200) @@ -109,8 +109,8 @@ class PagureFlaskApiUSertests(tests.Modeltests): def test_api_view_user_with_project(self): """ - Test the api_view_user method of the flask api, - this time the user has some project defined. + Test the api_view_user method of the flask api, + this time the user has some project defined. """ tests.create_projects(self.session) @@ -285,8 +285,8 @@ class PagureFlaskApiUSertests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_activity_stats(self, mockemail): - """ Test the api_view_user_activity_stats method of the flask user - api. """ + """Test the api_view_user_activity_stats method of the flask user + api.""" mockemail.return_value = True tests.create_projects(self.session) @@ -359,8 +359,8 @@ class PagureFlaskApiUSertests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_activity_date(self, mockemail): - """ Test the api_view_user_activity_date method of the flask user - api. """ + """Test the api_view_user_activity_date method of the flask user + api.""" self.test_api_view_user_activity_stats() @@ -490,8 +490,8 @@ class PagureFlaskApiUSertests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_activity_date_1_activity(self, mockemail): - """ Test the api_view_user_activity_date method of the flask user - api when the user only did one action. """ + """Test the api_view_user_activity_date method of the flask user + api when the user only did one action.""" tests.create_projects(self.session) repo = pagure.lib.query._get_project(self.session, "test") @@ -959,8 +959,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_filed(self, mockemail): - """ Test the api_view_user_requests_filed method of the flask user - api """ + """Test the api_view_user_requests_filed method of the flask user + api""" # First we test without the status parameter. It should default to `open` output = self.app.get("/api/0/user/pingou/requests/filed") @@ -1131,8 +1131,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_filed_created(self, mockemail): - """ Test the api_view_user_requests_filed method of the flask user - api with the created parameter """ + """Test the api_view_user_requests_filed method of the flask user + api with the created parameter""" today = datetime.datetime.utcnow().date() output = self.app.get( @@ -1204,8 +1204,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_filed_updated(self, mockemail): - """ Test the api_view_user_requests_filed method of the flask user - api with the created parameter """ + """Test the api_view_user_requests_filed method of the flask user + api with the created parameter""" today = datetime.datetime.utcnow().date() output = self.app.get( @@ -1236,8 +1236,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_filed_closed(self, mockemail): - """ Test the api_view_user_requests_filed method of the flask user - api with the created parameter """ + """Test the api_view_user_requests_filed method of the flask user + api with the created parameter""" today = datetime.datetime.utcnow().date() output = self.app.get( @@ -1268,8 +1268,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_filed_foo(self, mockemail): - """ Test the api_view_user_requests_filed method of the flask user - api """ + """Test the api_view_user_requests_filed method of the flask user + api""" # Default data returned output = self.app.get( @@ -1339,8 +1339,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_actionable(self, mockemail): - """ Test the api_view_user_requests_actionable method of the flask user - api """ + """Test the api_view_user_requests_actionable method of the flask user + api""" # First we test without the status parameter. It should default to `open` output = self.app.get("/api/0/user/pingou/requests/actionable") @@ -1515,8 +1515,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_actionable_created(self, mockemail): - """ Test the api_view_user_requests_filed method of the flask user - api with the created parameter """ + """Test the api_view_user_requests_filed method of the flask user + api with the created parameter""" today = datetime.datetime.utcnow().date() output = self.app.get( @@ -1588,8 +1588,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_actionable_updated(self, mockemail): - """ Test the api_view_user_requests_filed method of the flask user - api with the created parameter """ + """Test the api_view_user_requests_filed method of the flask user + api with the created parameter""" today = datetime.datetime.utcnow().date() output = self.app.get( @@ -1620,8 +1620,8 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_actionable_closed(self, mockemail): - """ Test the api_view_user_requests_filed method of the flask user - api with the created parameter """ + """Test the api_view_user_requests_filed method of the flask user + api with the created parameter""" today = datetime.datetime.utcnow().date() output = self.app.get( @@ -1866,8 +1866,8 @@ class PagureFlaskApiUsertestissues(tests.Modeltests): ) def test_user_issues_created(self): - """ Return the list of issues associated with the specified user - and play with the created filter. """ + """Return the list of issues associated with the specified user + and play with the created filter.""" today = datetime.datetime.utcnow().date() output = self.app.get( diff --git a/tests/test_pagure_flask_docs.py b/tests/test_pagure_flask_docs.py index 4baa735..d187bd8 100644 --- a/tests/test_pagure_flask_docs.py +++ b/tests/test_pagure_flask_docs.py @@ -104,7 +104,7 @@ class PagureFlaskDocstests(tests.SimplePagureTest): self.assertEqual(output.status_code, 404) def test_view_docs_project_no_git(self): - """ Test the view_docs endpoint with a project that has no + """Test the view_docs endpoint with a project that has no corresponding git repo. """ tests.create_projects(self.session) @@ -128,7 +128,7 @@ class PagureFlaskDocstests(tests.SimplePagureTest): ) def test_view_docs_project_no_docs(self): - """ Test the view_docs endpoint with a project that disabled the + """Test the view_docs endpoint with a project that disabled the docs. """ tests.create_projects(self.session) diff --git a/tests/test_pagure_flask_dump_load_ticket.py b/tests/test_pagure_flask_dump_load_ticket.py index 33d46c6..d20597b 100644 --- a/tests/test_pagure_flask_dump_load_ticket.py +++ b/tests/test_pagure_flask_dump_load_ticket.py @@ -32,7 +32,7 @@ from pagure.config import config as pagure_config, reload_config class PagureFlaskDumpLoadTicketTests(tests.Modeltests): - """ Tests for flask application for dumping and re-loading the JSON of + """Tests for flask application for dumping and re-loading the JSON of a ticket. """ @@ -179,7 +179,8 @@ class PagureFlaskDumpLoadTicketTests(tests.Modeltests): os.unlink(os.path.join(self.dbfolder, "db.sqlite")) self.db_session = pagure.lib.model.create_tables( - self.dbpath, acls=pagure_config.get("ACLS", {}), + self.dbpath, + acls=pagure_config.get("ACLS", {}), ) self._prepare_db() tests.create_projects(self.session) diff --git a/tests/test_pagure_flask_internal.py b/tests/test_pagure_flask_internal.py index 96b3c26..6853068 100644 --- a/tests/test_pagure_flask_internal.py +++ b/tests/test_pagure_flask_internal.py @@ -421,7 +421,7 @@ class PagureFlaskInternaltests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_mergeable_request_pull_FF(self, send_email): - """ Test the mergeable_request_pull endpoint with a fast-forward + """Test the mergeable_request_pull endpoint with a fast-forward merge. """ send_email.return_value = True @@ -548,7 +548,7 @@ class PagureFlaskInternaltests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_mergeable_request_pull_no_change(self, send_email): - """ Test the mergeable_request_pull endpoint when there are no + """Test the mergeable_request_pull endpoint when there are no changes to merge. """ send_email.return_value = True @@ -666,7 +666,7 @@ class PagureFlaskInternaltests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_mergeable_request_pull_merge(self, send_email): - """ Test the mergeable_request_pull endpoint when the changes can + """Test the mergeable_request_pull endpoint when the changes can be merged with a merge commit. """ send_email.return_value = True @@ -832,7 +832,7 @@ class PagureFlaskInternaltests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_mergeable_request_pull_conflicts(self, send_email): - """ Test the mergeable_request_pull endpoint when the changes cannot + """Test the mergeable_request_pull endpoint when the changes cannot be merged due to conflicts. """ send_email.return_value = True @@ -980,7 +980,7 @@ class PagureFlaskInternaltests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_mergeable_request_pull_merge_no_nonff_merges(self, send_email): - """ Test the mergeable_request_pull endpoint when the changes can + """Test the mergeable_request_pull endpoint when the changes can be merged with a merge commit, but project settings prohibit this. """ send_email.return_value = True @@ -1139,7 +1139,7 @@ class PagureFlaskInternaltests(tests.Modeltests): @patch("pagure.lib.notify.send_email") def test_mergeable_request_pull_minimum_score(self, send_email): - """ Test the mergeable_request_pull endpoint when the changes can + """Test the mergeable_request_pull endpoint when the changes can be merged with a merge FF, but project settings enforces vote on the PR. """ @@ -1284,7 +1284,7 @@ class PagureFlaskInternaltests(tests.Modeltests): MagicMock(side_effect=pagure.exceptions.PagureException("error")), ) def test_mergeable_request_pull_merge_pagureerror(self): - """ Test the mergeable_request_pull endpoint when the backend + """Test the mergeable_request_pull endpoint when the backend raises an GitError exception. """ # Create a git repo to play with @@ -1419,7 +1419,7 @@ class PagureFlaskInternaltests(tests.Modeltests): MagicMock(side_effect=pygit2.GitError("git error")), ) def test_mergeable_request_pull_merge_giterror(self): - """ Test the mergeable_request_pull endpoint when the backend + """Test the mergeable_request_pull endpoint when the backend raises an GitError exception. """ # Create a git repo to play with @@ -2750,7 +2750,7 @@ class PagureFlaskInternaltests(tests.Modeltests): ) def test_task_info_task_running(self): - """ Test the task_info internal API endpoint when the task isn't + """Test the task_info internal API endpoint when the task isn't ready. """ task = MagicMock() @@ -2763,8 +2763,7 @@ class PagureFlaskInternaltests(tests.Modeltests): self.assertEqual(output.status_code, 418) def test_task_info_task_passed(self): - """ Test the task_info internal API endpoint when the task failed. - """ + """Test the task_info internal API endpoint when the task failed.""" task = MagicMock() task.get = MagicMock(return_value="PASSED") with patch( @@ -2776,8 +2775,7 @@ class PagureFlaskInternaltests(tests.Modeltests): self.assertEqual(js_data, {"results": "PASSED"}) def test_task_info_task_failed(self): - """ Test the task_info internal API endpoint when the task failed. - """ + """Test the task_info internal API endpoint when the task failed.""" task = MagicMock() task.get = MagicMock(return_value=Exception("Random error")) with patch( @@ -2789,7 +2787,7 @@ class PagureFlaskInternaltests(tests.Modeltests): self.assertEqual(js_data, {"results": "Random error"}) def test_lookup_ssh_key(self): - """ Test the mergeable_request_pull endpoint when the backend + """Test the mergeable_request_pull endpoint when the backend raises an GitError exception. """ tests.create_projects(self.session) diff --git a/tests/test_pagure_flask_rebase.py b/tests/test_pagure_flask_rebase.py index 0de604c..f7632f0 100644 --- a/tests/test_pagure_flask_rebase.py +++ b/tests/test_pagure_flask_rebase.py @@ -129,8 +129,8 @@ class PagureRebasetests(PagureRebaseBasetests): ) def test_merge_status_needsrebase(self): - """ Test that the PR is marked as needing a rebase if the project - disables non-fast-forward merges. """ + """Test that the PR is marked as needing a rebase if the project + disables non-fast-forward merges.""" self.project = pagure.lib.query.get_authorized_project( self.session, "test" ) @@ -189,8 +189,8 @@ class PagureRebasetests(PagureRebaseBasetests): ) def test_rebase_api_ui_logged_in_different_user(self): - """ Test the rebase PR API endpoint when logged in from the UI and - its outcome. """ + """Test the rebase PR API endpoint when logged in from the UI and + its outcome.""" # Add 'bar' to the project 'test' so 'bar' can rebase the PR item = pagure.lib.model.User( user="bar", @@ -254,8 +254,8 @@ class PagureRebasetests(PagureRebaseBasetests): self.assertEqual(repo.requests[0].comments[0].user.username, "bar") def test_rebase_api_ui_logged_in_pull_request_author(self): - """ Test the rebase PR API endpoint when logged in from the UI and - its outcome. """ + """Test the rebase PR API endpoint when logged in from the UI and + its outcome.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): @@ -302,8 +302,8 @@ class PagureRebasetests(PagureRebaseBasetests): self.assertEqual(repo.requests[0].comments[0].user.username, "foo") def test_rebase_api_api_logged_in(self): - """ Test the rebase PR API endpoint when using an API token and - its outcome. """ + """Test the rebase PR API endpoint when using an API token and + its outcome.""" tests.create_tokens(self.session) tests.create_tokens_acl(self.session) @@ -338,8 +338,8 @@ class PagureRebasetests(PagureRebaseBasetests): ) def test_rebase_api_conflicts(self): - """ Test the rebase PR API endpoint when logged in from the UI and - its outcome. """ + """Test the rebase PR API endpoint when logged in from the UI and + its outcome.""" tests.add_content_to_git( os.path.join(self.path, "repos", "test.git"), branch="master", @@ -441,11 +441,14 @@ class PagureRebaseNoHooktests(PagureRebaseBasetests): config_values = {"authbackend": "pagure", "nogithooks": True} @patch.dict( - "pagure.config.config", {"FEDORA_MESSAGING_NOTIFICATIONS": True,} + "pagure.config.config", + { + "FEDORA_MESSAGING_NOTIFICATIONS": True, + }, ) def test_rebase_api_ui_logged_in(self): - """ Test the rebase PR API endpoint when logged in from the UI and - its outcome. """ + """Test the rebase PR API endpoint when logged in from the UI and + its outcome.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -894,8 +897,8 @@ class PagureRebaseNotAllowedtests(tests.Modeltests): self.request = self.project.requests[0] def test_rebase_api_ui_logged_in(self): - """ Test the rebase PR API endpoint when logged in from the UI and - its outcome. """ + """Test the rebase PR API endpoint when logged in from the UI and + its outcome.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -969,8 +972,8 @@ class PagureRebaseNotAllowedtests(tests.Modeltests): ) def test_rebase_api_ui_logged_in_different_user(self): - """ Test the rebase PR API endpoint when logged in from the UI and - its outcome. """ + """Test the rebase PR API endpoint when logged in from the UI and + its outcome.""" # Add 'bar' to the project 'test' so 'bar' can rebase the PR item = pagure.lib.model.User( user="bar", @@ -1057,8 +1060,8 @@ class PagureRebaseNotAllowedtests(tests.Modeltests): self.assertEqual(repo.requests[0].comments[0].user.username, "bar") def test_rebase_api_api_logged_in(self): - """ Test the rebase PR API endpoint when using an API token and - its outcome. """ + """Test the rebase PR API endpoint when using an API token and + its outcome.""" tests.create_tokens(self.session) tests.create_tokens_acl(self.session) @@ -1117,8 +1120,8 @@ class PagureRebaseNotAllowedtests(tests.Modeltests): ) def test_rebase_api_ui_logged_in_pull_request_author(self): - """ Test the rebase PR API endpoint when logged in from the UI and - its outcome. """ + """Test the rebase PR API endpoint when logged in from the UI and + its outcome.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index 8c10a35..6ff6f8d 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -545,8 +545,7 @@ class PagureFlaskApptests(tests.Modeltests): @patch("pygit2.init_repository", wraps=pygit2.init_repository) def test_new_project_with_template(self, pygit2init): - """ Test the new_project endpoint for a new project with a template set. - """ + """Test the new_project endpoint for a new project with a template set.""" # Before projects = pagure.lib.query.search_projects(self.session) self.assertEqual(len(projects), 0) @@ -848,7 +847,7 @@ class PagureFlaskApptests(tests.Modeltests): self.assertIn("SSH key removed", output_text) def patched_commit_exists(user, namespace, repo, githash): - """ Patched version of pagure.pfmarkdown._commit_exists to enforce + """Patched version of pagure.pfmarkdown._commit_exists to enforce returning true on some given hash without having us actually check the git repos. """ @@ -933,8 +932,7 @@ class PagureFlaskApptests(tests.Modeltests): self.assertEqual(expected[idx], output.get_data(as_text=True)) def test_markdown_preview(self): - """ Test the markdown_preview endpoint with a non-existing commit. - """ + """Test the markdown_preview endpoint with a non-existing commit.""" user = tests.FakeUser() user.username = "foo" @@ -1511,7 +1509,7 @@ class PagureFlaskApptests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_view_my_requests_pr_in_another_project(self): """Test the view_user_requests endpoint when the user opened a PR - in another project. """ + in another project.""" # Pingou creates the PR on test tests.create_projects(self.session) repo = pagure.lib.query._get_project(self.session, "test") @@ -1570,7 +1568,7 @@ class PagureFlaskApptests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_view_my_requests_against_another_project(self): """Test the view_user_requests endpoint when there is a PR opened - by me against a project I do not have rights on. """ + by me against a project I do not have rights on.""" # Create the PR tests.create_projects(self.session) repo = pagure.lib.query._get_project(self.session, "test") @@ -1724,7 +1722,7 @@ class PagureFlaskApptests(tests.Modeltests): def test_view_my_issues_tickets_turned_off(self): """Test the view_user_issues endpoint when the user exists and - and ENABLE_TICKETS is False """ + and ENABLE_TICKETS is False""" # Turn off the tickets instance wide pagure.config.config["ENABLE_TICKETS"] = False @@ -1934,8 +1932,8 @@ class PagureFlaskApptests(tests.Modeltests): @patch.dict("pagure.config.config", {"PAGURE_AUTH": "fas"}) @patch.dict("pagure.utils.pagure_config", {"PAGURE_AUTH": "fas"}) def test_create_project_auth_FAS_no_FPCA(self): - """ Test creating a project when auth is FAS and the user did not - sign the FPCA. """ + """Test creating a project when auth is FAS and the user did not + sign the FPCA.""" user = tests.FakeUser(username="foo", cla_done=False) with tests.user_set(self.app.application, user): @@ -2347,8 +2345,8 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"ENABLE_UI_NEW_PROJECTS": False}) def test_new_project_when_turned_off_in_the_ui(self): - """ Test the new_project endpoint when new project creation is - not allowed in the UI of this pagure instance. """ + """Test the new_project endpoint when new project creation is + not allowed in the UI of this pagure instance.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): @@ -2362,8 +2360,8 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"ENABLE_UI_NEW_PROJECTS": False}) def test_new_project_button_when_turned_off_in_the_ui_no_project(self): - """ Test the index endpoint when new project creation is - not allowed in the UI of this pagure instance. """ + """Test the index endpoint when new project creation is + not allowed in the UI of this pagure instance.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): @@ -2386,8 +2384,8 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"ENABLE_UI_NEW_PROJECTS": False}) def test_new_project_button_when_turned_off_in_the_ui_w_project(self): - """ Test the index endpoint when new project creation is - not allowed in the UI of this pagure instance. """ + """Test the index endpoint when new project creation is + not allowed in the UI of this pagure instance.""" tests.create_projects(self.session) user = tests.FakeUser(username="pingou") @@ -2410,8 +2408,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): ) def test_new_project_with_dot(self): - """ Test the new_project endpoint when new project contains a dot. - """ + """Test the new_project endpoint when new project contains a dot.""" # Before projects = pagure.lib.query.search_projects(self.session) self.assertEqual(len(projects), 0) @@ -2441,8 +2438,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): self.assertEqual(len(projects), 1) def test_new_project_with_plus(self): - """ Test the new_project endpoint when new project contains a plus sign. - """ + """Test the new_project endpoint when new project contains a plus sign.""" # Before projects = pagure.lib.query.search_projects(self.session) self.assertEqual(len(projects), 0) @@ -2477,8 +2473,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): self.assertEqual(repo.listall_branches(), []) def test_new_project_with_default_branch(self): - """ Test the new_project endpoint when new project contains a plus sign. - """ + """Test the new_project endpoint when new project contains a plus sign.""" # Before projects = pagure.lib.query.search_projects(self.session) self.assertEqual(len(projects), 0) @@ -2519,8 +2514,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"GIT_DEFAULT_BRANCH": "main"}) def test_new_project_with_default_branch_instance_wide(self): - """ Test the new_project endpoint when new project contains a plus sign. - """ + """Test the new_project endpoint when new project contains a plus sign.""" # Before projects = pagure.lib.query.search_projects(self.session) self.assertEqual(len(projects), 0) @@ -2560,8 +2554,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"GIT_DEFAULT_BRANCH": "main"}) def test_new_project_with_default_branch_instance_wide_overriden(self): - """ Test the new_project endpoint when new project contains a plus sign. - """ + """Test the new_project endpoint when new project contains a plus sign.""" # Before projects = pagure.lib.query.search_projects(self.session) self.assertEqual(len(projects), 0) @@ -2601,8 +2594,8 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): self.assertEqual(repo.listall_branches(), ["rawhide"]) def test_new_project_when_turned_off(self): - """ Test the new_project endpoint when new project creation is - not allowed in the pagure instance. """ + """Test the new_project endpoint when new project creation is + not allowed in the pagure instance.""" # turn the project creation off pagure.config.config["ENABLE_NEW_PROJECTS"] = False @@ -2701,7 +2694,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): self.assertIn("Invalid input. ", output_text) def test_new_project_mirrored_invalid_sshurl(self): - """ Test the new_project with a mirrored repo but an invalid + """Test the new_project with a mirrored repo but an invalid SSH-like url. """ @@ -2762,7 +2755,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"DISABLE_MIRROR_IN": True}) def test_new_project_mirrored_mirror_disabled(self): - """ Test the new_project with a mirrored repo when that feature is + """Test the new_project with a mirrored repo when that feature is disabled. """ @@ -2878,8 +2871,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"USER_NAMESPACE": True}) def test_new_project_user_namespaced(self): - """ Test the new_project with a user namespaced enabled. - """ + """Test the new_project with a user namespaced enabled.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): @@ -2938,8 +2930,7 @@ class PagureFlaskAppNewProjecttests(tests.Modeltests): @patch.dict("pagure.config.config", {"USER_NAMESPACE": True}) def test_new_project_user_namespaced_invalid_user(self): - """ Test the new_project with a user namespaced enabled. - """ + """Test the new_project with a user namespaced enabled.""" tests.create_user(self.session, "docs", "evil docs", ["docs@bar.com"]) user = tests.FakeUser(username="docs") diff --git a/tests/test_pagure_flask_ui_app_browse.py b/tests/test_pagure_flask_ui_app_browse.py index 1fac545..a81af86 100644 --- a/tests/test_pagure_flask_ui_app_browse.py +++ b/tests/test_pagure_flask_ui_app_browse.py @@ -46,8 +46,8 @@ class PagureFlaskAppBrowsetests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_logged_in_private_project(self): - """ Test the browse project endpoint when logged in with a private - project. """ + """Test the browse project endpoint when logged in with a private + project.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): @@ -69,8 +69,8 @@ class PagureFlaskAppBrowsetests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_unauth_private_project(self): - """ Test the browse project endpoint when logged out with a private - project. """ + """Test the browse project endpoint when logged out with a private + project.""" output = self.app.get("/browse/projects/") self.assertEqual(output.status_code, 200) @@ -90,8 +90,8 @@ class PagureFlaskAppBrowsetests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_logged_in_no_access_private_project(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -113,8 +113,8 @@ class PagureFlaskAppBrowsetests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_logged_in_ticket_private_project(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project.""" # Add user 'pingou' with ticket access on repo repo = pagure.lib.query._get_project(self.session, "test3") @@ -145,8 +145,8 @@ class PagureFlaskAppBrowsetests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_logged_in_commit_private_project(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project.""" # Add user 'pingou' with commit access on repo repo = pagure.lib.query._get_project(self.session, "test3") @@ -176,8 +176,8 @@ class PagureFlaskAppBrowsetests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_logged_in_admin_private_project(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project.""" # Add user 'pingou' with admin access on repo repo = pagure.lib.query._get_project(self.session, "test3") @@ -255,8 +255,8 @@ class PagureFlaskAppBrowseGroupAdmintests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_user_not_in_group(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project via a group as admin. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project via a group as admin.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -278,8 +278,8 @@ class PagureFlaskAppBrowseGroupAdmintests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_user_in_group(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project via a group as admin. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project via a group as admin.""" group = pagure.lib.query.search_groups(self.session, group_name="JL") pagure.lib.query.add_user_to_group( @@ -359,8 +359,8 @@ class PagureFlaskAppBrowseGroupCommittests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_user_not_in_group(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project via a group as admin. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project via a group as admin.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -382,8 +382,8 @@ class PagureFlaskAppBrowseGroupCommittests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_user_in_group(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project via a group as admin. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project via a group as admin.""" group = pagure.lib.query.search_groups(self.session, group_name="JL") pagure.lib.query.add_user_to_group( @@ -463,8 +463,8 @@ class PagureFlaskAppBrowseGroupTickettests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_user_not_in_group(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project via a group as admin. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project via a group as admin.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -486,8 +486,8 @@ class PagureFlaskAppBrowseGroupTickettests(tests.Modeltests): @patch.dict("pagure.config.config", {"PRIVATE_PROJECTS": True}) def test_browse_project_user_in_group(self): - """ Test the browse project endpoint when logged in as an user that - has no access to the private project via a group as admin. """ + """Test the browse project endpoint when logged in as an user that + has no access to the private project via a group as admin.""" group = pagure.lib.query.search_groups(self.session, group_name="JL") pagure.lib.query.add_user_to_group( diff --git a/tests/test_pagure_flask_ui_app_give_project.py b/tests/test_pagure_flask_ui_app_give_project.py index 705599c..3c87dfd 100644 --- a/tests/test_pagure_flask_ui_app_give_project.py +++ b/tests/test_pagure_flask_ui_app_give_project.py @@ -218,7 +218,7 @@ class PagureFlaskGiveRepotests(tests.SimplePagureTest): @patch.dict("pagure.config.config", {"PAGURE_ADMIN_USERS": "foo"}) @patch("pagure.lib.git.generate_gitolite_acls", MagicMock()) def test_give_project_not_owner_but_admin(self): - """ Test the give_project endpoint. + """Test the give_project endpoint. Test giving a project when the person giving the project is a pagure admin (instance wide admin) but not a project admin. @@ -282,8 +282,8 @@ class PagureFlaskGiveRepotests(tests.SimplePagureTest): @patch.dict("pagure.config.config", {"PAGURE_ADMIN_USERS": "foo"}) @patch("pagure.lib.git.generate_gitolite_acls", MagicMock()) def test_give_project_already_user(self): - """ Test the give_project endpoint when the new main_admin is already - a committer on the project. """ + """Test the give_project endpoint when the new main_admin is already + a committer on the project.""" project = pagure.lib.query._get_project(self.session, "test") pagure.lib.query.add_user_to_project( diff --git a/tests/test_pagure_flask_ui_app_index.py b/tests/test_pagure_flask_ui_app_index.py index 5b67a4b..706c682 100644 --- a/tests/test_pagure_flask_ui_app_index.py +++ b/tests/test_pagure_flask_ui_app_index.py @@ -57,8 +57,8 @@ class PagureFlaskAppIndextests(tests.Modeltests): def test_index_logged_in(self): """ - Test the index endpoint when logged in. - It should redirect to the userdash. + Test the index endpoint when logged in. + It should redirect to the userdash. """ tests.create_projects(self.session) diff --git a/tests/test_pagure_flask_ui_app_userdash.py b/tests/test_pagure_flask_ui_app_userdash.py index ea92bd6..7604dc5 100644 --- a/tests/test_pagure_flask_ui_app_userdash.py +++ b/tests/test_pagure_flask_ui_app_userdash.py @@ -33,8 +33,8 @@ class PagureFlaskAppUserdashTests(tests.Modeltests): """ Tests for the index page of flask app controller of pagure """ def test_index_commit_access_while_admin(self): - """ Test the index endpoint filter for commit access only when user - is an admin. """ + """Test the index endpoint filter for commit access only when user + is an admin.""" tests.create_projects(self.session) # Add a 3rd project just for foo @@ -87,8 +87,8 @@ class PagureFlaskAppUserdashTests(tests.Modeltests): ) def test_index_commit_access_while_commit(self): - """ Test the index endpoint filter for commit access only when user - is an committer. """ + """Test the index endpoint filter for commit access only when user + is an committer.""" tests.create_projects(self.session) # Add a 3rd project just for foo @@ -138,8 +138,8 @@ class PagureFlaskAppUserdashTests(tests.Modeltests): ) def test_index_commit_access_while_ticket(self): - """ Test the index endpoint filter for commit access only when user - is has ticket access. """ + """Test the index endpoint filter for commit access only when user + is has ticket access.""" tests.create_projects(self.session) # Add a 3rd project just for foo @@ -189,8 +189,8 @@ class PagureFlaskAppUserdashTests(tests.Modeltests): ) def test_index_admin_access_while_admin(self): - """ Test the index endpoint filter for admin access only when user - is an admin. """ + """Test the index endpoint filter for admin access only when user + is an admin.""" tests.create_projects(self.session) # Add a 3rd project just for foo @@ -240,8 +240,8 @@ class PagureFlaskAppUserdashTests(tests.Modeltests): ) def test_index_admin_access_while_commit(self): - """ Test the index endpoint filter for admin access only when user - is an committer. """ + """Test the index endpoint filter for admin access only when user + is an committer.""" tests.create_projects(self.session) # Add a 3rd project just for foo @@ -292,8 +292,8 @@ class PagureFlaskAppUserdashTests(tests.Modeltests): ) def test_index_main_admin_access_while_commit(self): - """ Test the index endpoint filter for main admin access only when - user is an committer. """ + """Test the index endpoint filter for main admin access only when + user is an committer.""" tests.create_projects(self.session) # Add a 3rd project just for foo diff --git a/tests/test_pagure_flask_ui_archives.py b/tests/test_pagure_flask_ui_archives.py index 37ab61f..8e82e56 100644 --- a/tests/test_pagure_flask_ui_archives.py +++ b/tests/test_pagure_flask_ui_archives.py @@ -124,8 +124,8 @@ class PagureFlaskUiArchivesTest(tests.Modeltests): self.assertEqual(os.listdir(self.archive_path), []) def test_project_no_tag(self): - """ Test getting the archive of a non-empty project but without - tags. """ + """Test getting the archive of a non-empty project but without + tags.""" with mock.patch.dict( "pagure.config.config", {"ARCHIVE_FOLDER": os.path.join(self.path, "archives")}, @@ -310,8 +310,8 @@ class PagureFlaskUiArchivesTest(tests.Modeltests): ) def test_project_w_commit_tar_gz_twice(self): - """ Test getting the archive from a commit twice, so we hit the - disk cache. """ + """Test getting the archive from a commit twice, so we hit the + disk cache.""" repopath = os.path.join(self.path, "repos", "test.git") repo = pygit2.Repository(repopath) commit = repo.head.target.hex diff --git a/tests/test_pagure_flask_ui_clone.py b/tests/test_pagure_flask_ui_clone.py index 11e9950..79354fe 100644 --- a/tests/test_pagure_flask_ui_clone.py +++ b/tests/test_pagure_flask_ui_clone.py @@ -223,7 +223,8 @@ class PagureFlaskAppClonetests(tests.Modeltests): % base64.b64encode(b"pingou:aaabbbcccddd") } output = self.app.get( - "/test.git/info/refs?service=git-receive-pack", headers=headers, + "/test.git/info/refs?service=git-receive-pack", + headers=headers, ) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) @@ -344,7 +345,8 @@ class PagureFlaskAppClonetests(tests.Modeltests): % base64.b64encode(b"pingou:aaabbbcccddd2") } output = self.app.get( - "/test.git/info/refs?service=git-receive-pack", headers=headers, + "/test.git/info/refs?service=git-receive-pack", + headers=headers, ) self.assertEqual(output.status_code, 401) self.assertIn("Authorization Required", output.get_data(as_text=True)) diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index 3b3d214..d71d571 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -38,7 +38,7 @@ from pagure.lib.repo import PagureRepo def _get_commits(output): - """ Returns the commits message in the output. All commits must have + """Returns the commits message in the output. All commits must have been made by `Alice Author` or `PY C` to be found. """ commits = [] @@ -75,7 +75,7 @@ def set_up_git_repo( prid=1, name_from="test", ): - """ Set up the git repo and create the corresponding PullRequest + """Set up the git repo and create the corresponding PullRequest object. """ @@ -3078,8 +3078,7 @@ index 0000000..2a552bb ) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_update_pull_requests_assign(self): - """ Test the update_pull_requests endpoint when assigning a PR. - """ + """Test the update_pull_requests endpoint when assigning a PR.""" tests.create_projects(self.session) tests.create_projects_git( @@ -4184,8 +4183,7 @@ index 0000000..2a552bb ) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_update_pull_requests_tag(self): - """ Test the update_pull_requests endpoint when tagging a PR. - """ + """Test the update_pull_requests endpoint when tagging a PR.""" tests.create_projects(self.session) tests.create_projects_git( @@ -5002,8 +5000,8 @@ index 0000000..2a552bb @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_fork_project_non_master_default(self): - """ Test the fork_project endpoint with a project whose default branch - is not master. """ + """Test the fork_project endpoint with a project whose default branch + is not master.""" tests.create_projects(self.session) for folder in ["docs", "tickets", "requests", "repos"]: @@ -6296,7 +6294,7 @@ More information @patch("pagure.lib.notify.send_email") def test_new_request_pull_fork_to_other_unrelated_fork(self, send_email): - """ Test creating a PR from fork to fork that isn't from the same + """Test creating a PR from fork to fork that isn't from the same family. """ send_email.return_value = True @@ -7096,7 +7094,7 @@ More information @patch("pagure.lib.notify.send_email") def test_merge_request_pull_FF_w_merge_commit(self, send_email): - """ Test the merge_request_pull endpoint with a FF PR but with a + """Test the merge_request_pull endpoint with a FF PR but with a merge commit. """ send_email.return_value = True @@ -7193,7 +7191,7 @@ More information @patch("pagure.lib.notify.send_email") def test_internal_endpoint_main_ahead(self, send_email): - """ Test the new_request_pull endpoint when the main repo is ahead + """Test the new_request_pull endpoint when the main repo is ahead of the fork. """ send_email.return_value = True @@ -7445,7 +7443,8 @@ More information ) self.assertEqual(output.status_code, 400) self.assertIn( - b"

Cannot edit binary files

", output.data, + b"

Cannot edit binary files

", + output.data, ) # Check fork-edit shows when user is not logged in @@ -7793,8 +7792,8 @@ More information class TestTicketAccessEditPRMetadata(tests.Modeltests): - """ Tests that people with ticket access on a project can edit the - meta-data of a PR """ + """Tests that people with ticket access on a project can edit the + meta-data of a PR""" def setUp(self): """ Set up the environnment, ran before every tests. """ @@ -7820,8 +7819,8 @@ class TestTicketAccessEditPRMetadata(tests.Modeltests): self.assertEqual(msg, "User added") def test_unauth_cannot_view_edit_metadata_ui(self): - """ Test that unauthenticated users cannot view the edit the - metadata fields in the UI. """ + """Test that unauthenticated users cannot view the edit the + metadata fields in the UI.""" output = self.app.get("/test/pull-request/1") self.assertEqual(output.status_code, 200) @@ -7844,8 +7843,8 @@ class TestTicketAccessEditPRMetadata(tests.Modeltests): ) def test_admin_can_view_edit_metadata_ui(self): - """ Test that admin users can view the edit the metadata fields in - the UI. """ + """Test that admin users can view the edit the metadata fields in + the UI.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -7903,8 +7902,8 @@ class TestTicketAccessEditPRMetadata(tests.Modeltests): ) def test_ticket_can_view_edit_metadata_ui(self): - """ Test that users with ticket access can view the edit the - metadata fields in the UI. """ + """Test that users with ticket access can view the edit the + metadata fields in the UI.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): @@ -7930,8 +7929,8 @@ class TestTicketAccessEditPRMetadata(tests.Modeltests): ) def test_ticket_can_edit_metadata_ui(self): - """ Test that users with ticket access can edit the metadata in the - UI. """ + """Test that users with ticket access can edit the metadata in the + UI.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): diff --git a/tests/test_pagure_flask_ui_issue_pr_link.py b/tests/test_pagure_flask_ui_issue_pr_link.py index 8a5bdf5..9016681 100644 --- a/tests/test_pagure_flask_ui_issue_pr_link.py +++ b/tests/test_pagure_flask_ui_issue_pr_link.py @@ -136,8 +136,7 @@ class PagureFlaskPrIssueLinkTest(tests.Modeltests): self.assertEqual(request.id, 3) def test_ticket_no_link(self): - """ Test that no Related PR(s) block is showing in the issue page. - """ + """Test that no Related PR(s) block is showing in the issue page.""" output = self.app.get("/test/issue/1") self.assertEqual(output.status_code, 200) self.assertNotIn( @@ -145,15 +144,13 @@ class PagureFlaskPrIssueLinkTest(tests.Modeltests): ) def test_ticket_link(self): - """ Test that a Related PR(s) block is showing in the issue page. - """ + """Test that a Related PR(s) block is showing in the issue page.""" output = self.app.get("/test/issue/2") self.assertEqual(output.status_code, 200) self.assertIn("Related Pull Requests", output.get_data(as_text=True)) def test_pr_link_issue_list(self): - """ Test that the related PR(s) shows in the page listing issues - """ + """Test that the related PR(s) shows in the page listing issues""" output = self.app.get("/test/issues") self.assertEqual(output.status_code, 200) self.assertIn( diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index d3ac54a..1c0df62 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -540,8 +540,8 @@ class PagureFlaskIssuestests(tests.Modeltests): ) def test_new_issue_metadata_user(self): - """ Test the new_issue endpoint when the user has access to the - project. """ + """Test the new_issue endpoint when the user has access to the + project.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -563,8 +563,8 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn("Assignee", output_text) def test_new_issue_metadata_not_user(self): - """ Test the new_issue endpoint when the user does not have access - to the project. """ + """Test the new_issue endpoint when the user does not have access + to the project.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -588,8 +588,8 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git", MagicMock(return_value=True)) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_new_issue_with_metadata(self): - """ Test the new_issue endpoint when the user has access to the - project. """ + """Test the new_issue endpoint when the user has access to the + project.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -658,7 +658,7 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git", MagicMock(return_value=True)) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_new_issue_with_metadata_not_user(self): - """ Test the new_issue endpoint when the user does not have access + """Test the new_issue endpoint when the user does not have access to the project but still tries to. """ @@ -1276,8 +1276,8 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_view_issue_inconsistent_milestone(self, p_send_email, p_ugt): - """ Test the view_issue endpoint when the milestone keys are - inconsistent with the milestones of the project. """ + """Test the view_issue endpoint when the milestone keys are + inconsistent with the milestones of the project.""" p_send_email.return_value = True p_ugt.return_value = True @@ -1811,8 +1811,8 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_view_issue_list_no_data(self, p_send_email, p_ugt): - """ Test the view_issue endpoint when the issue has a custom field - of type list with no data attached. """ + """Test the view_issue endpoint when the issue has a custom field + of type list with no data attached.""" p_send_email.return_value = True p_ugt.return_value = True @@ -2947,8 +2947,8 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git", MagicMock(return_value=True)) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_update_issue_block_closed(self): - """ Test how blocked issue shows in the UI when the blocking ticket - is open and closed. """ + """Test how blocked issue shows in the UI when the blocking ticket + is open and closed.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -4853,7 +4853,7 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_git_urls(self, p_send_email, p_ugt): - """ Check that the url to the git repo for issues is present/absent when + """Check that the url to the git repo for issues is present/absent when it should. """ p_send_email.return_value = True @@ -5454,8 +5454,7 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_view_issue_namespace_comment(self, p_send_email, p_ugt): - """ Test comment on the view_issue endpoint on namespaced project. - """ + """Test comment on the view_issue endpoint on namespaced project.""" # Create the project ns/test item = pagure.lib.model.Project( user_id=1, # pingou @@ -5520,7 +5519,7 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_view_issue_comment_and_close(self, p_send_email, p_ugt): - """ Test if the comment and close button shows up on a ticket opened + """Test if the comment and close button shows up on a ticket opened by the user """ # Create the project ns/test @@ -5566,8 +5565,7 @@ class PagureFlaskIssuestests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_view_issue_forked_namespace_comment(self, p_send_email, p_ugt): - """ Test comment on the view_issue endpoint on namespaced project. - """ + """Test comment on the view_issue endpoint on namespaced project.""" # Create the project ns/test item = pagure.lib.model.Project( user_id=1, # pingou diff --git a/tests/test_pagure_flask_ui_issues_open_access.py b/tests/test_pagure_flask_ui_issues_open_access.py index 7085d95..901b621 100644 --- a/tests/test_pagure_flask_ui_issues_open_access.py +++ b/tests/test_pagure_flask_ui_issues_open_access.py @@ -64,8 +64,8 @@ class PagureFlaskIssuesOpenAccesstests(tests.Modeltests): @patch("pagure.lib.git.update_git", MagicMock(return_value=True)) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_new_issue_with_metadata(self): - """ Test the new_issue endpoint when the user has access to the - project. """ + """Test the new_issue endpoint when the user has access to the + project.""" user = tests.FakeUser() user.username = "foo" @@ -122,7 +122,7 @@ class PagureFlaskIssuesOpenAccesstests(tests.Modeltests): @patch("pagure.lib.git.update_git", MagicMock(return_value=True)) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_new_issue_with_metadata_not_user(self): - """ Test the new_issue endpoint when the user does not have access + """Test the new_issue endpoint when the user does not have access to the project but still tries to. """ @@ -516,8 +516,8 @@ class PagureFlaskIssuesOpenAccesstests(tests.Modeltests): @patch("pagure.lib.git.update_git", MagicMock(return_value=True)) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_view_issue_list_no_data(self): - """ Test the view_issue endpoint when the issue has a custom field - of type list with no data attached. """ + """Test the view_issue endpoint when the issue has a custom field + of type list with no data attached.""" repo = pagure.lib.query.get_authorized_project(self.session, "test") # Add custom fields to the project diff --git a/tests/test_pagure_flask_ui_issues_private.py b/tests/test_pagure_flask_ui_issues_private.py index d9566e3..e548684 100644 --- a/tests/test_pagure_flask_ui_issues_private.py +++ b/tests/test_pagure_flask_ui_issues_private.py @@ -25,8 +25,7 @@ import tests # noqa class PagureFlaskIssuesPrivatetests(tests.Modeltests): - """ Tests for flask issues controller of pagure with private tickets - """ + """Tests for flask issues controller of pagure with private tickets""" @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def setUp(self): @@ -86,8 +85,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_issue_list_admin(self): - """ Test the list of issues when user is an admin of the project. - """ + """Test the list of issues when user is an admin of the project.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -101,8 +99,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_issue_list_author(self): - """ Test the list of issues when user is an admin of the project. - """ + """Test the list of issues when user is an admin of the project.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): @@ -116,7 +113,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_issue_list_authenticated(self): - """ Test the list of issues when user is authenticated but has no + """Test the list of issues when user is authenticated but has no special access to the project. """ @@ -132,7 +129,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_issue_list_authenticated_ticket(self): - """ Test the list of issues when user is authenticated but has + """Test the list of issues when user is authenticated but has ticket level access to the project. """ repo = pagure.lib.query._get_project(self.session, "test") @@ -158,7 +155,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_issue_list_authenticated_commit(self): - """ Test the list of issues when user is authenticated but has + """Test the list of issues when user is authenticated but has commit level access to the project. """ repo = pagure.lib.query._get_project(self.session, "test") @@ -184,7 +181,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_issue_list_authenticated_assigned(self): - """ Test the list of issues when user is authenticated and is + """Test the list of issues when user is authenticated and is assigned to one of the issue. """ @@ -212,7 +209,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): self.assertEqual(output.status_code, 404) def test_view_issue_admin(self): - """ Test accessing a private ticket when user is an admin of the + """Test accessing a private ticket when user is an admin of the project. """ @@ -232,8 +229,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_view_issue_author(self): - """ Test accessing a private ticket when user opened the ticket. - """ + """Test accessing a private ticket when user opened the ticket.""" user = tests.FakeUser(username="foo") with tests.user_set(self.app.application, user): @@ -251,7 +247,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_view_issue_authenticated(self): - """ Test accessing a private ticket when user is authenticated but + """Test accessing a private ticket when user is authenticated but has no special access to the project. """ @@ -261,7 +257,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): self.assertEqual(output.status_code, 404) def test_view_issue_authenticated_ticket(self): - """ Test accessing a private ticket when user is authenticated and + """Test accessing a private ticket when user is authenticated and has ticket level access to the project. """ repo = pagure.lib.query._get_project(self.session, "test") @@ -281,7 +277,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): self.assertEqual(output.status_code, 404) def test_view_issue_authenticated_commit(self): - """ Test accessing a private ticket when user is authenticated and + """Test accessing a private ticket when user is authenticated and has commit level access to the project. """ repo = pagure.lib.query._get_project(self.session, "test") @@ -311,7 +307,7 @@ class PagureFlaskIssuesPrivatetests(tests.Modeltests): ) def test_view_issue_authenticated_assigned(self): - """ Test accessing a private ticket when user is authenticated and + """Test accessing a private ticket when user is authenticated and is assigned to one of the issue. """ diff --git a/tests/test_pagure_flask_ui_issues_read_only.py b/tests/test_pagure_flask_ui_issues_read_only.py index ef57ccb..a299d1d 100644 --- a/tests/test_pagure_flask_ui_issues_read_only.py +++ b/tests/test_pagure_flask_ui_issues_read_only.py @@ -26,8 +26,7 @@ import tests # noqa class PagureFlaskIssuesReadOnlytests(tests.Modeltests): - """ Tests for flask issues controller of pagure with read-only tickets - """ + """Tests for flask issues controller of pagure with read-only tickets""" @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def setUp(self): @@ -71,7 +70,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): self.assertEqual(msg.title, "Test issue #2") def test_issue_list_authenticated_commit(self): - """ Test the list of issues when user is authenticated and has + """Test the list of issues when user is authenticated and has access to the project. """ @@ -88,8 +87,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): ) def test_field_comment(self): - """ Test if the field commit is present on the issue page. - """ + """Test if the field commit is present on the issue page.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.get("/test/issue/1") @@ -107,8 +105,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): self.assertIn("This issue tracker is read-only.", output_text) def test_update_ticket(self): - """ Test updating a ticket. - """ + """Test updating a ticket.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post( @@ -125,8 +122,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): ) def test_edit_comment(self): - """ Test editing a comment from a ticket. - """ + """Test editing a comment from a ticket.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post( @@ -143,8 +139,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): ) def test_edit_ticket(self): - """ Test editing a ticket. - """ + """Test editing a ticket.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post( @@ -161,8 +156,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): ) def test_new_issue(self): - """ Test creating a new ticket. - """ + """Test creating a new ticket.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post("/test/new_issue/", data={}) @@ -177,8 +171,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): ) def test_deleting_issue(self): - """ Test deleting a new ticket. - """ + """Test deleting a new ticket.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post("/test/issue/1/drop", data={}) @@ -193,8 +186,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): ) def test_uploading_to_issue(self): - """ Test uploading to a new ticket. - """ + """Test uploading to a new ticket.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post("/test/issue/1/upload", data={}) @@ -210,8 +202,7 @@ class PagureFlaskIssuesReadOnlytests(tests.Modeltests): class PagureFlaskAPIIssuesReadOnlytests(PagureFlaskIssuesReadOnlytests): - """ Tests for flask API issues controller of pagure with read-only tickets - """ + """Tests for flask API issues controller of pagure with read-only tickets""" @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def setUp(self): @@ -219,8 +210,7 @@ class PagureFlaskAPIIssuesReadOnlytests(PagureFlaskIssuesReadOnlytests): super(PagureFlaskAPIIssuesReadOnlytests, self).setUp() def test_api_new_issue(self): - """ Test creating a new ticket. - """ + """Test creating a new ticket.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post("/api/0/test/new_issue", data={}) @@ -341,7 +331,7 @@ class PagureFlaskAPIIssuesReadOnlytests(PagureFlaskIssuesReadOnlytests): class PagureFlaskIssuesAndPRDisabledtests(tests.Modeltests): - """ Tests for flask issues controller of pagure with tickets and PRs + """Tests for flask issues controller of pagure with tickets and PRs disabled. """ @@ -388,8 +378,7 @@ class PagureFlaskIssuesAndPRDisabledtests(tests.Modeltests): self.assertEqual(msg.title, "Test issue #2") def test_edit_tag(self): - """ Test editing a ticket tag. - """ + """Test editing a ticket tag.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post("/test/tag/tag1/edit", data={}) @@ -404,8 +393,7 @@ class PagureFlaskIssuesAndPRDisabledtests(tests.Modeltests): ) def test_drop_tags(self): - """ Test dropping a ticket tag. - """ + """Test dropping a ticket tag.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): output = self.app.post("/test/droptag/", data={}) diff --git a/tests/test_pagure_flask_ui_issues_templates.py b/tests/test_pagure_flask_ui_issues_templates.py index ee0e2f4..37696f9 100644 --- a/tests/test_pagure_flask_ui_issues_templates.py +++ b/tests/test_pagure_flask_ui_issues_templates.py @@ -27,8 +27,7 @@ import tests def create_templates(repopath): - """ Create a couple of templates at the specified repo. - """ + """Create a couple of templates at the specified repo.""" clone_repo = pygit2.Repository(repopath) # Create the RFE template @@ -127,8 +126,7 @@ class PagureFlaskIssuesTemplatetests(tests.Modeltests): create_templates(repopath) def test_new_issue_no_template(self): - """ Test the new_issue endpoint when the project has no templates. - """ + """Test the new_issue endpoint when the project has no templates.""" user = tests.FakeUser() with tests.user_set(self.app.application, user): @@ -204,7 +202,7 @@ class PagureFlaskIssuesTemplatetests(tests.Modeltests): ) def test_get_ticket_template_no_csrf(self): - """ Test the get_ticket_template endpoint when the project has no + """Test the get_ticket_template endpoint when the project has no templates. """ @@ -218,7 +216,7 @@ class PagureFlaskIssuesTemplatetests(tests.Modeltests): ) def test_get_ticket_template_no_template_specified(self): - """ Test the get_ticket_template endpoint when not specifying which + """Test the get_ticket_template endpoint when not specifying which template to get. """ @@ -234,7 +232,7 @@ class PagureFlaskIssuesTemplatetests(tests.Modeltests): ) def test_get_ticket_template_no_project(self): - """ Test the get_ticket_template endpoint when the project does not + """Test the get_ticket_template endpoint when the project does not exist. """ @@ -246,7 +244,7 @@ class PagureFlaskIssuesTemplatetests(tests.Modeltests): self.assertEqual(output.status_code, 404) def test_get_ticket_template_no_template(self): - """ Test the get_ticket_template endpoint when the project has no + """Test the get_ticket_template endpoint when the project has no templates. """ @@ -264,7 +262,7 @@ class PagureFlaskIssuesTemplatetests(tests.Modeltests): ) def test_get_ticket_template_issue_tracker_disabled(self): - """ Test the get_ticket_template endpoint when the project has + """Test the get_ticket_template endpoint when the project has disabled its issue tracker. """ repo = pagure.lib.query.get_authorized_project(self.session, "test") @@ -292,7 +290,7 @@ class PagureFlaskIssuesTemplatetests(tests.Modeltests): ) def test_get_ticket_template_w_template(self): - """ Test the get_ticket_template endpoint when the project has + """Test the get_ticket_template endpoint when the project has templates. """ @@ -311,7 +309,7 @@ class PagureFlaskIssuesTemplatetests(tests.Modeltests): ) def test_get_ticket_template_w_template_namespace(self): - """ Test the get_ticket_template endpoint when the project has + """Test the get_ticket_template endpoint when the project has templates and a namespace. """ diff --git a/tests/test_pagure_flask_ui_login.py b/tests/test_pagure_flask_ui_login.py index 8a1d16c..be319c8 100644 --- a/tests/test_pagure_flask_ui_login.py +++ b/tests/test_pagure_flask_ui_login.py @@ -362,7 +362,8 @@ class PagureFlaskLogintests(tests.SimplePagureTest): output.get_data(as_text=True), ) self.assertIn( - "Username or password invalid.", output.get_data(as_text=True), + "Username or password invalid.", + output.get_data(as_text=True), ) # Check the password is still not of a known version @@ -476,8 +477,8 @@ class PagureFlaskLogintests(tests.SimplePagureTest): @patch.dict("pagure.config.config", {"PAGURE_AUTH": "local"}) @patch.dict("pagure.config.config", {"CHECK_SESSION_IP": False}) def test_has_settings(self): - """ Test that user can see the Settings button when they are logged - in. """ + """Test that user can see the Settings button when they are logged + in.""" # Create a local user self.test_new_user() self.session.commit() @@ -517,8 +518,8 @@ class PagureFlaskLogintests(tests.SimplePagureTest): @patch.dict("pagure.config.config", {"PAGURE_AUTH": "local"}) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_non_ascii_password(self): - """ Test login and create user functionality when the password is - non-ascii. + """Test login and create user functionality when the password is + non-ascii. """ # Check before: diff --git a/tests/test_pagure_flask_ui_no_master_branch.py b/tests/test_pagure_flask_ui_no_master_branch.py index c3bef65..3d2e31f 100644 --- a/tests/test_pagure_flask_ui_no_master_branch.py +++ b/tests/test_pagure_flask_ui_no_master_branch.py @@ -30,8 +30,7 @@ from pagure.lib.repo import PagureRepo class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): - """ Tests for flask application when the git repo has no master branch. - """ + """Tests for flask application when the git repo has no master branch.""" def set_up_git_repo(self): """ Set up the git repo to play with. """ @@ -96,7 +95,7 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_repo(self, send_email): - """ Test the view_repo endpoint when the git repo has no master + """Test the view_repo endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -147,7 +146,7 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_commits(self, send_email): - """ Test the view_commits endpoint when the git repo has no + """Test the view_commits endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -184,7 +183,7 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_file(self, send_email): - """ Test the view_file endpoint when the git repo has no + """Test the view_file endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -227,7 +226,7 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_raw_file(self, send_email): - """ Test the view_raw_file endpoint when the git repo has no + """Test the view_raw_file endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -259,7 +258,7 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_tree(self, send_email): - """ Test the view_tree endpoint when the git repo has no + """Test the view_tree endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -303,7 +302,7 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_new_request_pull(self, send_email): - """ Test the new_request_pull endpoint when the git repo has no + """Test the new_request_pull endpoint when the git repo has no master branch. """ send_email.return_value = True diff --git a/tests/test_pagure_flask_ui_plugins_fedmsg.py b/tests/test_pagure_flask_ui_plugins_fedmsg.py index 3289eec..0df9c16 100644 --- a/tests/test_pagure_flask_ui_plugins_fedmsg.py +++ b/tests/test_pagure_flask_ui_plugins_fedmsg.py @@ -93,7 +93,7 @@ class PagureFlaskPluginFedmsgtests(tests.SimplePagureTest): ) def test_plugin_fedmsg_no_data(self): - """ Test the setting up the fedmsg plugin when there are no Docs + """Test the setting up the fedmsg plugin when there are no Docs folder. """ @@ -147,7 +147,7 @@ class PagureFlaskPluginFedmsgtests(tests.SimplePagureTest): ) def test_plugin_fedmsg_activate(self): - """ Test the setting up the fedmsg plugin when there are no Docs + """Test the setting up the fedmsg plugin when there are no Docs folder. """ pagure.config.config["DOCS_FOLDER"] = os.path.join( @@ -210,7 +210,7 @@ class PagureFlaskPluginFedmsgtests(tests.SimplePagureTest): ) def test_plugin_fedmsg_deactivate(self): - """ Test the setting up the fedmsg plugin when there are no Docs + """Test the setting up the fedmsg plugin when there are no Docs folder. """ self.test_plugin_fedmsg_activate() @@ -271,7 +271,7 @@ class PagureFlaskPluginFedmsgtests(tests.SimplePagureTest): @patch.dict("pagure.config.config", {"DOCS_FOLDER": None}) def test_plugin_fedmsg_no_docs(self): - """ Test the setting up the fedmsg plugin when there are no Docs + """Test the setting up the fedmsg plugin when there are no Docs folder. """ diff --git a/tests/test_pagure_flask_ui_plugins_mirror.py b/tests/test_pagure_flask_ui_plugins_mirror.py index 87004d5..8802d24 100644 --- a/tests/test_pagure_flask_ui_plugins_mirror.py +++ b/tests/test_pagure_flask_ui_plugins_mirror.py @@ -35,7 +35,7 @@ class PagureFlaskPluginMirrortests(tests.Modeltests): tests.create_projects_git(os.path.join(self.path, "repos")) def test_valid_ssh_url_pattern(self): - """ Check a number of valide ssh target that the pattern should let + """Check a number of valide ssh target that the pattern should let through. """ entries = [ @@ -95,7 +95,7 @@ class PagureFlaskPluginMirrortests(tests.Modeltests): ) def test_plugin_mirror_no_data(self): - """ Test the setting up the mirror plugin when there are no data + """Test the setting up the mirror plugin when there are no data provided in the request. """ @@ -141,7 +141,7 @@ class PagureFlaskPluginMirrortests(tests.Modeltests): ) def test_plugin_mirror_invalid_target(self): - """ Test the setting up the mirror plugin when there are the target + """Test the setting up the mirror plugin when there are the target provided is invalid. """ @@ -210,8 +210,7 @@ class PagureFlaskPluginMirrortests(tests.Modeltests): ) def test_setting_up_mirror(self): - """ Test the setting up the mirror plugin. - """ + """Test the setting up the mirror plugin.""" user = tests.FakeUser(username="pingou") with tests.user_set(self.app.application, user): @@ -255,8 +254,7 @@ class PagureFlaskPluginMirrortests(tests.Modeltests): ) def test_plugin_mirror_deactivate(self): - """ Test the deactivating the mirror plugin. - """ + """Test the deactivating the mirror plugin.""" self.test_setting_up_mirror() user = tests.FakeUser(username="pingou") diff --git a/tests/test_pagure_flask_ui_plugins_pagure_hook.py b/tests/test_pagure_flask_ui_plugins_pagure_hook.py index 2fad753..342e069 100644 --- a/tests/test_pagure_flask_ui_plugins_pagure_hook.py +++ b/tests/test_pagure_flask_ui_plugins_pagure_hook.py @@ -93,7 +93,7 @@ class PagureFlaskPluginPagureHooktests(tests.SimplePagureTest): ) def test_plugin_mail_no_data_csrf(self): - """ Test the pagure hook plugin endpoint when no data is sent but + """Test the pagure hook plugin endpoint when no data is sent but the csrf token. """ @@ -160,8 +160,7 @@ class PagureFlaskPluginPagureHooktests(tests.SimplePagureTest): ) def test_plugin_mail_activate_hook(self): - """ Test the pagure hook plugin endpoint when activating the hook. - """ + """Test the pagure hook plugin endpoint when activating the hook.""" pagure.config.config["DOCS_FOLDER"] = os.path.join( self.path, "repos", "docs" ) @@ -218,8 +217,7 @@ class PagureFlaskPluginPagureHooktests(tests.SimplePagureTest): ) def test_plugin_mail_deactivate_hook(self): - """ Test the pagure hook plugin endpoint when activating the hook. - """ + """Test the pagure hook plugin endpoint when activating the hook.""" self.test_plugin_mail_activate_hook() user = tests.FakeUser(username="pingou") @@ -285,7 +283,7 @@ class PagureFlaskPluginPagureHooktests(tests.SimplePagureTest): @patch.dict("pagure.config.config", {"DOCS_FOLDER": None}) def test_plugin_mail_activate_hook_no_doc(self): - """ Test the pagure hook plugin endpoint when activating the hook + """Test the pagure hook plugin endpoint when activating the hook on a pagure instance that de-activated the doc repos. """ @@ -319,7 +317,7 @@ class PagureFlaskPluginPagureHooktests(tests.SimplePagureTest): @patch.dict("pagure.config.config", {"DOCS_FOLDER": None}) def test_plugin_mail_deactivate_hook_no_doc(self): - """ Test the pagure hook plugin endpoint when activating then + """Test the pagure hook plugin endpoint when activating then deactivating the hook on a pagure instance that de-activated the doc repos. """ diff --git a/tests/test_pagure_flask_ui_pr_no_sources.py b/tests/test_pagure_flask_ui_pr_no_sources.py index 4040043..c8663c9 100644 --- a/tests/test_pagure_flask_ui_pr_no_sources.py +++ b/tests/test_pagure_flask_ui_pr_no_sources.py @@ -77,7 +77,7 @@ class PagureFlaskPrNoSourcestests(tests.Modeltests): self.assertTrue(os.path.exists(path)) def set_up_git_repo(self, repo, fork, branch_from="feature"): - """ Set up the git repo and create the corresponding PullRequest + """Set up the git repo and create the corresponding PullRequest object. """ @@ -162,8 +162,8 @@ class PagureFlaskPrNoSourcestests(tests.Modeltests): ) def test_accessing_pr_branch_deleted(self): - """ Test accessing the PR if branch it originates from has been - deleted. """ + """Test accessing the PR if branch it originates from has been + deleted.""" project = pagure.lib.query.get_authorized_project( self.session, "test", user="foo" ) @@ -193,8 +193,8 @@ class PagureFlaskPrNoSourcestests(tests.Modeltests): self.assertEqual(output2.status_code, 200) def test_accessing_pr_patch_branch_deleted(self): - """ Test accessing the PR's patch if branch it originates from has - been deleted. """ + """Test accessing the PR's patch if branch it originates from has + been deleted.""" project = pagure.lib.query.get_authorized_project( self.session, "test", user="foo" ) diff --git a/tests/test_pagure_flask_ui_priorities.py b/tests/test_pagure_flask_ui_priorities.py index bca2239..2969415 100644 --- a/tests/test_pagure_flask_ui_priorities.py +++ b/tests/test_pagure_flask_ui_priorities.py @@ -1315,7 +1315,7 @@ class PagureFlaskPrioritiestests(tests.Modeltests): @patch("pagure.lib.git.update_git", MagicMock(return_value=True)) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_default_priority_reset_when_updating_priorities(self): - """ Test updating the default priority of a repo when updating the + """Test updating the default priority of a repo when updating the priorities. """ tests.create_projects(self.session) diff --git a/tests/test_pagure_flask_ui_remote_pr.py b/tests/test_pagure_flask_ui_remote_pr.py index ad23a0c..b630da1 100644 --- a/tests/test_pagure_flask_ui_remote_pr.py +++ b/tests/test_pagure_flask_ui_remote_pr.py @@ -55,7 +55,7 @@ class PagureRemotePRtests(tests.Modeltests): shutil.rmtree(self.newpath) def set_up_git_repo(self, new_project=None, branch_from="feature"): - """ Set up the git repo and create the corresponding PullRequest + """Set up the git repo and create the corresponding PullRequest object. """ @@ -293,8 +293,8 @@ class PagureRemotePRtests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_new_remote_no_title(self): - """ Test creating a new remote PR authenticated when no title is - specified. """ + """Test creating a new remote PR authenticated when no title is + specified.""" tests.create_projects(self.session) tests.create_projects_git( @@ -341,8 +341,8 @@ class PagureRemotePRtests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_new_remote_pr_empty_target(self): - """ Test creating a new remote PR authenticated against an empty - git repo. """ + """Test creating a new remote PR authenticated against an empty + git repo.""" tests.create_projects(self.session) tests.create_projects_git( diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index e95149c..7658344 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -57,8 +57,8 @@ class PagureFlaskRepotests(tests.Modeltests): @patch("pagure.decorators.admin_session_timedout") def test_add_user_when_user_mngt_off(self, ast): - """ Test the add_user endpoint when user management is turned off - in the pagure instance """ + """Test the add_user endpoint when user management is turned off + in the pagure instance""" pagure.config.config["ENABLE_USER_MNGT"] = False ast.return_value = False @@ -234,8 +234,7 @@ class PagureFlaskRepotests(tests.Modeltests): @patch("pagure.decorators.admin_session_timedout") @patch.dict("pagure.config.config", {"DEPLOY_KEY": False}) def test_add_deploykey_disabled(self, ast): - """ Test the add_deploykey endpoint when it's disabled in the config. - """ + """Test the add_deploykey endpoint when it's disabled in the config.""" ast.return_value = False tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos")) @@ -473,7 +472,7 @@ class PagureFlaskRepotests(tests.Modeltests): @patch("pagure.decorators.admin_session_timedout") def test_add_group_project_when_user_mngt_off(self, ast): - """ Test the add_group_project endpoint when user management is + """Test the add_group_project endpoint when user management is turned off in the pagure instance""" pagure.config.config["ENABLE_USER_MNGT"] = False ast.return_value = False @@ -534,7 +533,7 @@ class PagureFlaskRepotests(tests.Modeltests): @patch.dict("pagure.config.config", {"ENABLE_GROUP_MNGT": False}) @patch("pagure.decorators.admin_session_timedout") def test_add_group_project_grp_mngt_off(self, ast): - """ Test the add_group_project endpoint when group management is + """Test the add_group_project endpoint when group management is turned off in the pagure instance""" ast.return_value = False @@ -783,7 +782,7 @@ class PagureFlaskRepotests(tests.Modeltests): @patch("pagure.decorators.admin_session_timedout") def test_remove_user_when_user_mngt_off(self, ast): - """ Test the remove_user endpoint when user management is turned + """Test the remove_user endpoint when user management is turned off in the pagure instance""" pagure.config.config["ENABLE_USER_MNGT"] = False ast.return_value = False @@ -936,7 +935,7 @@ class PagureFlaskRepotests(tests.Modeltests): @patch("pagure.decorators.admin_session_timedout") @patch.dict("pagure.config.config", {"DEPLOY_KEY": False}) def test_remove_deploykey_disabled(self, ast): - """ Test the remove_deploykey endpoint when it's disabled in the + """Test the remove_deploykey endpoint when it's disabled in the config. """ ast.return_value = False @@ -1156,7 +1155,7 @@ class PagureFlaskRepotests(tests.Modeltests): @patch("pagure.decorators.admin_session_timedout") def test_remove_group_project_when_user_mngt_off(self, ast): - """ Test the remove_group_project endpoint when user management is + """Test the remove_group_project endpoint when user management is turned off in the pagure instance""" pagure.config.config["ENABLE_USER_MNGT"] = False ast.return_value = False @@ -1525,7 +1524,7 @@ class PagureFlaskRepotests(tests.Modeltests): @patch("pagure.decorators.admin_session_timedout") def test_update_project_update_tag(self, ast): - """ Test the view_settings endpoint when updating the project's tags. + """Test the view_settings endpoint when updating the project's tags. We had an issue where when you add an existing tag to a project we were querying the wrong table in the database. It would thus not find @@ -1851,8 +1850,8 @@ class PagureFlaskRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_view_settings_custom_fields(self): - """ Test the view_settings endpoint when the project has some custom - field for issues. """ + """Test the view_settings endpoint when the project has some custom + field for issues.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos")) @@ -2114,8 +2113,8 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertEqual(output.status_code, 404) def test_view_repo_more_button_absent_no_auth(self): - """ Test the view_repo endpoint and check if the "more" button is - absent when not logged in. """ + """Test the view_repo endpoint and check if the "more" button is + absent when not logged in.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -2137,8 +2136,8 @@ class PagureFlaskRepotests(tests.Modeltests): self.perfReset() def test_view_repo_more_button_present(self): - """ Test the view_repo endpoint and check if the "more" button is - present when it should be. """ + """Test the view_repo endpoint and check if the "more" button is + present when it should be.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -2178,8 +2177,8 @@ class PagureFlaskRepotests(tests.Modeltests): self.perfReset() def test_view_repo_more_button_absent_no_access(self): - """ Test the view_repo endpoint and check if the "more" button is - absent if the user doesn't have access to the project. """ + """Test the view_repo endpoint and check if the "more" button is + absent if the user doesn't have access to the project.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -2205,8 +2204,8 @@ class PagureFlaskRepotests(tests.Modeltests): self.perfReset() def test_view_repo_ssh_key_not_uploaded_no_ssh_url(self): - """ Test viewing repo when user hasn't uploaded SSH key yet - and thus should see a message instead of url for SSH cloning. """ + """Test viewing repo when user hasn't uploaded SSH key yet + and thus should see a message instead of url for SSH cloning.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) user = tests.FakeUser(username="pingou") @@ -2221,8 +2220,8 @@ class PagureFlaskRepotests(tests.Modeltests): ) def test_view_repo_read_only_no_ssh_url(self): - """ Test viewing repo that is still readonly and thus user - should see a message instead of url for SSH cloning. """ + """Test viewing repo that is still readonly and thus user + should see a message instead of url for SSH cloning.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) repo = pagure.lib.query._get_project(self.session, "test") @@ -3497,8 +3496,8 @@ class PagureFlaskRepotests(tests.Modeltests): ) def test_view_commit_with_full_link(self): - """ Test the view_commit endpoint when the commit message includes - an url. """ + """Test the view_commit endpoint when the commit message includes + an url.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -3542,8 +3541,8 @@ class PagureFlaskRepotests(tests.Modeltests): ) def test_view_commit_with_short_link(self): - """ Test the view_commit endpoint when the commit message includes - an url. """ + """Test the view_commit endpoint when the commit message includes + an url.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -3900,8 +3899,8 @@ index 0000000..fb7093d @patch("pagure.lib.notify.send_email") @patch("pagure.decorators.admin_session_timedout") def test_delete_repo_when_turned_off(self, ast, send_email): - """ Test the delete_repo endpoint when deletion of a repo is - turned off in the pagure instance """ + """Test the delete_repo endpoint when deletion of a repo is + turned off in the pagure instance""" ast.return_value = False send_email.return_value = True @@ -4589,8 +4588,8 @@ index 0000000..fb7093d MagicMock(return_value=False), ) def test_delete_repo_no_ticket(self): - """ Test the delete_repo endpoint when tickets aren't enabled in - this pagure instance. """ + """Test the delete_repo endpoint when tickets aren't enabled in + this pagure instance.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos")) @@ -6317,8 +6316,8 @@ index 0000000..fb7093d @patch.dict("pagure.config.config", {"ALLOW_DELETE_BRANCH": False}) def test_delete_branch_disabled_in_ui(self): - """ Test that the delete branch button doesn't show when the feature - is turned off. """ + """Test that the delete branch button doesn't show when the feature + is turned off.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -6341,8 +6340,8 @@ index 0000000..fb7093d @patch.dict("pagure.config.config", {"ALLOW_DELETE_BRANCH": False}) def test_delete_branch_disabled(self): - """ Test the delete_branch endpoint when it's disabled in the entire - instance. """ + """Test the delete_branch endpoint when it's disabled in the entire + instance.""" tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, "repos"), bare=True) @@ -6371,8 +6370,8 @@ index 0000000..fb7093d @patch.dict("pagure.config.config", {"ALLOW_DELETE_BRANCH": False}) def test_delete_branch_disabled_fork(self): - """ Test the delete_branch endpoint when it's disabled in the entire - instance. """ + """Test the delete_branch endpoint when it's disabled in the entire + instance.""" item = pagure.lib.model.Project( user_id=2, # foo name="test", @@ -6892,7 +6891,7 @@ index 0000000..fb7093d {"UPLOAD_FOLDER_PATH": None, "UPLOAD_FOLDER_URL": None}, ) def test_releases_upload_folder_vars_None(self): - """ Test that /releases/ page of a repo displays correctly with + """Test that /releases/ page of a repo displays correctly with UPLOAD_FOLDER_PATH and UPLOAD_FOLDER_URL set to None """ tests.create_projects(self.session) diff --git a/tests/test_pagure_flask_ui_repo_delete_project.py b/tests/test_pagure_flask_ui_repo_delete_project.py index 6e2448b..6a2b2fe 100644 --- a/tests/test_pagure_flask_ui_repo_delete_project.py +++ b/tests/test_pagure_flask_ui_repo_delete_project.py @@ -73,7 +73,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_repo_when_turned_off(self): - """ Test the delete_repo endpoint for a fork when only deleting main + """Test the delete_repo endpoint for a fork when only deleting main project is forbidden. """ @@ -91,7 +91,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_button_present(self): - """ Test that the delete button is present when deletions are + """Test that the delete button is present when deletions are allowed. """ @@ -116,7 +116,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_button_absent(self): - """ Test that the delete button is absent when deletions are not + """Test that the delete button is absent when deletions are not allowed. """ @@ -142,7 +142,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_fork_when_project_off_refreshing(self): - """ Test the delete_repo endpoint for a fork when only deleting main + """Test the delete_repo endpoint for a fork when only deleting main project is forbidden but the fork is being refreshed in the backend """ project = pagure.lib.query.get_authorized_project( @@ -182,7 +182,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_fork_when_project_off(self): - """ Test the delete_repo endpoint for a fork when only deleting main + """Test the delete_repo endpoint for a fork when only deleting main project is forbidden. """ project = pagure.lib.query.get_authorized_project( @@ -296,7 +296,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_fork_when_fork_and_project_off(self): - """ Test the delete_repo endpoint for a fork when deleting fork and + """Test the delete_repo endpoint for a fork when deleting fork and project is forbidden. """ @@ -318,7 +318,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_fork_button_absent(self): - """ Test that the delete button is absent when deletions are not + """Test that the delete button is absent when deletions are not allowed. """ @@ -346,7 +346,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_fork_button_fork_del_allowed(self): - """ Test that the delete button is present when deletions of projects + """Test that the delete button is present when deletions of projects is not allowed but deletions of forks is. """ @@ -383,7 +383,7 @@ class PagureFlaskDeleteRepotests(tests.Modeltests): MagicMock(return_value=False), ) def test_delete_fork_button_fork_del_allowed_read_only(self): - """ Test that the delete button is absent when deletions of projects + """Test that the delete button is absent when deletions of projects is not allowed but deletions of forks is but fork is still being processed. """ diff --git a/tests/test_pagure_flask_ui_repo_milestones.py b/tests/test_pagure_flask_ui_repo_milestones.py index ad72681..094c295 100644 --- a/tests/test_pagure_flask_ui_repo_milestones.py +++ b/tests/test_pagure_flask_ui_repo_milestones.py @@ -129,8 +129,7 @@ class PagureFlaskRepoMilestonestests(tests.Modeltests): MagicMock(return_value=False), ) def test_issue_page_milestone_actives(self): - """ Test viewing tickets on a project having milestones, all active. - """ + """Test viewing tickets on a project having milestones, all active.""" repo = pagure.lib.query.get_authorized_project(self.session, "test") @@ -160,7 +159,7 @@ class PagureFlaskRepoMilestonestests(tests.Modeltests): MagicMock(return_value=False), ) def test_issue_page_milestone_not_allactives(self): - """ Test viewing tickets on a project having milestones, not all + """Test viewing tickets on a project having milestones, not all being active. """ diff --git a/tests/test_pagure_flask_ui_repo_mirrored_from.py b/tests/test_pagure_flask_ui_repo_mirrored_from.py index 6cbfc30..541972e 100644 --- a/tests/test_pagure_flask_ui_repo_mirrored_from.py +++ b/tests/test_pagure_flask_ui_repo_mirrored_from.py @@ -33,8 +33,7 @@ from pagure.lib.repo import PagureRepo class PagureUiRepoMirroredFromTests(tests.Modeltests): - """ Tests for pagure project that are mirrored from a remote location - """ + """Tests for pagure project that are mirrored from a remote location""" maxDiff = None @@ -54,7 +53,7 @@ class PagureUiRepoMirroredFromTests(tests.Modeltests): self.session.commit() def test_custom_projecticon(self): - """ Ensure that the customized project icon is shown the main page of + """Ensure that the customized project icon is shown the main page of the project. """ output = self.app.get("/test") @@ -66,7 +65,7 @@ class PagureUiRepoMirroredFromTests(tests.Modeltests): ) def test_regular_projecticon(self): - """ Ensure that the customized project icon is shown the main page of + """Ensure that the customized project icon is shown the main page of the project. """ output = self.app.get("/test2") @@ -77,7 +76,7 @@ class PagureUiRepoMirroredFromTests(tests.Modeltests): ) def test_settings_shows(self): - """ Ensure that the box to edit the mirrored from value shows up + """Ensure that the box to edit the mirrored from value shows up in the settings. """ user = tests.FakeUser(username="pingou") @@ -96,7 +95,7 @@ class PagureUiRepoMirroredFromTests(tests.Modeltests): ) def test_settings_not_show(self): - """ Ensure that the box to edit the mirrored from value does not + """Ensure that the box to edit the mirrored from value does not show up in the settings when it shouldn't. """ user = tests.FakeUser(username="pingou") @@ -114,7 +113,7 @@ class PagureUiRepoMirroredFromTests(tests.Modeltests): ) def test_edit_mirrored_from(self): - """ Ensure that we can successfully edit the content of the + """Ensure that we can successfully edit the content of the mirrored_from field. """ user = tests.FakeUser(username="pingou") diff --git a/tests/test_pagure_flask_ui_repo_slash_name.py b/tests/test_pagure_flask_ui_repo_slash_name.py index 028f542..6210580 100644 --- a/tests/test_pagure_flask_ui_repo_slash_name.py +++ b/tests/test_pagure_flask_ui_repo_slash_name.py @@ -30,8 +30,7 @@ from pagure.lib.repo import PagureRepo class PagureFlaskSlashInNametests(tests.SimplePagureTest): - """ Tests for flask application when the project contains a '/'. - """ + """Tests for flask application when the project contains a '/'.""" def setUp(self): """ Set up the environnment, ran before every tests. """ @@ -74,7 +73,7 @@ class PagureFlaskSlashInNametests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_repo_empty(self, send_email): - """ Test the view_repo endpoint when the project has a slash in its + """Test the view_repo endpoint when the project has a slash in its name. """ send_email.return_value = True @@ -159,7 +158,7 @@ class PagureFlaskSlashInNametests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_repo(self, send_email): - """ Test the view_repo endpoint when the project has a slash in its + """Test the view_repo endpoint when the project has a slash in its name. """ send_email.return_value = True diff --git a/tests/test_pagure_flask_ui_repo_view_file.py b/tests/test_pagure_flask_ui_repo_view_file.py index effa06b..f2b8441 100644 --- a/tests/test_pagure_flask_ui_repo_view_file.py +++ b/tests/test_pagure_flask_ui_repo_view_file.py @@ -223,7 +223,7 @@ class PagureFlaskRepoViewFiletests(LocalBasetests): ) def test_view_file_fork_and_edit_logged_out(self): - """ Test the view_file fork and edit button presence when logged + """Test the view_file fork and edit button presence when logged out. """ @@ -244,7 +244,7 @@ class PagureFlaskRepoViewFiletests(LocalBasetests): ) def test_view_file_fork_and_edit_logged_in(self): - """ Test the view_file fork and edit button presence when logged + """Test the view_file fork and edit button presence when logged in. """ @@ -360,8 +360,7 @@ class PagureFlaskRepoViewFileForktests(LocalBasetests): ) def test_view_file_fork_and_edit_on_your_fork(self): - """ Test the view_file on a text file on your fork when logged in. - """ + """Test the view_file on a text file on your fork when logged in.""" # logged in, but it's your own fork, so just edit button is there user = tests.FakeUser(username="pingou") @@ -382,7 +381,7 @@ class PagureFlaskRepoViewFileForktests(LocalBasetests): ) def test_view_file_fork_and_edit_on_a_fork(self): - """ Test the view_file on a text file on somone else's fork when + """Test the view_file on a text file on somone else's fork when logged in. """ @@ -406,7 +405,7 @@ class PagureFlaskRepoViewFileForktests(LocalBasetests): ) def test_view_file_fork_and_edit_on_project(self): - """ Test the view_file on a text file on somone else's fork when + """Test the view_file on a text file on somone else's fork when logged in. """ diff --git a/tests/test_pagure_flask_ui_slash_branch_name.py b/tests/test_pagure_flask_ui_slash_branch_name.py index cbb2e11..9272968 100644 --- a/tests/test_pagure_flask_ui_slash_branch_name.py +++ b/tests/test_pagure_flask_ui_slash_branch_name.py @@ -30,8 +30,7 @@ from pagure.lib.repo import PagureRepo class PagureFlaskSlashInBranchtests(tests.SimplePagureTest): - """ Tests for flask application when the branch name contains a '/'. - """ + """Tests for flask application when the branch name contains a '/'.""" def set_up_git_repo(self): """ Set up the git repo to play with. """ @@ -99,7 +98,7 @@ class PagureFlaskSlashInBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_repo(self, send_email): - """ Test the view_repo endpoint when the git repo has no master + """Test the view_repo endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -147,7 +146,7 @@ class PagureFlaskSlashInBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_commits(self, send_email): - """ Test the view_commits endpoint when the git repo has no + """Test the view_commits endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -176,7 +175,7 @@ class PagureFlaskSlashInBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_file(self, send_email): - """ Test the view_file endpoint when the git repo has no + """Test the view_file endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -236,7 +235,7 @@ class PagureFlaskSlashInBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_raw_file(self, send_email): - """ Test the view_raw_file endpoint when the git repo has no + """Test the view_raw_file endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -272,7 +271,7 @@ class PagureFlaskSlashInBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_view_tree(self, send_email): - """ Test the view_tree endpoint when the git repo has no + """Test the view_tree endpoint when the git repo has no master branch. """ send_email.return_value = True @@ -317,7 +316,7 @@ class PagureFlaskSlashInBranchtests(tests.SimplePagureTest): @patch("pagure.lib.notify.send_email") def test_new_request_pull(self, send_email): - """ Test the new_request_pull endpoint when the git repo has no + """Test the new_request_pull endpoint when the git repo has no master branch. """ send_email.return_value = True diff --git a/tests/test_pagure_flask_ui_star_project.py b/tests/test_pagure_flask_ui_star_project.py index 26e707e..ff4e31b 100644 --- a/tests/test_pagure_flask_ui_star_project.py +++ b/tests/test_pagure_flask_ui_star_project.py @@ -56,8 +56,8 @@ class TestStarProjectUI(tests.SimplePagureTest): self.assertEqual(output.status_code, 404) def test_star_project_no_csrf(self): - """ Test the star_project endpoint for the case when there - is no CSRF token given """ + """Test the star_project endpoint for the case when there + is no CSRF token given""" user = tests.FakeUser() user.username = "pingou" diff --git a/tests/test_pagure_hooks_pagure_hook.py b/tests/test_pagure_hooks_pagure_hook.py index b351fd2..be629a1 100644 --- a/tests/test_pagure_hooks_pagure_hook.py +++ b/tests/test_pagure_hooks_pagure_hook.py @@ -95,7 +95,7 @@ class PagureHooksPagureHooktests(tests.SimplePagureTest): @mock.patch("pagure.hooks.pagure_hook.fixes_relation") def test_generate_revision_change_log_short_url(self, fixes_relation): - """ Test generate_revision_change_log when the comment contains + """Test generate_revision_change_log when the comment contains a short link to the same project. """ @@ -127,7 +127,7 @@ class PagureHooksPagureHooktests(tests.SimplePagureTest): @mock.patch("pagure.hooks.pagure_hook.fixes_relation") def test_generate_revision_change_log_full_url(self, fixes_relation): - """ Test generate_revision_change_log when the comment contains + """Test generate_revision_change_log when the comment contains a full link to another project. """ @@ -163,7 +163,7 @@ class PagureHooksPagureHooktests(tests.SimplePagureTest): @mock.patch("pagure.hooks.pagure_hook.fixes_relation") def test_generate_revision_change_log_full_url_fork(self, fixes_relation): - """ Test generate_revision_change_log when the comment contains + """Test generate_revision_change_log when the comment contains a full link to a fork. """ diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py index d9adba4..d35c393 100644 --- a/tests/test_pagure_lib.py +++ b/tests/test_pagure_lib.py @@ -727,8 +727,7 @@ class PagureLibtests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_edit_issue_priority(self, p_send_email, p_ugt): - """ Test the edit_issue of pagure.lib when changing the priority. - """ + """Test the edit_issue of pagure.lib when changing the priority.""" p_send_email.return_value = True p_ugt.return_value = True @@ -770,7 +769,7 @@ class PagureLibtests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def test_edit_issue_depending(self, p_send_email, p_ugt): - """ Test the edit_issue of pagure.lib when the issue depends on + """Test the edit_issue of pagure.lib when the issue depends on another. """ p_send_email.return_value = True @@ -2183,7 +2182,7 @@ class PagureLibtests(tests.Modeltests): clear=True, ) def test_set_up_user_multiple_emaildomains(self): - """ Test the set_up_user of pagure.lib when there are + """Test the set_up_user of pagure.lib when there are multimple domains configured in ALLOWED_EMAIL_DOMAINS""" items = pagure.lib.query.search_user(self.session) @@ -4430,8 +4429,7 @@ class PagureLibtests(tests.Modeltests): ) def test_get_project_users(self): - """ Test the get_project_users method when combine is True - """ + """Test the get_project_users method when combine is True""" tests.create_projects(self.session) project = pagure.lib.query.get_authorized_project( @@ -4546,8 +4544,7 @@ class PagureLibtests(tests.Modeltests): self.assertEqual(users[0].username, "foo") def test_get_project_users_combine_false(self): - """ Test the get_project_users method when combine is False - """ + """Test the get_project_users method when combine is False""" tests.create_projects(self.session) project = pagure.lib.query.get_authorized_project( @@ -4634,8 +4631,7 @@ class PagureLibtests(tests.Modeltests): self.assertEqual(users[0].username, "foo") def test_get_project_groups(self): - """ Test the get_project_groups method when combine is True - """ + """Test the get_project_groups method when combine is True""" # Create some projects tests.create_projects(self.session) @@ -4766,8 +4762,7 @@ class PagureLibtests(tests.Modeltests): self.assertEqual(project.groups[0].display_name, "Justice League") def test_get_project_groups_combine_false(self): - """ Test the get_project_groups method when combine is False - """ + """Test the get_project_groups method when combine is False""" # Create some projects tests.create_projects(self.session) @@ -4884,8 +4879,8 @@ class PagureLibtests(tests.Modeltests): self.assertEqual(project.groups[0].display_name, "Justice League") def test_get_obj_access_user(self): - """ Test the get_obj_access method of pagure.lib - for model.User object """ + """Test the get_obj_access method of pagure.lib + for model.User object""" # Create the projects tests.create_projects(self.session) @@ -4948,8 +4943,8 @@ class PagureLibtests(tests.Modeltests): self.assertEqual(access_obj.access, "ticket") def test_get_obj_access_group(self): - """ Test the get_obj_access method of pagure.lib - for model.PagureGroup object """ + """Test the get_obj_access method of pagure.lib + for model.PagureGroup object""" # Create the projects tests.create_projects(self.session) @@ -5206,7 +5201,7 @@ foo bar self.assertEqual(html, expected) def test_text2markdown_table_old_mk(self): - """ Test the text2markdown function with a markdown table using the old + """Test the text2markdown function with a markdown table using the old format where the orientation instruction are provided next to the column delimiter unlike what can be done with more recent version of markdown. """ @@ -5305,8 +5300,8 @@ foo bar self.assertEqual(key[3], "(RSA)") def test_create_deploykeys_ssh_keys_on_disk_empty(self): - """ Test the create_deploykeys_ssh_keys_on_disk function of - pagure.lib.query. """ + """Test the create_deploykeys_ssh_keys_on_disk function of + pagure.lib.query.""" self.assertIsNone( pagure.lib.query.create_deploykeys_ssh_keys_on_disk(None, None) ) @@ -5315,8 +5310,8 @@ foo bar ) def test_create_deploykeys_ssh_keys_on_disk_nokey(self): - """ Test the create_deploykeys_ssh_keys_on_disk function of - pagure.lib.query. """ + """Test the create_deploykeys_ssh_keys_on_disk function of + pagure.lib.query.""" tests.create_projects(self.session) project = pagure.lib.query._get_project(self.session, "test") @@ -5336,8 +5331,8 @@ foo bar "pagure.lib.query.is_valid_ssh_key", MagicMock(return_value="foo bar") ) def test_create_deploykeys_ssh_keys_on_disk(self): - """ Test the create_deploykeys_ssh_keys_on_disk function of - pagure.lib.query. """ + """Test the create_deploykeys_ssh_keys_on_disk function of + pagure.lib.query.""" tests.create_projects(self.session) project = pagure.lib.query._get_project(self.session, "test") @@ -5388,8 +5383,8 @@ foo bar MagicMock(return_value="\nfoo bar"), ) def test_create_deploykeys_ssh_keys_on_disk_empty_first_key(self): - """ Test the create_deploykeys_ssh_keys_on_disk function of - pagure.lib.query. """ + """Test the create_deploykeys_ssh_keys_on_disk function of + pagure.lib.query.""" tests.create_projects(self.session) project = pagure.lib.query._get_project(self.session, "test") @@ -5419,8 +5414,8 @@ foo bar ) def test_create_deploykeys_ssh_keys_on_disk_invalid(self): - """ Test the create_deploykeys_ssh_keys_on_disk function of - pagure.lib.query. """ + """Test the create_deploykeys_ssh_keys_on_disk function of + pagure.lib.query.""" tests.create_projects(self.session) project = pagure.lib.query._get_project(self.session, "test") @@ -5508,7 +5503,7 @@ foo bar clear=True, ) def test_add_email_to_user_with_logs(self): - """ Test the add_email_to_user function of pagure.lib when there + """Test the add_email_to_user function of pagure.lib when there are log entries associated to the email added. """ user = pagure.lib.query.search_user(self.session, username="pingou") diff --git a/tests/test_pagure_lib_add_user_to_project.py b/tests/test_pagure_lib_add_user_to_project.py index 0fe5e2c..c5aa1ec 100644 --- a/tests/test_pagure_lib_add_user_to_project.py +++ b/tests/test_pagure_lib_add_user_to_project.py @@ -79,8 +79,7 @@ class PagureLibAddUserToProjecttests(tests.Modeltests): @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_update_user_to_project_default(self): - """ Update an existing user without any required group membership. - """ + """Update an existing user without any required group membership.""" repo = pagure.lib.query._get_project(self.session, "test") # Update the access of the user diff --git a/tests/test_pagure_lib_drop_issue.py b/tests/test_pagure_lib_drop_issue.py index 54e3266..e60b0a6 100644 --- a/tests/test_pagure_lib_drop_issue.py +++ b/tests/test_pagure_lib_drop_issue.py @@ -32,7 +32,7 @@ class PagureLibDropIssuetests(tests.Modeltests): @patch("pagure.lib.git.update_git") @patch("pagure.lib.notify.send_email") def setUp(self, p_send_email, p_ugt): - """ Create a couple of tickets and add tag to the project so we can + """Create a couple of tickets and add tag to the project so we can play with them later. """ super(PagureLibDropIssuetests, self).setUp() @@ -95,7 +95,7 @@ class PagureLibDropIssuetests(tests.Modeltests): @patch("pagure.lib.notify.send_email") @patch("pagure.lib.git._maybe_wait", tests.definitely_wait) def test_drop_issue(self, p_send_email, p_ugt): - """ Test the drop_issue of pagure.lib.query. + """Test the drop_issue of pagure.lib.query. We had an issue where we could not delete issue that had been tagged with this test, we create two issues, tag one of them and delete @@ -135,7 +135,7 @@ class PagureLibDropIssuetests(tests.Modeltests): @patch("pagure.lib.notify.send_email") @patch("pagure.lib.git._maybe_wait", tests.definitely_wait) def test_drop_issue_two_issues_one_tag(self, p_send_email, p_ugt): - """ Test the drop_issue of pagure.lib.query. + """Test the drop_issue of pagure.lib.query. We had an issue where we could not delete issue that had been tagged with this test, we create two issues, tag them both and delete one diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index 229bcfe..1840a46 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -38,8 +38,8 @@ class PagureLibGittests(tests.Modeltests): maxDiff = None def test_write_gitolite_acls(self): - """ Test the write_gitolite_acls function of pagure.lib.git. - when the new uesr is an made an admin """ + """Test the write_gitolite_acls function of pagure.lib.git. + when the new uesr is an made an admin""" tests.create_projects(self.session) repo = pagure.lib.query.get_authorized_project(self.session, "test") @@ -143,8 +143,8 @@ repo requests/forks/pingou/test3 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_acls_preconf(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a preconf set """ + """Test the write_gitolite_acls function of pagure.lib.git with + a preconf set""" tests.create_projects(self.session) outputconf = os.path.join(self.path, "test_gitolite.conf") @@ -214,8 +214,8 @@ repo requests/somenamespace/test3 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_acls_preconf_postconf(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a postconf set """ + """Test the write_gitolite_acls function of pagure.lib.git with + a postconf set""" tests.create_projects(self.session) outputconf = os.path.join(self.path, "test_gitolite.conf") @@ -295,8 +295,8 @@ repo requests/somenamespace/test3 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_acls_postconf(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a preconf and a postconf set """ + """Test the write_gitolite_acls function of pagure.lib.git with + a preconf and a postconf set""" tests.create_projects(self.session) outputconf = os.path.join(self.path, "test_gitolite.conf") @@ -483,8 +483,8 @@ repo requests/forks/pingou/test3 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_acls_ticket(self): - """ Test the write_gitolite_acls function of pagure.lib.git. - when the new uesr is just a ticketer """ + """Test the write_gitolite_acls function of pagure.lib.git. + when the new uesr is just a ticketer""" tests.create_projects(self.session) repo = pagure.lib.query.get_authorized_project(self.session, "test") @@ -586,8 +586,8 @@ repo requests/forks/pingou/test3 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_acls_commit(self): - """ Test the write_gitolite_acls function of pagure.lib.git. - when the new uesr is just a committer """ + """Test the write_gitolite_acls function of pagure.lib.git. + when the new uesr is just a committer""" tests.create_projects(self.session) repo = pagure.lib.query.get_authorized_project(self.session, "test") @@ -693,7 +693,7 @@ repo requests/forks/pingou/test3 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_acls_groups(self): - """ Test the write_gitolite_acls function of pagure.lib.git with + """Test the write_gitolite_acls function of pagure.lib.git with groups as admin """ tests.create_projects(self.session) @@ -847,7 +847,7 @@ repo requests/forks/pingou/test2 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_acls_groups_ticket(self): - """ Test the write_gitolite_acls function of pagure.lib.git with + """Test the write_gitolite_acls function of pagure.lib.git with groups as ticketers """ tests.create_projects(self.session) @@ -1002,7 +1002,7 @@ repo requests/forks/pingou/test2 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_acls_groups_commit(self): - """ Test the write_gitolite_acls function of pagure.lib.git with + """Test the write_gitolite_acls function of pagure.lib.git with groups as committers """ tests.create_projects(self.session) @@ -1161,7 +1161,7 @@ repo requests/forks/pingou/test2 self.assertFalse(os.path.exists(outputconf)) def test_write_gitolite_project_pr_only(self): - """ Test the write_gitolite_acls function of pagure.lib.git. + """Test the write_gitolite_acls function of pagure.lib.git. when the project enforces the PR approach. """ tests.create_projects(self.session) @@ -1268,7 +1268,7 @@ repo requests/forks/pingou/test3 @patch.dict("pagure.config.config", {"PR_ONLY": True}) def test_write_gitolite_global_pr_only(self): - """ Test the write_gitolite_acls function of pagure.lib.git. + """Test the write_gitolite_acls function of pagure.lib.git. when the pagure instance enforces the PR approach. """ tests.create_projects(self.session) @@ -3355,8 +3355,8 @@ index 0000000..60f7480 @patch("pagure.lib.notify.send_email") @patch("pagure.lib.git.update_git") def test_merge_pull_request_no_master(self, email_f, up_git): - """ Test the merge_pull_request function when there are no master - branch in the repo. """ + """Test the merge_pull_request function when there are no master + branch in the repo.""" email_f.return_value = True up_git.return_value = True @@ -3436,8 +3436,8 @@ index 0000000..60f7480 @patch("pagure.lib.notify.send_email") @patch("pagure.lib.git.update_git") def test_merge_pull_request_closed(self, email_f, up_git): - """ Test the merge_pull_request function when the PR was already - closed/merged. """ + """Test the merge_pull_request function when the PR was already + closed/merged.""" email_f.return_value = True up_git.return_value = True diff --git a/tests/test_pagure_lib_git_diff_pr.py b/tests/test_pagure_lib_git_diff_pr.py index f482a24..3861873 100644 --- a/tests/test_pagure_lib_git_diff_pr.py +++ b/tests/test_pagure_lib_git_diff_pr.py @@ -326,7 +326,7 @@ class PagureFlaskForkPrtests(tests.Modeltests): "pagure.config.config", {"FEDORA_MESSAGING_NOTIFICATIONS": True} ) def test_diff_pull_request_updated(self): - """ Test that calling pagure.lib.git.diff_pull_request on an updated + """Test that calling pagure.lib.git.diff_pull_request on an updated PR updates the PR reference """ gitrepo = os.path.join(self.path, "repos", "test.git") @@ -758,7 +758,7 @@ class PagureFlaskForkPrtests(tests.Modeltests): self.assertNotEqual(commit.oid.hex, commit2.oid.hex) def test_two_diff_pull_request_sequentially(self): - """ Test calling pagure.lib.git.diff_pull_request twice returns + """Test calling pagure.lib.git.diff_pull_request twice returns the same data """ gitrepo = os.path.join(self.path, "repos", "test.git") diff --git a/tests/test_pagure_lib_gitolite_config.py b/tests/test_pagure_lib_gitolite_config.py index d080612..b95babe 100644 --- a/tests/test_pagure_lib_gitolite_config.py +++ b/tests/test_pagure_lib_gitolite_config.py @@ -110,8 +110,8 @@ class PagureLibGitoliteConfigtests(tests.Modeltests): self.assertFalse(os.path.exists(self.outputconf)) def test_write_gitolite_pre_post_projectNone(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a postconf set """ + """Test the write_gitolite_acls function of pagure.lib.git with + a postconf set""" helper = pagure.lib.git_auth.get_git_auth_helper("gitolite3") helper.write_gitolite_acls( @@ -147,8 +147,8 @@ class PagureLibGitoliteConfigtests(tests.Modeltests): self.assertEqual(data, exp) def test_write_gitolite_pre_post_projectNone_to_existing_file(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a postconf set with existing output file """ + """Test the write_gitolite_acls function of pagure.lib.git with + a postconf set with existing output file""" with open(self.outputconf, "w") as stream: pass @@ -168,8 +168,8 @@ class PagureLibGitoliteConfigtests(tests.Modeltests): self.assertEqual(data, "") def test_write_gitolite_pre_post_project_1(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a postconf set """ + """Test the write_gitolite_acls function of pagure.lib.git with + a postconf set""" with open(self.outputconf, "w") as stream: pass @@ -209,8 +209,8 @@ class PagureLibGitoliteConfigtests(tests.Modeltests): self.assertEqual(data, exp) def test_write_gitolite_pre_post_project_test(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a postconf set """ + """Test the write_gitolite_acls function of pagure.lib.git with + a postconf set""" with open(self.outputconf, "w") as stream: pass @@ -260,8 +260,8 @@ repo requests/test self.assertEqual(data, exp) def test_write_gitolite_pre_post_project_test_full_file(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a postconf set """ + """Test the write_gitolite_acls function of pagure.lib.git with + a postconf set""" # Re-generate the gitolite config for all the projects self.test_write_gitolite_pre_post_project_1() @@ -362,8 +362,8 @@ repo requests/test "pagure.config.config", {"ENABLE_DOCS": False, "ENABLE_TICKETS": False} ) def test_write_gitolite_disabled_docs_tickets(self): - """ Test the write_gitolite_acls function when docs and tickets - are disabled """ + """Test the write_gitolite_acls function when docs and tickets + are disabled""" # Re-generate the gitolite config for all the projects project = pagure.lib.query._get_project(self.session, "test") @@ -421,7 +421,7 @@ repo requests/somenamespace/test3 class PagureLibGitoliteGroupConfigtests(tests.Modeltests): - """ Tests for generating the gitolite configuration file for a group + """Tests for generating the gitolite configuration file for a group change """ @@ -741,7 +741,7 @@ repo requests/test self.assertEqual(data, exp) def test_write_gitolite_delete_group(self): - """ Test the updating the gitolite config after having + """Test the updating the gitolite config after having deleted a group. """ @@ -793,8 +793,8 @@ repo requests/test @patch("pagure.lib.git_auth.get_git_auth_helper") def test_task_generate_gitolite_acls_one_group(self, get_helper): - """ Test the generate_gitolite_acls task to ensure if group is None - then None is passed to the helper. """ + """Test the generate_gitolite_acls task to ensure if group is None + then None is passed to the helper.""" helper = MagicMock() get_helper.return_value = helper pagure.lib.query.SESSIONMAKER = self.session.session_factory @@ -809,8 +809,8 @@ repo requests/test self.assertIsNotNone(args[1].get("project")) def test_write_gitolite_project_test_private(self): - """ Test the write_gitolite_acls function of pagure.lib.git with - a postconf set """ + """Test the write_gitolite_acls function of pagure.lib.git with + a postconf set""" # Make the test project private project = pagure.lib.query._get_project(self.session, "test") @@ -876,8 +876,8 @@ repo requests/somenamespace/test3 self.assertEqual(data, exp) def test_remove_acls(self): - """ Test the remove_acls function of pagure.lib.git when deleting - a project """ + """Test the remove_acls function of pagure.lib.git when deleting + a project""" pagure.config.config["GITOLITE_CONFIG"] = self.outputconf with open(self.outputconf, "w") as stream: @@ -954,8 +954,8 @@ repo requests/somenamespace/test3 self.assertEqual(data, exp) def test_remove_acls_no_project(self): - """ Test the remove_acls function of pagure.lib.git when no project - is specified """ + """Test the remove_acls function of pagure.lib.git when no project + is specified""" pagure.config.config["GITOLITE_CONFIG"] = self.outputconf with open(self.outputconf, "w") as stream: diff --git a/tests/test_pagure_lib_link.py b/tests/test_pagure_lib_link.py index eb4b192..e36a754 100644 --- a/tests/test_pagure_lib_link.py +++ b/tests/test_pagure_lib_link.py @@ -41,8 +41,7 @@ class PagureLibLinktests(tests.Modeltests): """ Tests for pagure.lib.link """ def test_get_relation_relates(self): - """ Test the get_relation function of pagure.lib.link with relates. - """ + """Test the get_relation function of pagure.lib.link with relates.""" link = pagure.lib.link.get_relation( self.session, @@ -142,8 +141,7 @@ class PagureLibLinktests(tests.Modeltests): self.assertEqual(link, []) def test_get_relation_fixes(self): - """ Test the get_relation function of pagure.lib.link with fixes. - """ + """Test the get_relation function of pagure.lib.link with fixes.""" link = pagure.lib.link.get_relation( self.session, diff --git a/tests/test_pagure_lib_login.py b/tests/test_pagure_lib_login.py index d6c7213..3809d03 100644 --- a/tests/test_pagure_lib_login.py +++ b/tests/test_pagure_lib_login.py @@ -107,8 +107,7 @@ class PagureLibLogintests(tests.Modeltests): ) def test_unicode_required(self): - """ Test to check for non-ascii password - """ + """Test to check for non-ascii password""" self.assertRaises( ValueError, pagure.lib.login.generate_hashed_value, diff --git a/tests/test_pagure_lib_model_delete_project.py b/tests/test_pagure_lib_model_delete_project.py index 3f6c78e..0b7ca2f 100644 --- a/tests/test_pagure_lib_model_delete_project.py +++ b/tests/test_pagure_lib_model_delete_project.py @@ -148,8 +148,8 @@ class DeleteProjectTests(tests.Modeltests): self.assertEqual(self.session.query(model.TagColored).count(), 0) def test_delete_project_with_coloredtags_and_issues(self): - """ Test the model when we delete a project with Colored tags and - issues. """ + """Test the model when we delete a project with Colored tags and + issues.""" # Create a project item = model.Project( @@ -212,8 +212,8 @@ class DeleteProjectTests(tests.Modeltests): self.assertEqual(self.session.query(model.Issue).count(), 0) def test_delete_project_with_coloredtags_and_tagged_issues(self): - """ Test the model when we delete a project with Colored tags and - tagged issues. """ + """Test the model when we delete a project with Colored tags and + tagged issues.""" # Create a project item = model.Project( diff --git a/tests/test_pagure_lib_notify.py b/tests/test_pagure_lib_notify.py index 78af57a..63ace5c 100644 --- a/tests/test_pagure_lib_notify.py +++ b/tests/test_pagure_lib_notify.py @@ -500,8 +500,8 @@ RW1haWwgY29udGVudA== @patch.dict("pagure.config.config", {"EVENTSOURCE_SOURCE": None}) @patch("pagure.lib.notify.smtplib.SMTP") def test_send_email_no_reply_to(self, mock_smtp): - """ Test the send_email method from pagure.lib.notify when there - should not be a Reply-To header even if mail_id is defined. """ + """Test the send_email method from pagure.lib.notify when there + should not be a Reply-To header even if mail_id is defined.""" mock_smtp.return_value = MagicMock() email = pagure.lib.notify.send_email( diff --git a/tests/test_pagure_lib_notify_email.py b/tests/test_pagure_lib_notify_email.py index c5d1c49..2738e26 100644 --- a/tests/test_pagure_lib_notify_email.py +++ b/tests/test_pagure_lib_notify_email.py @@ -29,7 +29,7 @@ import tests # pylint: disable=wrong-import-position class PagureLibNotifyEmailtests(tests.Modeltests): - """ Some tests for the various email construction functions. In + """Some tests for the various email construction functions. In their own class so they can have some shared fixtures. """ diff --git a/tests/test_pagure_lib_plugins.py b/tests/test_pagure_lib_plugins.py index 7163f67..ecf2986 100644 --- a/tests/test_pagure_lib_plugins.py +++ b/tests/test_pagure_lib_plugins.py @@ -45,7 +45,7 @@ class PagureLibtests_plugins(tests.Modeltests): @patch("pagure.lib.plugins.load") def test_plugin_is_enabled_for(self, load): - """ Test the is_enabled_for method of plugins is properly + """Test the is_enabled_for method of plugins is properly handled by pagure.lib.plugins.get_enabled_plugins. """ tests.create_projects(self.session) @@ -62,7 +62,7 @@ class PagureLibtests_plugins(tests.Modeltests): @patch("pagure.lib.plugins.load") def test_get_plugin_names(self, load): - """ Test the get_plugin_names method with plugins that don't + """Test the get_plugin_names method with plugins that don't have backref. """ load.return_value = [EnabledForAll] diff --git a/tests/test_pagure_lib_watch_list.py b/tests/test_pagure_lib_watch_list.py index 29049ee..13e1070 100644 --- a/tests/test_pagure_lib_watch_list.py +++ b/tests/test_pagure_lib_watch_list.py @@ -53,8 +53,8 @@ class PagureLibGetWatchListtests(tests.Modeltests): ) def test_get_watch_list_simple(self): - """ Test get_watch_list when the creator of the ticket is the - creator of the project """ + """Test get_watch_list when the creator of the ticket is the + creator of the project""" # Create a project ns/test item = pagure.lib.model.Project( user_id=1, # pingou @@ -85,8 +85,8 @@ class PagureLibGetWatchListtests(tests.Modeltests): ) def test_get_watch_list_different_creator(self): - """ Test get_watch_list when the creator of the ticket is not the - creator of the project """ + """Test get_watch_list when the creator of the ticket is not the + creator of the project""" # Create a project ns/test item = pagure.lib.model.Project( user_id=1, # pingou @@ -118,8 +118,8 @@ class PagureLibGetWatchListtests(tests.Modeltests): ) def test_get_watch_list_project_w_contributor(self): - """ Test get_watch_list when the project has more than one - contributor """ + """Test get_watch_list when the project has more than one + contributor""" # Create a project ns/test3 item = pagure.lib.model.Project( user_id=1, # pingou @@ -174,8 +174,7 @@ class PagureLibGetWatchListtests(tests.Modeltests): ) def test_get_watch_list_user_in_group(self): - """ Test get_watch_list when the project has groups of contributors - """ + """Test get_watch_list when the project has groups of contributors""" # Create a project ns/test3 item = pagure.lib.model.Project( user_id=1, # pingou @@ -258,8 +257,8 @@ class PagureLibGetWatchListtests(tests.Modeltests): ) def test_get_watch_list_project_w_contributor_out(self): - """ Test get_watch_list when the project has one contributor not - watching the project """ + """Test get_watch_list when the project has one contributor not + watching the project""" # Create a project ns/test3 item = pagure.lib.model.Project( user_id=1, # pingou @@ -321,8 +320,8 @@ class PagureLibGetWatchListtests(tests.Modeltests): ) def test_get_watch_list_project_w_contributor_out_pr(self): - """ Test get_watch_list when the project has one contributor not - watching the pull-request """ + """Test get_watch_list when the project has one contributor not + watching the pull-request""" # Create a project ns/test3 item = pagure.lib.model.Project( user_id=1, # pingou @@ -384,8 +383,8 @@ class PagureLibGetWatchListtests(tests.Modeltests): ) def test_get_watch_list_project_w_contributor_watching_project(self): - """ Test get_watch_list when the project has one contributor watching - the project """ + """Test get_watch_list when the project has one contributor watching + the project""" # Create a project ns/test3 item = pagure.lib.model.Project( user_id=1, # pingou @@ -442,8 +441,8 @@ class PagureLibGetWatchListtests(tests.Modeltests): @mock.patch.dict("pagure.config.config", {"PAGURE_ADMIN_USERS": "foo"}) def test_get_watch_list_project_w_private_issue(self): - """ Test get_watch_list when the project has one contributor watching - the project and the issue is private """ + """Test get_watch_list when the project has one contributor watching + the project and the issue is private""" # Create a project ns/test3 item = pagure.lib.model.Project( user_id=1, # pingou From fa6c30507638c5461bbebd0c3d8df4d8122aeaa3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 06 2021 14:29:31 +0000 Subject: [PATCH 2/2] Make flake8 check for 80 characters line Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_style.py b/tests/test_style.py index 5c9b81c..a00e0a9 100644 --- a/tests/test_style.py +++ b/tests/test_style.py @@ -42,6 +42,7 @@ class TestStyle(unittest.TestCase): "-m", "flake8", "--ignore=E712,W503,E203,E902", + "--max-line-length=80", REPO_PATH, ]