~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to test/misc/make_date_test.py

  • Committer: mattgiuca
  • Date: 2008-02-19 00:54:28 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:500
db: get_user and get_users now return User objects instead of dictionaries.
    This is the major part of replacing dicts with User objects, as it
    propagates upwards.

Propagated User objects up through the following modules:
    listusers.py, dispatch.login, authenticate, userservice, forumutil
All of these now treat users as an object rather than a dict.

To save on the size of the changes so far, login still individually copies
fields over to the session (so the session does not yet store a user object;
that is the second part of this refactor).

WOO!! Revision 500 :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# Run in a user's jail to test the "short date format" displayed in the
 
3
# file browser's file table.
 
4
#
 
5
# Generates a bunch of files in the current directory and sets their date
 
6
# stamps to various dates in the past.
 
7
# The files are named after their date stamps relative to today.
 
8
#
 
9
# Author: Matt Giuca
 
10
# Date: 13/1/2008
 
11
 
 
12
import os
 
13
import time
 
14
 
 
15
seconds_per_day = 60*60*24
 
16
time_now = time.time()
 
17
 
 
18
if time.daylight:
 
19
    timezone_offset = time.altzone
 
20
else:
 
21
    timezone_offset = time.timezone
 
22
 
 
23
# Time at the beginning of today, local time
 
24
local_daystart \
 
25
    = time_now - int(time_now - timezone_offset) % seconds_per_day
 
26
 
 
27
def make_file_days_ago(days_ago):
 
28
    global time_now
 
29
    make_file(str(days_ago) + "days",
 
30
        time_now - seconds_per_day*days_ago)
 
31
def make_file(fname, timestamp):
 
32
    f = open(fname, 'w')
 
33
    f.close()
 
34
    os.utime(fname, (timestamp, timestamp))
 
35
 
 
36
make_file_days_ago(0)
 
37
make_file_days_ago(1)
 
38
make_file_days_ago(2)
 
39
make_file_days_ago(3)
 
40
make_file_days_ago(4)
 
41
make_file_days_ago(5)
 
42
make_file_days_ago(6)
 
43
make_file_days_ago(7)
 
44
make_file_days_ago(10)
 
45
make_file_days_ago(365)
 
46
 
 
47
# Now a boundary test - Make a file in the last second of Yesterday.
 
48
make_file("first_second_today", local_daystart)
 
49
make_file("last_second_yesterday", local_daystart-1)