Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved test setup #960

Merged
merged 28 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
644f4c5
wip
sezanzeb Sep 28, 2024
f705d5f
asdf
sezanzeb Sep 29, 2024
12a2d72
update usage for combinations
sezanzeb Sep 29, 2024
88a13a9
development.md hint for evedv imports and patches
sezanzeb Oct 1, 2024
ea52f85
don't you love it when things break overnight?
sezanzeb Oct 1, 2024
891b4e1
some mypy stuff
sezanzeb Oct 1, 2024
448f028
ladjsfkla
sezanzeb Oct 1, 2024
8e4e510
updated outdated assertion code or something
sezanzeb Oct 1, 2024
703d3ef
aldjkf
sezanzeb Oct 1, 2024
d8b9995
optimize imports
sezanzeb Oct 1, 2024
52b0210
update copyright year, refactoring test lib
sezanzeb Oct 1, 2024
a055911
unittest discover in github pipeline
sezanzeb Oct 1, 2024
9b1d0de
Merge branch 'main' into improved_test_setup
sezanzeb Oct 1, 2024
203edb2
kasjdfa
sezanzeb Oct 1, 2024
04e5115
akldjsfa
sezanzeb Oct 1, 2024
efdfd85
improved test_daemon
sezanzeb Oct 1, 2024
2062941
hopefully fixed test_daemon
sezanzeb Oct 1, 2024
34ccf9c
minor cleanup
sezanzeb Oct 1, 2024
28de297
updated docs, removed .run configurations
sezanzeb Oct 1, 2024
e337025
run all unit tests in github ci
sezanzeb Oct 1, 2024
c0c884f
removed redundant quick_cleanup calls
sezanzeb Oct 1, 2024
f2457eb
minor cleanup stuff
sezanzeb Oct 1, 2024
bb491ee
bump python version in ci
sezanzeb Oct 2, 2024
c1d4e58
using pythons patch method everywhere else as well
sezanzeb Oct 2, 2024
4f03e57
rename logger to logging
sezanzeb Oct 2, 2024
9e56742
removed unused evdev wrapper
sezanzeb Oct 2, 2024
055047a
duplicate test_setup
sezanzeb Oct 16, 2024
9e59630
Merge branch 'main' into improved_test_setup
sezanzeb Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
461 changes: 272 additions & 189 deletions bin/input-remapper-control

Large diffs are not rendered by default.

35 changes: 22 additions & 13 deletions bin/input-remapper-gtk
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@

from __future__ import annotations

import sys
import atexit
import sys
from argparse import ArgumentParser

import gi
gi.require_version('Gtk', '3.0')
gi.require_version('GLib', '2.0')
gi.require_version('GtkSource', '4')

gi.require_version("Gtk", "3.0")
gi.require_version("GLib", "2.0")
gi.require_version("GtkSource", "4")
from gi.repository import Gtk

# https://github.com/Nuitka/Nuitka/issues/607#issuecomment-650217096
Expand All @@ -38,7 +39,7 @@ Gtk.init()
from inputremapper.gui.gettext import _, LOCALE_DIR
from inputremapper.gui.reader_service import ReaderService
from inputremapper.daemon import DaemonProxy
from inputremapper.logger import logger, update_verbosity, log_info
from inputremapper.logger.logger import logger


def start_processes() -> DaemonProxy:
Expand All @@ -53,18 +54,21 @@ def start_processes() -> DaemonProxy:
return Daemon.connect()


if __name__ == '__main__':
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument(
'-d', '--debug', action='store_true', dest='debug',
help=_('Displays additional debug information'),
default=False
"-d",
"--debug",
action="store_true",
dest="debug",
help=_("Displays additional debug information"),
default=False,
)

options = parser.parse_args(sys.argv[1:])
update_verbosity(options.debug)
log_info('input-remapper-gtk')
logger.debug('Using locale directory: {}'.format(LOCALE_DIR))
logger.update_verbosity(options.debug)
logger.log_info("input-remapper-gtk")
logger.debug("Using locale directory: {}".format(LOCALE_DIR))

# import input-remapper stuff after setting the log verbosity
from inputremapper.gui.messages.message_broker import MessageBroker, MessageType
Expand All @@ -89,7 +93,12 @@ if __name__ == '__main__':
daemon = start_processes()

data_manager = DataManager(
message_broker, GlobalConfig(), reader_client, daemon, GlobalUInputs(), system_mapping
message_broker,
GlobalConfig(),
reader_client,
daemon,
GlobalUInputs(),
system_mapping,
)
controller = Controller(message_broker, data_manager)
user_interface = UserInterface(message_broker, controller)
Expand Down
17 changes: 10 additions & 7 deletions bin/input-remapper-reader-service
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,24 @@

