You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1.1 KiB

  1. import nilmdb
  2. from nilmdb import NilmDB
  3. from nose.tools import assert_raises
  4. import itertools
  5. import os
  6. import sys
  7. import atexit
  8. testdb = "tests/test.db"
  9. #@atexit.register
  10. #def cleanup():
  11. # os.unlink(testdb)
  12. def test_NilmDB():
  13. try:
  14. os.unlink(testdb)
  15. except:
  16. pass
  17. with assert_raises(IOError):
  18. nilmdb.NilmDB("/nonexistant-db/foo")
  19. db = nilmdb.NilmDB(testdb)
  20. db.close()
  21. db = nilmdb.NilmDB(testdb)
  22. def test_stream():
  23. db = nilmdb.NilmDB(testdb)
  24. assert(db.stream_list() == [])
  25. db.stream_create("/newton/prep", nilmdb.layout.PrepData)
  26. db.stream_create("/newton/raw", nilmdb.layout.RawData)
  27. db.stream_create("/newton/rawnotch", nilmdb.layout.RawNotchedData)
  28. # Verify we got 3 streams
  29. assert(db.stream_list() == [ "/newton/prep",
  30. "/newton/raw",
  31. "/newton/rawnotch" ])
  32. # Verify that columns were made right
  33. assert(len(db.h5file.getNode("/newton/prep").cols) == 9)
  34. assert(len(db.h5file.getNode("/newton/raw").cols) == 7)
  35. assert(len(db.h5file.getNode("/newton/rawnotch").cols) == 10)