Skip to content

Commit

Permalink
Merge branch 'release/0.25.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
eliostvs committed Dec 9, 2023
2 parents 2cb7304 + 3be0f1d commit 40c48d7
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.25.0
current_version = 0.25.1

[bumpversion:file:setup.py]

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.25.1

### Removed

- Dependency on python-tomate package.

## 0.25.0

### Changed
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:22.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -qq && apt-get install -y \
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
dbus-x11 \
gir1.2-appindicator3-0.1 \
gir1.2-gdkpixbuf-2.0 \
Expand Down Expand Up @@ -30,9 +30,10 @@ RUN apt-get update -qq && apt-get install -y \
python3-wrapt \
python3-xdg \
python3-yapsy \
xvfb
xvfb \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

RUN pip3 install \
RUN pip3 install --no-cache-dir \
black \
isort \
ruff \
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def find_data_files(data_map, package_name):
py_modules=[],
data_files=find_data_files(DATA_FILES, "tomate"),
url="https://github.com/eliostvs/tomate-gtk",
version="0.25.0",
version="0.25.1",
zip_safe=False,
entry_points={"console_scripts": ["tomate-gtk=tomate.__main__:main"]},
)
21 changes: 6 additions & 15 deletions tests/plugins/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,12 @@

from gi.repository import Gtk

from tomate.pomodoro import Events, SessionPayload, SessionType
from tomate.ui.testing import Q
from tomate.pomodoro import Events, SessionType
from tomate.ui.testing import Q, create_session_payload

SECTION_NAME = "script_plugin"


def random_payload(session_type: SessionType = SessionType.POMODORO) -> SessionPayload:
return SessionPayload(
id="1234",
type=session_type,
duration=0,
pomodoros=0,
)