"""Starts the root reader-service."""
import asyncio
import os
import sys
import atexit
import os
import signal
import sys
from argparse import ArgumentParser

from inputremapper.logger import update_verbosity
from inputremapper.groups import _Groups
from inputremapper.logger.logger import update_verbosity


if __name__ == '__main__':
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument(
'-d', '--debug', action='store_true', dest='debug',
help='Displays additional debug information', default=False
"-d",
"--debug",
action="store_true",
dest="debug",
help="Displays additional debug information",
default=False,
)

options = parser.parse_args(sys.argv[1:])
Expand Down
22 changes: 14 additions & 8 deletions bin/input-remapper-service
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,24 @@
import sys
from argparse import ArgumentParser

from inputremapper.logger import update_verbosity, log_info
from inputremapper.logger.logger import update_verbosity, log_info


if __name__ == '__main__':
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument(
'-d', '--debug', action='store_true', dest='debug',
help='Displays additional debug information', default=False
"-d",
"--debug",
action="store_true",
dest="debug",
help="Displays additional debug information",
default=False,
)
parser.add_argument(
'--hide-info', action='store_true', dest='hide_info',
help='Don\'t display version information', default=False
"--hide-info",
action="store_true",
dest="hide_info",
help="Don't display version information",
default=False,
)

options = parser.parse_args(sys.argv[1:])
Expand All @@ -47,7 +53,7 @@ if __name__ == '__main__':
from inputremapper.daemon import Daemon

if not options.hide_info:
log_info('input-remapper-service')
log_info("input-remapper-service")

daemon = Daemon()
daemon.publish()
Expand Down
2 changes: 1 addition & 1 deletion inputremapper/configs/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import copy
from typing import Union, List, Optional, Callable, Any

from inputremapper.logger import logger, VERSION
from inputremapper.logger.logger import logger, VERSION

NONE = "none"

Expand Down
2 changes: 1 addition & 1 deletion inputremapper/configs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import pkg_resources

from inputremapper.logger import logger
from inputremapper.logger.logger import logger

logged = False

Expand Down
11 changes: 6 additions & 5 deletions inputremapper/configs/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
from typing import Optional

from inputremapper.configs.base_config import ConfigBase, INITIAL_CONFIG
from inputremapper.configs.paths import CONFIG_PATH, USER, touch
from inputremapper.logger import logger
from inputremapper.configs.paths import PathUtils
from inputremapper.user import UserUtils
from inputremapper.logger.logger import logger

MOUSE = "mouse"
WHEEL = "wheel"
Expand All @@ -42,7 +43,7 @@ class GlobalConfig(ConfigBase):
"""

def __init__(self):
self.path = os.path.join(CONFIG_PATH, "config.json")
self.path = os.path.join(PathUtils.config_path(), "config.json")
super().__init__()

def get_dir(self) -> str:
Expand Down Expand Up @@ -118,11 +119,11 @@ def load_config(self, path: Optional[str] = None):

def _save_config(self):
"""Save the config to the file system."""
if USER == "root":
if UserUtils.user == "root":
logger.debug("Skipping config file creation for the root user")
return

touch(self.path)
PathUtils.touch(self.path)

with open(self.path, "w") as file:
json.dump(self._config, file, indent=4)
Expand Down
2 changes: 1 addition & 1 deletion inputremapper/configs/input_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from inputremapper.configs.system_mapping import system_mapping
from inputremapper.gui.messages.message_types import MessageType
from inputremapper.logger import logger
from inputremapper.logger.logger import logger
from inputremapper.utils import get_evdev_constant_name

# having shift in combinations modifies the configured output,
Expand Down
7 changes: 4 additions & 3 deletions inputremapper/configs/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,10 @@
SymbolAndCodeMismatchError,
MissingMacroOrKeyError,
MissingOutputAxisError,
MacroParsingError,
)
from inputremapper.gui.gettext import _
from inputremapper.gui.messages.message_types import MessageType
from inputremapper.injection.global_uinputs import can_default_uinput_emit
from inputremapper.injection.global_uinputs import GlobalUInputs
from inputremapper.injection.macros.parse import is_this_a_macro, parse
from inputremapper.utils import get_evdev_constant_name

Expand Down Expand Up @@ -393,7 +392,9 @@ def validate_symbol(cls, values):
raise OutputSymbolUnknownError(symbol)

target = values.get("target_uinput")
if target is not None and not can_default_uinput_emit(target, EV_KEY, code):
if target is not None and not GlobalUInputs.can_default_uinput_emit(
target, EV_KEY, code
):
raise SymbolNotAvailableInTargetError(symbol, target)

return values
Expand Down
Loading
Loading