From f4599cae4056cab7b34968b5d76700bd9ea2e547 Mon Sep 17 00:00:00 2001 From: Hubert Tarasiuk Date: Thu, 7 May 2015 18:34:17 +0200 Subject: [PATCH 1/6] Implement timestamp support for local files in testenv * testenv/README: Change timestamp format definition * testenv/conf/local_files.py: Set proper timestamps --- testenv/README | 2 +- testenv/conf/local_files.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/testenv/README b/testenv/README index 081a957..cf22f89 100644 --- a/testenv/README +++ b/testenv/README @@ -124,7 +124,7 @@ WgetFile (str name, str contents, str timestamp, dict rules) None except name is a mandatory paramter, one may pass only those parameters that are required by the File object. -The timestamp string should be a valid Unix Timestamp as defined in RFC xxxx. +The timestamp string should be in a format: "YYYY-MM-DD HH:MM:SS" in UTC zone. The rules object is a dictionary element, with the key as the Rule Name and value as the Rule Data. In most cases, the Rule Data is another dictionary. diff --git a/testenv/conf/local_files.py b/testenv/conf/local_files.py index 5f9c8fa..908ced1 100644 --- a/testenv/conf/local_files.py +++ b/testenv/conf/local_files.py @@ -1,3 +1,6 @@ +from os import utime +from time import strptime +from calendar import timegm from conf import hook """ Pre-Test Hook: LocalFiles @@ -16,3 +19,8 @@ class LocalFiles: for f in self.local_files: with open(f.name, 'w') as fp: fp.write(f.content) + if f.timestamp is not None: + tstamp = timegm(strptime(f.timestamp, '%Y-%m-%d %H:%M:%S')) + atime = tstamp + mtime = tstamp + utime(f.name, (atime, mtime)) -- 2.4.0