Skip to content

Commit

Permalink
style: apply black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoor committed Jun 16, 2021
1 parent 3a53536 commit f8de493
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
6 changes: 3 additions & 3 deletions bugmon/bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class EnhancedBug(Bug):
)

def __init__(self, bugsy, **kwargs):
""" Initializes LocalAttachment """
"""Initializes LocalAttachment"""
super().__init__(bugsy, **kwargs)

if bugsy is None and ("attachments" not in kwargs or "comments" not in kwargs):
Expand Down Expand Up @@ -446,7 +446,7 @@ class LocalAttachment(Attachment):
"""

def __init__(self, **kwargs):
""" Initializes LocalAttachment """
"""Initializes LocalAttachment"""
super().__init__(None, **kwargs)

def update(self):
Expand All @@ -464,7 +464,7 @@ class LocalComment(Comment):
"""

def __init__(self, **kwargs):
""" Initializes LocalComment """
"""Initializes LocalComment"""
super().__init__(None, **kwargs)

def add_tags(self, tags):
Expand Down
5 changes: 4 additions & 1 deletion bugmon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def parse_args(argv=None):

# Optional args
parser.add_argument(
"-d", "--dry-run", action="store_true", help="Disable bug modification",
"-d",
"--dry-run",
action="store_true",
help="Disable bug modification",
)

# Bug selection
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,25 @@

@pytest.fixture(scope="module")
def attachment_fixture():
""" Simple attachment """
"""Simple attachment"""
return ATTACHMENT


@pytest.fixture(scope="module")
def comment_fixture():
""" Simple comment """
"""Simple comment"""
return COMMENT


@pytest.fixture(scope="module")
def bug_fixture():
""" Simple bug """
"""Simple bug"""
return BUG


@pytest.fixture(scope="module")
def bug_fixture_prefetch():
""" Simple bug including attachment and comment data """
"""Simple bug including attachment and comment data"""
bug_data = copy.deepcopy(BUG)
bug_data["attachments"] = [ATTACHMENT]
bug_data["comments"] = [COMMENT]
Expand Down
48 changes: 24 additions & 24 deletions tests/test_bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def test_new_attachment(attachment_fixture):
""" Test that new Attachment is the same as fixture """
"""Test that new Attachment is the same as fixture"""
result = LocalAttachment(**attachment_fixture).to_dict()

for key in result:
Expand All @@ -39,7 +39,7 @@ def test_new_attachment(attachment_fixture):


def test_new_comment(comment_fixture):
""" Test that new Comment is the same as fixture """
"""Test that new Comment is the same as fixture"""
result = LocalComment(**comment_fixture).to_dict()
for key in result:
if key in ["time", "creation_time"]:
Expand All @@ -52,28 +52,28 @@ def test_new_comment(comment_fixture):


def test_new_bug(bug_fixture_prefetch):
""" Test that new Bug is the same as fixture """
"""Test that new Bug is the same as fixture"""
result = EnhancedBug(None, **bug_fixture_prefetch).to_dict()
for key in result:
assert bug_fixture_prefetch[key] == result[key]


def test_new_bug_without_bugsy_or_prefetch(bug_fixture):
""" Test that new Bug without bugsy or cached data throws """
"""Test that new Bug without bugsy or cached data throws"""
with pytest.raises(BugException):
EnhancedBug(None, **bug_fixture)


def test_new_bug_prefetch_exclusion(bug_fixture_prefetch):
""" Test that new Bug with prefetch excludes attachments and comments """
"""Test that new Bug with prefetch excludes attachments and comments"""
result = EnhancedBug(None, **bug_fixture_prefetch).to_dict()
assert "attachments" not in result
assert "comments" not in result


@pytest.mark.parametrize("method", ["add_attachment", "add_comment"])
def test_bug_remote_methods(bug_fixture_prefetch, method):
""" Test that EnhancedBug with prefetch enabled throws on remote methods """
"""Test that EnhancedBug with prefetch enabled throws on remote methods"""
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)
with pytest.raises(TypeError) as e:
getattr(bug, method)(None)
Expand All @@ -82,7 +82,7 @@ def test_bug_remote_methods(bug_fixture_prefetch, method):


def test_bug_get_attachments_prefetch(attachment_fixture, bug_fixture_prefetch):
""" Test that get_attachments with cached data returns correct attacment """
"""Test that get_attachments with cached data returns correct attacment"""
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)
attachments = bug.get_attachments()
assert len(attachments) == 1
Expand All @@ -91,7 +91,7 @@ def test_bug_get_attachments_prefetch(attachment_fixture, bug_fixture_prefetch):


def test_bug_get_comments_prefetch(bug_fixture_prefetch, comment_fixture):
""" Test that get_attachments with cached data returns correct attacment """
"""Test that get_attachments with cached data returns correct attacment"""
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)
comments = bug.get_comments()
assert len(comments) == 1
Expand All @@ -101,7 +101,7 @@ def test_bug_get_comments_prefetch(bug_fixture_prefetch, comment_fixture):

@pytest.mark.parametrize("method", ["add_tags", "remove_tags"])
def test_comment_remote_methods(comment_fixture, method):
""" Test that LocalComment throws on remote methods """
"""Test that LocalComment throws on remote methods"""
comment = LocalComment(**comment_fixture)
with pytest.raises(TypeError) as e:
getattr(comment, method)(None)
Expand All @@ -111,7 +111,7 @@ def test_comment_remote_methods(comment_fixture, method):

@pytest.mark.parametrize("method", ["update"])
def test_attachment_remote_methods(attachment_fixture, method):
""" Test that LocalAttachment throws on remote methods """
"""Test that LocalAttachment throws on remote methods"""
attachment = LocalAttachment(**attachment_fixture)
with pytest.raises(TypeError) as e:
getattr(attachment, method)()
Expand All @@ -121,7 +121,7 @@ def test_attachment_remote_methods(attachment_fixture, method):

@pytest.mark.parametrize("alias, version", BRANCH_ALIAS_PAIRS)
def test_bug_branch(mocker, bug_fixture_prefetch, alias, version):
""" Test that branch matches alias of current version """
"""Test that branch matches alias of current version"""
mocker.patch("bugmon.bug.Fetcher.resolve_esr", side_effect=["esr78", "esr68"])
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)

Expand All @@ -133,7 +133,7 @@ def test_bug_branch(mocker, bug_fixture_prefetch, alias, version):


def test_bug_branches(mocker, bug_fixture_prefetch):
""" Test branch enumeration """
"""Test branch enumeration"""
mocker.patch("bugmon.bug.Fetcher.resolve_esr", side_effect=["esr78", "esr68"])
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)
# Set fixed central version
Expand All @@ -153,7 +153,7 @@ def test_bug_branches(mocker, bug_fixture_prefetch):


def test_bug_build_flags(bug_fixture_prefetch):
""" Simple test of bug.build_flags """
"""Simple test of bug.build_flags"""
data = copy.deepcopy(bug_fixture_prefetch)
data["comments"][0]["text"] = "Built with --enable-address-sanitizer --enable-debug"
bug = EnhancedBug(bugsy=None, **data)
Expand All @@ -165,15 +165,15 @@ def test_bug_build_flags(bug_fixture_prefetch):


def test_bug_central_version(mocker, bug_fixture_prefetch):
""" Simple test of bug.central_version """
"""Simple test of bug.central_version"""
mocker.patch("bugmon.bug._get_milestone", return_value=81)
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)

assert bug.central_version == 81


def test_bug_comment_zero(bug_fixture_prefetch):
""" Simple test of bug.comment_zero """
"""Simple test of bug.comment_zero"""
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)

assert bug.comment_zero == bug_fixture_prefetch["comments"][0]["text"]
Expand All @@ -182,7 +182,7 @@ def test_bug_comment_zero(bug_fixture_prefetch):
@pytest.mark.parametrize("code_wrap", [True, False])
@pytest.mark.parametrize("bid", [REV, SHORT_REV, BUILD_ID, "INVALID_REV"])
def test_bug_initial_build_id_comment(mocker, bug_fixture_prefetch, code_wrap, bid):
""" Test parsing of initial_build_id from comment """
"""Test parsing of initial_build_id from comment"""
if code_wrap:
bid_str = f"`{bid}`"
else:
Expand All @@ -208,7 +208,7 @@ def test_bug_initial_build_id_comment(mocker, bug_fixture_prefetch, code_wrap, b

@pytest.mark.parametrize("bid", [REV, SHORT_REV])
def test_bug_initial_build_id_whiteboard(mocker, bug_fixture_prefetch, bid):
""" Test parsing of initial_build_id from whiteboard """
"""Test parsing of initial_build_id from whiteboard"""
data = copy.deepcopy(bug_fixture_prefetch)
data["whiteboard"] = f"[bugmon:origRev={bid}]"
bug = EnhancedBug(bugsy=None, **data)
Expand All @@ -224,7 +224,7 @@ def test_bug_initial_build_id_whiteboard(mocker, bug_fixture_prefetch, bid):

@pytest.mark.parametrize("use_trunk", [True, False])
def test_bug_version(mocker, bug_fixture_prefetch, use_trunk):
""" Simple test of version helper """
"""Simple test of version helper"""
if use_trunk:
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)
mocker.patch("bugmon.bug._get_milestone", return_value=81)
Expand All @@ -237,7 +237,7 @@ def test_bug_version(mocker, bug_fixture_prefetch, use_trunk):


def test_bug_command_setter_append(bug_fixture_prefetch):
""" Test appending commands to whiteboard """
"""Test appending commands to whiteboard"""
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)
commands = bug.commands
commands["fake_command"] = None
Expand All @@ -246,15 +246,15 @@ def test_bug_command_setter_append(bug_fixture_prefetch):


def test_bug_command_setter_replace(bug_fixture_prefetch):
""" Test replacing commands """
"""Test replacing commands"""
bug = EnhancedBug(bugsy=None, **bug_fixture_prefetch)
bug.commands = {"fake_command": None}

assert bug.whiteboard == "[bugmon:fake_command]"


def test_bug_command_setter_empty_bugmon(bug_fixture_prefetch):
""" Test setting command where bugmon exists on whiteboard with no commands """
"""Test setting command where bugmon exists on whiteboard with no commands"""
data = copy.deepcopy(bug_fixture_prefetch)
data["whiteboard"] = "[bugmon:]"
bug = EnhancedBug(bugsy=None, **data)
Expand All @@ -264,7 +264,7 @@ def test_bug_command_setter_empty_bugmon(bug_fixture_prefetch):


def test_bug_command_setter_empty_whiteboard(bug_fixture_prefetch):
""" Test initialization of bugmon command on whiteboard """
"""Test initialization of bugmon command on whiteboard"""
data = copy.deepcopy(bug_fixture_prefetch)
data["whiteboard"] = ""
bug = EnhancedBug(bugsy=None, **data)
Expand All @@ -274,7 +274,7 @@ def test_bug_command_setter_empty_whiteboard(bug_fixture_prefetch):


def test_bug_command_setter_remove_command(bug_fixture_prefetch):
""" Test removing command from whiteboard """
"""Test removing command from whiteboard"""
data = copy.deepcopy(bug_fixture_prefetch)
data["whiteboard"] = "[something-else][bugmon:verify]"
bug = EnhancedBug(bugsy=None, **data)
Expand All @@ -284,7 +284,7 @@ def test_bug_command_setter_remove_command(bug_fixture_prefetch):


def test_bug_cache_bug(mocker, bug_fixture, comment_fixture, attachment_fixture):
""" Test EnhancedBug.cache_bug() """
"""Test EnhancedBug.cache_bug()"""
data = copy.deepcopy(bug_fixture)
bug = EnhancedBug(bugsy=True, **data)

Expand Down

0 comments on commit f8de493

Please sign in to comment.