Browse Source

Move more datetime_tz calls into common code

tags/nilmdb-1.4.0
Jim Paris 11 years ago
parent
commit
56679ad770
3 changed files with 6 additions and 10 deletions
  1. +4
    -7
      tests/test_client.py
  2. +1
    -1
      tests/test_interval.py
  3. +1
    -2
      tests/test_timestamper.py

+ 4
- 7
tests/test_client.py View File

@@ -186,8 +186,7 @@ class TestClient(object):
datetime_tz.localtz_set("America/New_York")

testfile = "tests/data/prep-20120323T1000"
start = datetime_tz.datetime_tz.smartparse("20120323T1000")
start = start.totimestamp()
start = nilmdb.utils.time.parse_time("20120323T1000")
rate = 120

# First try a nonexistent path
@@ -301,13 +300,11 @@ class TestClient(object):
client = nilmdb.client.Client(url = testurl)

# Trigger a client error in generator
start = datetime_tz.datetime_tz.smartparse("20120323T2000")
end = datetime_tz.datetime_tz.smartparse("20120323T1000")
start = nilmdb.utils.time.parse_time("20120323T2000")
end = nilmdb.utils.time.parse_time("20120323T1000")
for function in [ client.stream_intervals, client.stream_extract ]:
with assert_raises(ClientError) as e:
function("/newton/prep",
start.totimestamp(),
end.totimestamp()).next()
function("/newton/prep", start, end).next()
in_("400 Bad Request", str(e.exception))
in_("start must precede end", str(e.exception))



+ 1
- 1
tests/test_interval.py View File

@@ -51,7 +51,7 @@ class TestInterval:
# Test Interval class
os.environ['TZ'] = "America/New_York"
datetime_tz._localtz = None
(d1, d2, d3) = [ datetime_tz.datetime_tz.smartparse(x).totimestamp()
(d1, d2, d3) = [ nilmdb.utils.time.parse_time(x)
for x in [ "03/24/2012", "03/25/2012", "03/26/2012" ] ]

# basic construction


+ 1
- 2
tests/test_timestamper.py View File

@@ -1,6 +1,5 @@
import nilmdb
from nilmdb.utils.printf import *
from nilmdb.utils import datetime_tz

from nose.tools import *
from nose.tools import assert_raises
@@ -20,7 +19,7 @@ class TestTimestamper(object):
def join(list):
return "\n".join(list) + "\n"

start = datetime_tz.datetime_tz.smartparse("03/24/2012").totimestamp()
start = nilmdb.utils.time.parse_time("03/24/2012")
lines_in = [ "hello", "world", "hello world", "# commented out" ]
lines_out = [ "1332561600.000000 hello",
"1332561600.000125 world",


Loading…
Cancel
Save