source: orange/orange/doc/modules/server_files_update.py @ 5897:9ea6bed02f54

Revision 5897:9ea6bed02f54, 1.1 KB checked in by blaz <blaz.zupan@…>, 5 years ago (diff)

regression test script for orngServerFiles. Checks single file update.

Line 
1import orngServerFiles
2import os
3reload(orngServerFiles)
4
5domain = "demo"
6filename = "orngServerFiles.py"
7
8print "Downloading domain: %s, file: %s" % (domain, filename) 
9orngServerFiles.download(domain, filename, verbose=False)
10print "Needs update? %s (should be False)" % orngServerFiles.needs_update(domain, filename)
11
12# change the access and modified time of the local file
13# this is stored in the .info file (does not depend on the actual datetime
14# values that we could access through os.stat(path) or set using us.utime)
15path = orngServerFiles.localpath(domain, filename) + ".info"
16f = file(path)
17str = [f.readline()] # first line
18s = "1800" + f.readline()[4:] # second line with date, change it
19print "Changing date to", s.strip() 
20str += [s]
21str += f.readlines() # remaining lines
22f.close()
23f = file(path, "w")
24f.writelines(str)
25f.close()
26
27print "Needs update? %s (should be True)" % orngServerFiles.needs_update(domain, filename)
28print "Updating ..."
29orngServerFiles.update(domain, filename, verbose=False)
30print "Needs update? %s (should be False)" % orngServerFiles.needs_update(domain, filename)
31
Note: See TracBrowser for help on using the repository browser.