Browse Source

Fill out test coverage

tags/nilmdb-1.4.0
Jim Paris 11 years ago
parent
commit
049375d30e
3 changed files with 15 additions and 13 deletions
  1. +1
    -1
      tests/test_bulkdata.py
  2. +10
    -7
      tests/test_client.py
  3. +4
    -5
      tests/test_cmdline.py

+ 1
- 1
tests/test_bulkdata.py View File

@@ -60,7 +60,7 @@ class TestBulkData(object):
with assert_raises(IndexError):
x = get_node_slice(0)
with assert_raises(IndexError):
x = node[0]
x = node[0] # timestamp
raw = []
for i in range(1000):
raw.append("%d 1 2 3 4 5 6 7 8\n" % (10000 + i))


+ 10
- 7
tests/test_client.py View File

@@ -639,23 +639,26 @@ class TestClient(object):
eq_(connections(), (1, 6))

def test_client_13_timestamp_rounding(self):
raise SkipTest("doesn't work right")
# Test potentially bad timestamps (due to floating point roundoff etc)
# Test potentially bad timestamps (due to floating point
# roundoff etc). The server will round floating point values
# to the nearest int.
client = nilmdb.client.Client(testurl)

client.stream_create("/rounding/test", "uint16_1")
with client.stream_insert_context("/rounding/test",
100000000, 200000000) as ctx:
ctx.insert("100000000 1\n")
ctx.insert("150000000 1\n")
ctx.insert("199999999 1\n")
100000000, 200000000.1) as ctx:
ctx.insert("100000000.1 1\n")
ctx.insert("150000000.00003 1\n")
ctx.insert("199999999.4 1\n")
eq_(list(client.stream_intervals("/rounding/test")),
[ [ 100000000, 200000000 ] ])

with assert_raises(ClientError):
with client.stream_insert_context("/rounding/test",
200000000, 300000000) as ctx:
ctx.insert("200000000 1\n")
ctx.insert("250000000 1\n")
# Server will round this and give an error on finalize()
ctx.insert("299999999.99 1\n")

client.stream_destroy("/rounding/test")


+ 4
- 5
tests/test_cmdline.py View File

@@ -231,11 +231,10 @@ class TestCmdline(object):
eq_(parse_time("snapshot-20120405-140000.raw.gz"), test)
eq_(parse_time("prep-20120405T1400"), test)
eq_(parse_time("1333648800.0"), test)
try:
eq_(parse_time("1333648800000000"), test)
eq_(parse_time("@1333648800000000"), test)
except AssertionError:
warnings.warn("parsing int64 timestamps isn't working")
eq_(parse_time("1333648800000000"), test)
eq_(parse_time("@1333648800000000"), test)
with assert_raises(ValueError):
parse_time("@hashtag12345")

def test_03_info(self):
self.ok("info")


Loading…
Cancel
Save