def test_timestream_create(self):
     ts = TimeStream()
     ts.version = 1
     ts.create(self.tmp_path)
     self.assertEqual(ts.path, self.tmp_path)
     self.assertDictEqual(ts.image_data, {})
     self.assertDictEqual(ts.data, {})
 def test_timestream_load_bad(self):
     """Test TimeStream initialisation with bad/non timestream"""
     with self.assertRaises(ValueError):
         inst = TimeStream()
         inst.load(helpers.FILES["not_a_timestream"])
     with self.assertRaises(ValueError):
         inst = TimeStream()
         inst.load(helpers.FILES["timestream_bad"])
     with self.assertRaises(TypeError):
         inst = TimeStream()
         inst.load(None)
     with self.assertRaises(ValueError):
         inst = TimeStream()
         inst.version = 42
         inst.load(helpers.FILES["timestream"])
 def test_timestream_write(self):
     ts = TimeStream()
     ts.version = 1
     ts.create(self.tmp_path, ext="jpg")
     self.assertEqual(ts.path, self.tmp_path)
     self.assertDictEqual(ts.image_data, {})
     self.assertDictEqual(ts.data, {})
     for _ in range(10):
         img = TimeStreamImage()
         arr = np.arange(300, dtype="uint8")
         arr = arr.reshape((10, 10, 3))
         date = dt.datetime.now()
         str_date = ts_format_date(date)
         img.pixels = arr
         img.datetime = date
         img.data["fake"] = True
         ts.write_image(img)
         self.assertIn(str_date, ts.image_data)
         self.assertDictEqual(img.data, ts.image_data[str_date])
         self.assertTrue(path.exists, img.path)