1616class TestWGet (PavTestCase ):
1717
1818 GET_TARGET = "https://github.com/lanl/Pavilion/raw/master/README.md"
19+ GET_TARGET2 = "https://github.com/lanl/Pavilion/raw/master/RELEASE.txt"
1920 TARGET_HASH = '275fa3c8aeb10d145754388446be1f24bb16fb00'
2021
2122 _logger = logging .getLogger (__file__ )
@@ -73,8 +74,6 @@ def test_update(self):
7374 # It should update the file if the info file isn't there and the
7475 # sizes don't match.
7576 ctime = dest_fn .stat ().st_ctime
76- with dest_fn .open ('ab' ) as dest_file :
77- dest_file .write (b'a' )
7877 info_fn .unlink ()
7978 try :
8079 wget .update (self .pav_cfg , self .GET_TARGET , dest_fn )
@@ -86,7 +85,6 @@ def test_update(self):
8685
8786 # We'll muck up the info file data, to force an update.
8887 db_data = {
89- 'ETag' : 'nope' ,
9088 'Content-Length' : '-1'
9189 }
9290 with info_fn .open ('w' ) as info_file :
@@ -98,5 +96,21 @@ def test_update(self):
9896 new_ctime = dest_fn .stat ().st_ctime
9997 self .assertNotEqual (new_ctime , ctime )
10098
101- dest_fn .stat ()
102- info_fn .stat ()
99+ ctime = new_ctime
100+ # Checking if a remote file change forces an update
101+ try :
102+ wget .update (self .pav_cfg , self .GET_TARGET2 , dest_fn )
103+ except pavilion .errors .WGetError as err :
104+ self .fail ("Failed with: {}" .format (err .args [0 ]))
105+ new_ctime = dest_fn .stat ().st_ctime
106+ self .assertNotEqual (new_ctime , ctime )
107+
108+ ctime = new_ctime
109+ # Make sure no updates happen if everything is the same
110+ try :
111+ wget .update (self .pav_cfg , self .GET_TARGET2 , dest_fn )
112+ except pavilion .errors .WGetError as err :
113+ self .fail ("Failed with: {}" .format (err .args [0 ]))
114+ new_ctime = dest_fn .stat ().st_ctime
115+ self .assertEqual (new_ctime , ctime )
116+
0 commit comments