Show More
@@ -17,13 +17,26 b' class TestAdminController(TestController' | |||
|
17 | 17 | def setup_class(cls): |
|
18 | 18 | UserLog.query().delete() |
|
19 | 19 | Session().commit() |
|
20 | ||
|
21 | def strptime(val): | |
|
22 | fmt = '%Y-%m-%d %H:%M:%S' | |
|
23 | if '.' not in val: | |
|
24 | return datetime.datetime.strptime(val, fmt) | |
|
25 | ||
|
26 | nofrag, frag = val.split(".") | |
|
27 | date = datetime.datetime.strptime(nofrag, fmt) | |
|
28 | ||
|
29 | frag = frag[:6] # truncate to microseconds | |
|
30 | frag += (6 - len(frag)) * '0' # add 0s | |
|
31 | return date.replace(microsecond=int(frag)) | |
|
32 | ||
|
20 | 33 | with open(os.path.join(FIXTURES, 'journal_dump.csv')) as f: |
|
21 | 34 | for row in csv.DictReader(f): |
|
22 | 35 | ul = UserLog() |
|
23 | 36 | for k, v in row.iteritems(): |
|
24 | 37 | v = safe_unicode(v) |
|
25 | 38 | if k == 'action_date': |
|
26 |
v = |
|
|
39 | v = strptime(v) | |
|
27 | 40 | if k in ['user_id', 'repository_id']: |
|
28 | 41 | #nullable due to FK problems |
|
29 | 42 | v = None |
@@ -134,4 +147,4 b' class TestAdminController(TestController' | |||
|
134 | 147 | self.log_user() |
|
135 | 148 | response = self.app.get(url(controller='admin/admin', action='index', |
|
136 | 149 | filter='date:20121020')) |
|
137 | response.mustcontain('17 entries') No newline at end of file | |
|
150 | response.mustcontain('17 entries') |
General Comments 0
You need to be logged in to leave comments.
Login now