Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
LINTER_RULES_PATH: /
VALIDATE_ALL_CODEBASE: true
VALIDATE_JSCPD: false
VALIDATE_GITLEAKS: false
PYTHON_PYLINT_CONFIG_FILE: .pylintrc
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ disable=raw-checker-failed,
import-error,
no-member,
protected-access,
cyclic-import,
unknown-option-value,


# Enable the message, report, category or checker with the given id(s). You can
Expand Down
2 changes: 1 addition & 1 deletion format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ uv run codespell -f -w .
uv run black .
uv run isort .
uv run flake8 .
uv run pylint main.py tank_controller/ tests/
uv run pylint main.py titration/ test/

# Clean up
find . -name ".pytest_cache" -type d -exec /bin/rm -rf {} +
Expand Down
22 changes: 22 additions & 0 deletions test/devices/eeprom_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
The file to test the EEPROM class
"""

from titration.devices.eeprom import EEPROM


def test_default_google_sheet_interval_value():
"""
The function to test the default google_sheet_interval value
"""
eeprom = EEPROM()
assert eeprom.google_sheet_interval == 20


def test_set_google_sheet_interval_value():
"""
The function to test setting the google_sheet_interval value
"""
eeprom = EEPROM()
eeprom.google_sheet_interval = 45
assert eeprom.google_sheet_interval == 45
2 changes: 1 addition & 1 deletion test/ui_state/demo_mode/demo_stir_control_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
The file to test the DemoStirControl Class
"""

# pylint: disable = too-many-arguments, redefined-builtin
# pylint: disable = too-many-arguments, redefined-builtin, too-many-positional-arguments, unknown-option-value

from unittest import mock
from unittest.mock import ANY
Expand Down
59 changes: 59 additions & 0 deletions test/ui_state/view_google_sheet_interval_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
The file to test the View Google Minutes class
"""

from unittest import mock

from titration.devices.library import LiquidCrystal
from titration.titrator import Titrator
from titration.ui_state.controller.view_google_sheet_interval import (
ViewGoogleSheetInterval,
)
from titration.ui_state.main_menu import MainMenu
from titration.ui_state.ui_state import UIState


class MockPreviousState(UIState):
"""
A mock previous state for testing purposes
"""

def __init__(self, titrator):
super().__init__(titrator)


@mock.patch.object(LiquidCrystal, "print")
def test_view_google_sheet_interval(print_mock):
"""
The function to test ViewGoogleSheetInterval's loop function
"""
state = ViewGoogleSheetInterval(Titrator(), MainMenu(Titrator()))

state.loop()

print_mock.assert_any_call("Google Mins:", line=1)
print_mock.assert_any_call("20", line=2)


def test_handle_key_4():
"""
The function to test the back handle key
"""
titrator = Titrator()

titrator.state = ViewGoogleSheetInterval(titrator, MockPreviousState(titrator))

titrator.state.handle_key("4")
assert isinstance(titrator.state, MockPreviousState)


def test_handle_key_d():
"""
The function to test the reset handle keys
"""
titrator = Titrator()

titrator.state = ViewGoogleSheetInterval(titrator, MockPreviousState(titrator))

titrator.state.handle_key("D")
assert isinstance(titrator.state, MockPreviousState)
15 changes: 15 additions & 0 deletions titration/devices/eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
The file for the EEPROM class
"""


class EEPROM:
"""
The class for the EEPROM
"""

def __init__(self):
"""
The constructor function for the EEPROM class
"""
self.google_sheet_interval = 20
4 changes: 4 additions & 0 deletions titration/titrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# pylint: disable = too-many-instance-attributes

from titration.devices.eeprom import EEPROM
from titration.devices.library import (
Heater,
Keypad,
Expand Down Expand Up @@ -32,6 +33,9 @@ def __init__(self):
"""
The constructor for the Titrator class
"""
# Initialize EEPROM
self.eeprom = EEPROM()

# Initialize LCD
self.lcd = LiquidCrystal()

Expand Down
11 changes: 0 additions & 11 deletions titration/ui_state/controller/view_google_mins.py

This file was deleted.

33 changes: 33 additions & 0 deletions titration/ui_state/controller/view_google_sheet_interval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
The file to hold the View Google Sheet Interval class
"""

from titration.devices.library import Keypad
from titration.ui_state.ui_state import UIState


class ViewGoogleSheetInterval(UIState):
"""
This is a class for the ViewGoogleSheetInterval state of the Tank Controller
"""

def __init__(self, titrator, previous_state=None):
"""
The constructor for the ViewGoogleSheetInterval class
"""
super().__init__(titrator)
self.previous_state = previous_state

def loop(self):
"""
The loop function for the ViewGoogleSheetInterval class
"""
self.titrator.lcd.print("Google Mins:", line=1)
self.titrator.lcd.print(f"{self.titrator.eeprom.google_sheet_interval}", line=2)

def handle_key(self, key):
"""
The handle_key function for the ViewGoogleSheetInterval class
"""
if key in [Keypad.KEY_4, Keypad.KEY_D]:
self._set_next_state(self.previous_state, True)
6 changes: 4 additions & 2 deletions titration/ui_state/main_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
from titration.ui_state.controller.set_time import SetTime
from titration.ui_state.controller.view_device_address import ViewDeviceAddress
from titration.ui_state.controller.view_free_memory import ViewFreeMemory
from titration.ui_state.controller.view_google_mins import ViewGoogleMins
from titration.ui_state.controller.view_google_sheet_interval import (
ViewGoogleSheetInterval,
)
from titration.ui_state.controller.view_log_file import ViewLogFile
from titration.ui_state.controller.view_ph_calibration import ViewPHCalibration
from titration.ui_state.controller.view_pid_constants import ViewPIDConstants
Expand Down Expand Up @@ -94,7 +96,7 @@ def __init__(self, titrator):
self.view_menu_actions = [
ViewDeviceAddress, # View IP and MAC
ViewFreeMemory, # View Free Memory
ViewGoogleMins, # View Google mins
ViewGoogleSheetInterval, # View Google mins
ViewLogFile, # View Log File
ViewPHCalibration, # View pH slope
ViewPIDConstants, # View PID constants
Expand Down