@pytest.fixture
def subprocess_run(mocker, monkeypatch):
import script
Expand Down Expand Up @@ -56,7 +47,7 @@ def test_execute_command_when_event_is_trigger(event, option, bus, subprocess_ru
command = config.get(SECTION_NAME, option)
plugin.activate()

bus.send(event, random_payload())
bus.send(event, create_session_payload())

subprocess_run.assert_called_once_with(command, shell=True, check=True)

Expand All @@ -73,7 +64,7 @@ def test_command_variables(event, section, session_type, bus, subprocess_run, co
config.set(SECTION_NAME, section, "$event $session")
plugin.activate()

bus.send(event, random_payload(session_type))
bus.send(event, create_session_payload(type=session_type))

subprocess_run.assert_called_once_with(f"{event.name} {session_type.name}", shell=True, check=True)

Expand All @@ -90,7 +81,7 @@ def test_does_not_execute_commands_when_they_are_not_configured(event, option, b
config.remove(SECTION_NAME, option)
plugin.activate()

assert bus.send(event, random_payload()) == [False]
assert bus.send(event, create_session_payload()) == [False]

subprocess_run.assert_not_called()

Expand All @@ -100,7 +91,7 @@ def test_execute_command_fail(bus, config, plugin):

plugin.activate()

assert bus.send(Events.SESSION_START, random_payload()) == [False]
assert bus.send(Events.SESSION_START, create_session_payload()) == [False]


class TestSettingsWindow:
Expand Down
15 changes: 3 additions & 12 deletions tests/plugins/test_ticking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import gi
import pytest

from tomate.ui.testing import create_session_payload

gi.require_version("Gtk", "3.0")
gi.require_version("Gst", "1.0")

from tomate.pomodoro import Events, SessionPayload, SessionType
from tomate.pomodoro import Events, SessionType

DEFAULT_ALARM = f'file://{join(dirname(dirname(__file__)), "data", "tomate", "media", "clock.ogg")}'

Expand Down Expand Up @@ -78,14 +80,3 @@ def test_stops_player_when_is_deactivate(self, player, bus, config, plugin):
plugin.deactivate()

player.return_value.stop.assert_called_once()


def create_session_payload(**kwargs) -> SessionPayload:
defaults = {
"id": "1234",
"duration": 25 * 60,
"pomodoros": 0,
"type": SessionType.POMODORO,
}
defaults.update(kwargs)
return SessionPayload(**defaults)
10 changes: 5 additions & 5 deletions tests/pomodoro/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
def session(graph, config, bus, mocker):
graph.register_instance("tomate.bus", bus)
graph.register_instance("tomate.config", config)
mocker.patch("uuid.uuid4", return_value="1234")
scan_to_graph(["tomate.pomodoro.timer", "tomate.pomodoro.session"], graph)
return graph.get("tomate.session")

Expand Down Expand Up @@ -50,7 +49,6 @@ def test_starts_when_session_is_not_running(self, state, session, bus, mocker):

assert result is True
payload = SessionPayload(
id="1234",
type=SessionType.POMODORO,
pomodoros=0,
duration=25 * 60,
Expand All @@ -75,7 +73,6 @@ def test_stops_when_session_is_running(self, session, bus, mocker):

assert result is True
payload = SessionPayload(
id="1234",
type=SessionType.POMODORO,
duration=25 * 60,
pomodoros=0,
Expand Down Expand Up @@ -109,7 +106,6 @@ def test_resets_when_session_is_not_running(self, state, session_type, duration,

assert result is True
payload = SessionPayload(
id="1234",
type=session_type,
pomodoros=0,
duration=duration,
Expand Down Expand Up @@ -184,7 +180,6 @@ def test_changes_session_type(self, bus, config, mocker, session):
run_loop_for(2)

payload = SessionPayload(
id="1234",
type=SessionType.SHORT_BREAK,
duration=5 * 60,
pomodoros=1,
Expand Down Expand Up @@ -261,6 +256,11 @@ def test_type_of(number, session_type):
assert SessionType.of(number) == session_type


def test_type_of_unknown():
with pytest.raises(Exception):
assert SessionType.of(999)


@pytest.mark.parametrize(
"session_type, option",
[
Expand Down
2 changes: 1 addition & 1 deletion tomate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.25.0"
__version__ = "0.25.1"
8 changes: 4 additions & 4 deletions tomate/pomodoro/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import enum
import logging
import uuid
from collections import namedtuple

from wiring import SingletonScope, inject
Expand All @@ -19,7 +18,7 @@
logger = logging.getLogger(__name__)


class Payload(namedtuple("SessionPayload", ["id", "type", "pomodoros", "duration"])):
class Payload(namedtuple("SessionPayload", ["type", "pomodoros", "duration"])):
@property
def countdown(self) -> str:
return format_seconds(self.duration)
Expand All @@ -31,11 +30,13 @@ class Type(enum.Enum):
LONG_BREAK = 2

@classmethod
def of(cls, index) -> Type:
def of(cls, index: int) -> Type:
for number, attr in enumerate(cls):
if number == index:
return attr

raise Exception(f"invalid index: {index}")

@property
def option(self) -> str:
return "{}_duration".format(self.name.replace("_", "").lower())
Expand Down Expand Up @@ -154,7 +155,6 @@ def _trigger(self, event: Events) -> None:
def _create_payload(self, **kwargs) -> Payload:
defaults = {
"duration": self.duration,
"id": uuid.uuid4(),
"pomodoros": self.pomodoros,
"type": self.current,
}
Expand Down
2 changes: 1 addition & 1 deletion tomate/ui/dialogs/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, config):
modal=True,
program_name="Tomate Gtk",
title="Tomate Gtk",
version="0.25.0",
version="0.25.1",
website="https://github.com/eliostvs/tomate-gtk",
website_label="Tomate GTK on Github",
)
Expand Down
1 change: 0 additions & 1 deletion tomate/ui/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def active_shortcut(shortcut_engine: ShortcutEngine, shortcut: Shortcut, window:

def create_session_payload(**kwargs) -> SessionPayload:
defaults = {
"id": "1234",
"duration": 25 * 60,
"pomodoros": 0,
"type": SessionType.POMODORO,
Expand Down
2 changes: 1 addition & 1 deletion tomate/ui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def hide(self):
logger.debug("action=hide strategy=tray")
return self.widget.hide_on_delete()
else:
self.widget.iconify()
logger.debug("action=hide strategy=minimize")
self.widget.iconify()
return Gtk.true

@on(Events.SESSION_END)
Expand Down

0 comments on commit 40c48d7

Please sign in to comment.