Skip to content

Commit

Permalink
Update linter / fix breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexeh committed Nov 18, 2023
1 parent b4fdbcf commit 4f20a34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ variable-rgx = "[a-z_][a-z0-9_]{0,30}$"
[tool.pylint.global]
extension-pkg-whitelist = ["PyQt5"]
# ignoring missing module and missing class docstring errors
disable = ["C0114", "C0115","W1201","W1202","logging-fstring-interpolation"]
disable = ["C0114", "C0115","W1201","W1202","logging-fstring-interpolation","missing-function-docstring"]
output-format = "colorized"
5 changes: 1 addition & 4 deletions src/joystick_diagrams/classes/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from dataclasses import dataclass
from enum import auto, Enum
import logging
from typing import Optional, final

from traitlets import This

_logger = logging.getLogger(__name__)
_devices = {}
Expand Down Expand Up @@ -109,7 +106,7 @@ def add_modifier_to_input(self, input_id, modifier: set, command: Command) -> No
obj = self._get_input(input_id)
_logger.debug(f"Modifier input is: {obj}")
if obj is None:
self.create_input(input_id, InputTypes.BUTTON, "Not Used", [])
self.create_input(input_id, InputTypes.BUTTON, "Not Used")
obj = self._get_input(input_id)
_logger.debug(f"Modifier input created now: {obj}")
obj.add_modifier(modifier, command)
Expand Down
42 changes: 17 additions & 25 deletions tests/input/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
# Test duplication of new device is prevented
# Check a device can have an input registered
# Check a device can have an input overwritten

import pytest
import unittest
import logging
from joystick_diagrams.classes.input import (
add_device,
Input,
LogicalDevice,
InputTypes,
Command,
Expand All @@ -16,7 +13,6 @@
get_devices,
clear_devices,
)
import logging

LOGGER = logging.getLogger(__name__)

Expand All @@ -31,9 +27,9 @@ def test_add_device():
name = "test_name"
add_device(guid, name)
devices = get_devices()
assert (len(devices), 1)
assert (devices[guid].guid, guid)
assert (devices[guid].name, name)
assert len(devices), 1
assert devices[guid].guid, guid
assert devices[guid].name, name


def test_check_devices_registered():
Expand All @@ -52,7 +48,7 @@ def test_check_devices_duplication_name(caplog):
device = add_device("dev-1", "device XYZ")
assert device.guid == "dev-1"
assert device.name == "device 1"
assert type(device) == LogicalDevice
assert isinstance(device, type) == LogicalDevice
assert "Device dev-1 already exists and will not be re-added" in caplog.text


Expand Down Expand Up @@ -85,23 +81,23 @@ def test_add_multiple_inputs_with_modifiers():
device_inputs = get_devices(guid).get_device_inputs()

# Check that the correct number of inputs were added
assert (len(device_inputs), len(inputs))
assert len(device_inputs), len(inputs)

# Check that each input has the correct properties
for input_data in inputs:
input = next((x for x in device_inputs if x.identifier == input_data["id"]), None)
assert (input, None)
assert (input.style, input_data["style"])
assert (input.command.name, input_data["command"].name)
assert input, None
assert input.style, input_data["style"]
assert input.command.name, input_data["command"].name

# Check that each input has the correct modifiers
for modifier_data in modifiers:
modifier = next((x for x in input.modifiers if x.modifiers == modifier_data["input"]), None)
assert (modifier, None)
assert (modifier.command.name, modifier_data["command"].name)
assert modifier, None
assert modifier.command.name, modifier_data["command"].name


def test_add_modify_existing_modifier(caplog):
def test_add_modify_existing_modifier():
# TO DO > Setup in fixture
guid = "dev-1"
# Define the inputs and modifiers
Expand All @@ -114,10 +110,6 @@ def test_add_modify_existing_modifier(caplog):
{"input": {"modifier2"}, "command": Command("modifier_command2")},
]

changes = [
{"input": {"modifier1"}, "command": Command("modifer_command_changed")},
]

# Add the inputs and modifiers to the device
for input_data in inputs:
add_inputs(guid, input_id=input_data["id"], style=input_data["style"], command=input_data["command"])
Expand All @@ -130,15 +122,15 @@ def test_add_modify_existing_modifier(caplog):
# Check that each input has the correct properties
for input_data in inputs:
input = next((x for x in device_inputs if x.identifier == input_data["id"]), None)
assert (input, None)
assert (input.style, input_data["style"])
assert (input.command.name, input_data["command"].name)
assert input, None
assert input.style, input_data["style"]
assert input.command.name, input_data["command"].name

# Check that each input has the correct modifiers
for modifier_data in modifiers:
modifier = next((x for x in input.modifiers if x.modifiers == modifier_data["input"]), None)
assert (modifier, None)
assert (modifier.command.name, modifier_data["command"].name)
assert modifier, None
assert modifier.command.name, modifier_data["command"].name

# Change a modifier
device = get_devices(guid)
Expand Down

0 comments on commit 4f20a34

Please sign in to comment.