Skip to content

Commit

Permalink
test fix - file exploring - mock timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
odudex committed Jun 29, 2024
1 parent bfa6f22 commit f80e79b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/pages/test_file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def mock_file_operations(mocker):
def test_file_exploring(m5stickv, mocker, mock_file_operations):
from krux.pages.file_manager import FileManager
from krux.input import BUTTON_ENTER, BUTTON_PAGE
import time

BTN_SEQUENCE = (
[BUTTON_PAGE] # Move to second file
Expand All @@ -23,6 +24,11 @@ def test_file_exploring(m5stickv, mocker, mock_file_operations):
+ [BUTTON_PAGE] # Go to "back"
+ [BUTTON_ENTER] # Leave file explorer
)

def mock_localtime(timestamp):
return time.gmtime(timestamp)

mocker.patch("time.localtime", side_effect=mock_localtime)
mocker.patch(
"krux.sd_card.SDHandler.dir_exists", mocker.MagicMock(side_effect=[True, False])
)
Expand All @@ -35,7 +41,7 @@ def test_file_exploring(m5stickv, mocker, mock_file_operations):
ctx.display.draw_hcentered_text.assert_has_calls(
[
mocker.call(
"second_file\n\nSize: 1.1 KB\n\nCreated: 1969-12-31 21:00\n\nModified: 1969-12-31 21:00"
"second_file\n\nSize: 1.1 KB\n\nCreated: 1970-01-01 00:00\n\nModified: 1970-01-01 00:00"
)
]
)
Expand Down

0 comments on commit f80e79b

Please sign in to comment.