Fix flake8 errors
Signed-off-by: Michal Konečný <mkonecny@redhat.com>
This commit is contained in:
parent
6e69a65ce0
commit
a8dca5908f
9 changed files with 45 additions and 38 deletions
|
@ -2,21 +2,22 @@
|
|||
Unit tests for `toddlers.plugins.scm_request_processor`
|
||||
"""
|
||||
import json
|
||||
from unittest.mock import call, patch, MagicMock, Mock
|
||||
import logging
|
||||
import re
|
||||
from unittest.mock import call, MagicMock, Mock, patch
|
||||
|
||||
import arrow
|
||||
from pagure_messages.issue_schema import IssueNewV1
|
||||
import pytest
|
||||
|
||||
import toddlers.plugins.scm_request_processor as scm_request_processor
|
||||
from toddlers.exceptions import ValidationError
|
||||
import toddlers.plugins.scm_request_processor as scm_request_processor
|
||||
|
||||
|
||||
class TestAcceptsTopic:
|
||||
"""
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.accepts_topic` method.
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.accepts_topic`
|
||||
method.
|
||||
"""
|
||||
|
||||
toddler_cls = scm_request_processor.SCMRequestProcessor
|
||||
|
@ -146,7 +147,8 @@ class TestProcess:
|
|||
|
||||
class TestProcessTicket:
|
||||
"""
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.process_ticket` method.
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.process_ticket`
|
||||
method.
|
||||
"""
|
||||
|
||||
def setup(self):
|
||||
|
@ -488,7 +490,8 @@ class TestVerifySLAs:
|
|||
|
||||
class TestCreateNewRepo:
|
||||
"""
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.create_new_repo` method.
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.create_new_repo`
|
||||
method.
|
||||
"""
|
||||
|
||||
def setup(self):
|
||||
|
@ -649,7 +652,8 @@ class TestCreateNewRepo:
|
|||
|
||||
def test_create_new_repo_requester_not_in_dist_git(self):
|
||||
"""
|
||||
Assert that ticket will be commented on when requester doesn't have a valid dist git account.
|
||||
Assert that ticket will be commented on when requester doesn't
|
||||
have a valid dist git account.
|
||||
"""
|
||||
issue = {"id": 100, "user": {"name": "zlopez"}}
|
||||
|
||||
|
@ -922,7 +926,8 @@ class TestCreateNewRepo:
|
|||
@patch("toddlers.plugins.scm_request_processor.pdc")
|
||||
def test_create_new_repo_tests_namespace(self, mock_pdc):
|
||||
"""
|
||||
Assert that ticket will be processed when everything is in order and namespace is set to tests.
|
||||
Assert that ticket will be processed when everything is in order and namespace
|
||||
is set to tests.
|
||||
"""
|
||||
issue = {"id": 100, "user": {"name": "zlopez"}}
|
||||
|
||||
|
@ -979,7 +984,8 @@ class TestCreateNewRepo:
|
|||
@patch("toddlers.plugins.scm_request_processor.pdc")
|
||||
def test_create_new_repo_non_default_branch(self, mock_pdc):
|
||||
"""
|
||||
Assert that ticket will be processed when everything is in order and requested branch is not default.
|
||||
Assert that ticket will be processed when everything is in order and requested
|
||||
branch is not default.
|
||||
"""
|
||||
issue = {"id": 100, "user": {"name": "zlopez"}}
|
||||
|
||||
|
@ -1128,7 +1134,8 @@ class TestCreateNewRepo:
|
|||
|
||||
class TestCreateNewBranch:
|
||||
"""
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.create_new_branch` method.
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.create_new_branch`
|
||||
method.
|
||||
"""
|
||||
|
||||
def setup(self):
|
||||
|
@ -1660,7 +1667,8 @@ class TestCreateNewBranch:
|
|||
|
||||
class TestValidateReviewBug:
|
||||
"""
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.validate_review_bug` method.
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.validate_review_bug`
|
||||
method.
|
||||
"""
|
||||
|
||||
def setup(self):
|
||||
|
@ -2398,7 +2406,8 @@ class TestValidateReviewBug:
|
|||
|
||||
class TestValidEpelPackage:
|
||||
"""
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.valid_epel_package` method.
|
||||
Test class for `toddlers.plugins.scm_request_processor.SCMRequestProcessor.valid_epel_package`
|
||||
method.
|
||||
"""
|
||||
|
||||
def setup(self):
|
||||
|
|
|
@ -1055,7 +1055,7 @@ class TestCommentOnBug:
|
|||
|
||||
mock_bz.return_value = server
|
||||
|
||||
bug = toddlers.utils.bugzilla_system.comment_on_bug(bug_id, comment)
|
||||
toddlers.utils.bugzilla_system.comment_on_bug(bug_id, comment)
|
||||
|
||||
mock_bz.assert_called_with()
|
||||
server.comment.assert_called_with(id=bug_id, comment=comment)
|
||||
|
|
|
@ -236,7 +236,7 @@ class TestFedoraAccountFASJSON:
|
|||
assert output is False
|
||||
|
||||
@patch("toddlers.utils.fedora_account.get_fasjson")
|
||||
def test_get_user_by_email(self, mock_fas):
|
||||
def test_get_user_by_username(self, mock_fas):
|
||||
user = [{"username": "scoady", "emails": ["scoady@fp.o"]}]
|
||||
result = Mock()
|
||||
result.result = user
|
||||
|
@ -250,7 +250,7 @@ class TestFedoraAccountFASJSON:
|
|||
assert output == {"username": "scoady", "emails": ["scoady@fp.o"]}
|
||||
|
||||
@patch("toddlers.utils.fedora_account.get_fasjson")
|
||||
def test_get_user_by_email_empty(self, mock_fas):
|
||||
def test_get_user_by_username_empty(self, mock_fas):
|
||||
user = []
|
||||
result = Mock()
|
||||
result.result = user
|
||||
|
@ -264,7 +264,7 @@ class TestFedoraAccountFASJSON:
|
|||
assert output is None
|
||||
|
||||
@patch("toddlers.utils.fedora_account.get_fasjson")
|
||||
def test_get_user_by_email_error(self, mock_fas):
|
||||
def test_get_user_by_username_error(self, mock_fas):
|
||||
server = Mock()
|
||||
server.search.side_effect = ClientError(
|
||||
message="Error getting bz_email for group",
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
"""
|
||||
Unit tests for `toddlers.utils.pagure`.
|
||||
"""
|
||||
import pytest
|
||||
from unittest.mock import call, Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from toddlers.exceptions import PagureError
|
||||
import toddlers.utils.pagure as pagure
|
||||
|
||||
|
@ -13,7 +14,7 @@ class TestPagureSetPagure:
|
|||
Test class for `toddlers.pagure.set_pagure` function.
|
||||
"""
|
||||
|
||||
def test_set_pagure_no_pagure_url(self):
|
||||
def test_set_pagure(self):
|
||||
"""
|
||||
Test initialization of pagure module.
|
||||
"""
|
||||
|
@ -109,7 +110,7 @@ class TestPagureCloseIssue:
|
|||
|
||||
with patch("toddlers.utils.pagure.Pagure.add_comment_to_issue") as comment_mock:
|
||||
comment_mock.return_value = True
|
||||
result = self.pagure.close_issue(issue_id, namespace, message, reason)
|
||||
self.pagure.close_issue(issue_id, namespace, message, reason)
|
||||
|
||||
self.pagure._requests_session.post.assert_called_with(
|
||||
"https://pagure.io/test/issue/100/status",
|
||||
|
@ -138,7 +139,7 @@ class TestPagureCloseIssue:
|
|||
"toddlers.utils.pagure.Pagure.add_comment_to_issue"
|
||||
) as comment_mock:
|
||||
comment_mock.return_value = True
|
||||
result = self.pagure.close_issue(issue_id, namespace, message, reason)
|
||||
self.pagure.close_issue(issue_id, namespace, message, reason)
|
||||
|
||||
self.pagure._requests_session.post.assert_called_with(
|
||||
"https://pagure.io/test/issue/100/status",
|
||||
|
@ -176,7 +177,7 @@ class TestPagureAddCommentToIssue:
|
|||
namespace = "test"
|
||||
message = "message"
|
||||
|
||||
result = self.pagure.add_comment_to_issue(issue_id, namespace, message)
|
||||
self.pagure.add_comment_to_issue(issue_id, namespace, message)
|
||||
|
||||
self.pagure._requests_session.post.assert_called_with(
|
||||
"https://pagure.io/test/issue/100/comment",
|
||||
|
@ -200,7 +201,7 @@ class TestPagureAddCommentToIssue:
|
|||
expected_error = "Couldn't comment on issue 'https://pagure.io/test/issue/100'"
|
||||
|
||||
with pytest.raises(PagureError, match=expected_error):
|
||||
result = self.pagure.add_comment_to_issue(issue_id, namespace, message)
|
||||
self.pagure.add_comment_to_issue(issue_id, namespace, message)
|
||||
|
||||
self.pagure._requests_session.post.assert_called_with(
|
||||
"https://pagure.io/test/issue/100/comment",
|
||||
|
@ -279,7 +280,7 @@ class TestPagureUserExists:
|
|||
expected_error = "Couldn't get user '{0}'".format(username)
|
||||
|
||||
with pytest.raises(PagureError, match=expected_error):
|
||||
result = self.pagure.user_exists(username)
|
||||
self.pagure.user_exists(username)
|
||||
|
||||
self.pagure._requests_session.get.assert_called_with(
|
||||
"https://pagure.io/api/0/users?pattern={0}".format(username),
|
||||
|
@ -628,7 +629,7 @@ class TestPagureNewBranch:
|
|||
with pytest.raises(RuntimeError, match=expected_error):
|
||||
self.pagure.new_branch(namespace, repo, branch)
|
||||
|
||||
def test_new_branch_missing_required_params(self):
|
||||
def test_new_branch_conflicting_params(self):
|
||||
"""
|
||||
Assert that method fails if conflicting parameters are provided.
|
||||
"""
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
Unit tests for `toddlers.utils.pdc`.
|
||||
"""
|
||||
from unittest.mock import call, MagicMock, patch
|
||||
from unittest.mock import call, MagicMock
|
||||
|
||||
import toddlers.utils.pdc as pdc
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
from .pagure_error import PagureError
|
||||
from .validation_error import ValidationError
|
||||
from .pagure_error import PagureError # noqa: F401
|
||||
from .validation_error import ValidationError # noqa: F401
|
||||
|
|
|
@ -17,8 +17,8 @@ import arrow
|
|||
from pagure_messages.issue_schema import IssueNewV1
|
||||
|
||||
from toddlers.base import ToddlerBase
|
||||
from toddlers.utils import bugzilla_system, fedora_account, git, pagure, pdc, requests
|
||||
from toddlers.exceptions import ValidationError
|
||||
from toddlers.utils import bugzilla_system, fedora_account, git, pagure, pdc, requests
|
||||
|
||||
# Regex for branch name validation
|
||||
STREAM_NAME_REGEX = r"^[a-zA-Z0-9.\-_+]+$"
|
||||
|
@ -413,7 +413,6 @@ class SCMRequestProcessor(ToddlerBase):
|
|||
)
|
||||
return
|
||||
|
||||
issue_id = issue["id"]
|
||||
_log.info(
|
||||
"- Checking if user {0} has an account in dist-git.".format(requester)
|
||||
)
|
||||
|
@ -644,7 +643,6 @@ class SCMRequestProcessor(ToddlerBase):
|
|||
)
|
||||
return
|
||||
|
||||
issue_id = issue["id"]
|
||||
issue_owner = issue["user"]["name"]
|
||||
|
||||
# Check if the branch requestor is one of the maintainers or part of the groups
|
||||
|
|
|
@ -18,8 +18,8 @@ Examples:
|
|||
import logging
|
||||
from typing import Mapping
|
||||
|
||||
from toddlers.utils import requests
|
||||
from toddlers.exceptions import PagureError
|
||||
from toddlers.utils import requests
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -260,7 +260,8 @@ class Pagure:
|
|||
|
||||
if response.status_code != 200:
|
||||
log.error(
|
||||
"Error when creating alias for project '{0}/{1}'. Got status_code '{2}'.".format(
|
||||
"Error when creating alias for project '{0}/{1}'. "
|
||||
"Got status_code '{2}'.".format(
|
||||
namespace, repo, response.status_code
|
||||
)
|
||||
)
|
||||
|
@ -430,9 +431,8 @@ class Pagure:
|
|||
|
||||
if response.status_code != 200:
|
||||
log.error(
|
||||
"Error when retrieving contributors project '{0}/{1}'. Got status_code '{2}'.".format(
|
||||
namespace, repo, response.status_code
|
||||
)
|
||||
"Error when retrieving contributors project '{0}/{1}'. "
|
||||
"Got status_code '{2}'.".format(namespace, repo, response.status_code)
|
||||
)
|
||||
raise PagureError(
|
||||
"Couldn't get contributors for project '{0}/{1}'".format(
|
||||
|
@ -468,9 +468,8 @@ class Pagure:
|
|||
|
||||
if response.status_code != 200:
|
||||
log.error(
|
||||
"Error when getting default branch for project '{0}/{1}'. Got status_code '{2}'.".format(
|
||||
namespace, repo, response.status_code
|
||||
)
|
||||
"Error when getting default branch for project '{0}/{1}'. "
|
||||
"Got status_code '{2}'.".format(namespace, repo, response.status_code)
|
||||
)
|
||||
raise PagureError(
|
||||
"Couldn't get default branch for project '{0}/{1}'".format(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Optional, Mapping
|
||||
from typing import Mapping, Optional
|
||||
|
||||
from pdc_client import PDCClient
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue