Skip to content

Commit

Permalink
Removed unused code, formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
caseneuve committed Oct 26, 2023
1 parent 158afc7 commit e715130
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
18 changes: 0 additions & 18 deletions dzira/dzira.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,6 @@ def estimate(i):
)


# def show_sprint_info(sprint: Sprint, board: Board) -> None:
# project = board.raw["location"]["projectName"]
# fmt = lambda d: datetime.strptime(d, "%Y-%m-%dT%H:%M:%S.%fZ").strftime("%a, %b %d")
# print(
# f"\n{C['bold']} {sprint.name} by {project}{C['reset']} "
# f"[{fmt(sprint.startDate)} -> {fmt(sprint.endDate)}]\n",
# flush=True,
# )


@cli.command()
@click.pass_context
@click.help_option("-h", "--help")
Expand All @@ -331,7 +321,6 @@ def ls(ctx):

### Validators


def is_valid_time(time: str) -> bool:
return (
re.match(r"^(([1-9]|1\d|2[0-3])h)?(\s+(?=\d))?(([1-5]\d|[1-9])m)?$", time)
Expand Down Expand Up @@ -385,7 +374,6 @@ def check_params(**args) -> None:

### Payload


def calculate_seconds(**payload) -> dict:
start, end = itemgetter("start", "end")(payload)

Expand All @@ -407,12 +395,6 @@ def calculate_seconds(**payload) -> dict:
return payload


# def prepare_payload(**payload) -> dict:
# # if not payload["time"] and payload["start"]:
# payload["seconds"] = calculate_seconds(**payload)
# return payload


def establish_issue(jira: JIRA, config: dict, issue: str) -> str:
board = config.get("JIRA_BOARD")

Expand Down
30 changes: 2 additions & 28 deletions tests/test_dzira.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import pathlib
import sys
from unittest.mock import Mock, PropertyMock, call, patch, sentinel, MagicMock
from unittest.mock import Mock, PropertyMock, call, patch, sentinel

import pytest
import click
Expand All @@ -12,6 +12,7 @@
DOTFILE,
Result,
_get_board_by_name,
_update_worklog,
add_worklog,
c,
calculate_seconds,
Expand All @@ -26,7 +27,6 @@
get_current_sprint,
get_current_sprint_with_issues,
get_jira,
_get_sprint_issues,
get_sprint_issues,
get_sprints,
get_worklog,
Expand All @@ -35,7 +35,6 @@
log,
ls,
main,
_update_worklog,
update_worklog,
validate_hour,
validate_time,
Expand Down Expand Up @@ -642,31 +641,6 @@ def test_does_not_rise_when_worklog_and_comment(self):
check_params(**args) # should not rise


# class TestPreparePaload:
# args = dict(
# time=None, start=sentinel.start, end=sentinel.end, comment=sentinel.comment, worklog_id=None
# )

# def test_uses_time_and_comment_if_provided(self, mocker):
# mock_calculate_seconds = mocker.patch("dzira.dzira.calculate_seconds")
# args = {**self.args, "time": "2h"}

# result = prepare_payload(**args)

# assert result == dict(**args)
# mock_calculate_seconds.assert_not_called()

# def test_uses_time_and_start_end_when_time_not_provided(self, mocker):
# mock_calculate_seconds = mocker.patch("dzira.dzira.calculate_seconds")
# args = dict(
# time=None, start=sentinel.start, end=sentinel.end, comment=sentinel.comment, worklog_id=None
# )
# result = prepare_payload(**args)

# assert result == {**args, "seconds": mock_calculate_seconds.return_value}
# mock_calculate_seconds.assert_called_once_with(**args)


@patch("dzira.dzira.get_sprint_issues")
@patch("dzira.dzira.get_current_sprint")
@patch("dzira.dzira.get_board_by_name")
Expand Down

0 comments on commit e715130

Please sign in to comment.