@@ -32,20 +32,27 @@ def setUp(self) -> None:
32
32
self .fs .add_real_directory (Path (__file__ ).parent .parent ) # Allow ui file to be found
33
33
self .live_directory = Path ("/live_dir" )
34
34
self .fs .create_dir (self .live_directory )
35
+ self .initial_time = 4000.0
35
36
36
37
def _generate_image (self ):
37
38
image = np .zeros ((10 , 10 ))
38
39
image [5 , :] = np .arange (10 )
39
- os .utime (self .live_directory , (10 , 4000.0 ))
40
+ os .utime (self .live_directory , (10 , self .initial_time ))
41
+ self .initial_time += 1000
40
42
return image
41
43
42
44
def _make_simple_dir (self , directory : Path ):
43
45
file_list = [directory / f"abc_{ i :06d} .tif" for i in range (5 )]
46
+ # set initial time to live directory utime
47
+ # initial_time = 4000.0
44
48
if not directory .exists ():
45
49
self .fs .create_dir (directory )
46
-
50
+ # increment = 1
47
51
for file in file_list :
48
52
self .fs .create_file (file )
53
+ # set file time to incrememnt by 1
54
+ # os.utime(file, (10, initial_time + increment))
55
+ # increment += 1
49
56
50
57
return file_list
51
58
@@ -96,8 +103,12 @@ def test_rotate_operation_rotates_image(self, _mock_time, _mock_image_watcher, m
96
103
def test_file_time_is_updated (self , _mock_time , _mock_image_watcher , mock_load_image ):
97
104
file_list = self ._make_simple_dir (self .live_directory )
98
105
image_list = [Image_Data (path ) for path in file_list ]
99
- mock_load_image .return_value = self ._generate_image ()
100
- self .imaging .show_live_viewer (self .live_directory )
101
- self .imaging .live_viewer .presenter .model ._handle_image_changed_in_list (image_list )
102
- self .check_target (widget = self .imaging .live_viewer )
103
- # self.assertEqual(self.imaging.live_viewer.presenter.model.images[0].image_modified_time_stamp, "4000.0")
106
+ increment = 0
107
+ for image in image_list :
108
+ image .image_modified_time_stamp = 4000.0 + increment
109
+ mock_load_image .return_value = self ._generate_image ()
110
+ self .imaging .show_live_viewer (self .live_directory )
111
+ self .assertEqual (image .image_modified_time_stamp ,
112
+ 4000.0 + increment ) # Add this line to check the label time
113
+ self .imaging .live_viewer .presenter .model ._handle_image_changed_in_list (image_list )
114
+ self .check_target (widget = self .imaging .live_viewer )
0 commit comments