def test_write_json(self): self.example_packet.write_json(TEST_DATA_DIR, "test.json") self.example_packet.write_json(TEST_DATA_DIR) self.assertEqual(self.example_packet, reader.read_json_file(test_data("test.json"))) self.assertEqual( self.example_packet, reader.read_json_file(test_data("0000000001_1552075743960.json"))) os.remove(test_data("test.json")) os.remove(test_data("0000000001_1552075743960.json"))
def setUp(self): # Make some copies of the test data so that they can be used here shutil.copyfile(test_data("example.rdvxz"), test_data("test_a.rdvxz")) shutil.copyfile(test_data("example.rdvxz"), test_data("test_b.rdvxz")) shutil.copyfile(test_data("example.json"), test_data("test_c.json")) shutil.copyfile(test_data("example.json"), test_data("test_d.json"))
def setUp(self) -> None: self.empty_image_sensor: image.Image = image.Image.new() self.non_empty_image_sensor: image.Image = image.Image.new() with open(test_utils.test_data('redvox_logo.png'), "rb") as image_in: data_as_bytes: bytes = image_in.read() self.non_empty_image_sensor.set_samples( [data_as_bytes, data_as_bytes]) self.non_empty_image_sensor.set_image_codec(image.ImageCodec.PNG) self.non_empty_image_sensor.get_timestamps().set_default_unit() self.non_empty_image_sensor.get_timestamps().set_timestamps( np.array([1000, 2000]), True)
def test_to_rdvxz_multi(self): if os.name != "nt": joined: str = str(os.path.join(TEST_DATA_DIR, "*.json")) os.system(f"python3 -m redvox.cli.cli json-to-rdvxz {joined}") self.assertTrue(os.path.isfile(test_data("test_c.rdvxz"))) self.assertTrue(os.path.isfile(test_data("test_d.rdvxz"))) self.assertEqual( reader.read_rdvxz_file(test_data("test_c.rdvxz")), reader.read_json_file(test_data("test_c.json"))) self.assertEqual( reader.read_rdvxz_file(test_data("test_d.rdvxz")), reader.read_json_file(test_data("test_d.json")))
def setUp(self) -> None: test_filepath_api900: str = tests.test_data( "1637680001_1532459248280.rdvxz") api900_packet = reader.read_file(test_filepath_api900) self.api900_wrapped_packet: reader.WrappedRedvoxPacket = reader.wrap( api900_packet) timesync_channel: reader.TimeSynchronizationSensor = self.api900_wrapped_packet.time_synchronization_sensor( ) self.coeffs900: np.ndarray = timesync_channel.payload_values() self.nm900: int = int(len(self.coeffs900) / 6) self.fs: float = self.api900_wrapped_packet.microphone_sensor( ).sample_rate_hz() self.b0 = self.api900_wrapped_packet.app_file_start_timestamp_machine() self.a1, self.a2, self.a3, self.b1, self.b2, self.b3 = \ tri_message_stats.transmit_receive_timestamps_microsec(self.coeffs900) self.tri_ms = tri_message_stats.TriMessageStats( self.api900_wrapped_packet.redvox_id(), self.a1, self.a2, self.a3, self.b1, self.b2, self.b3)
def test_append_value(self): with open(test_utils.test_data('redvox_logo.png'), "rb") as image_in: data_as_bytes: bytes = image_in.read() self.non_empty_image_sensor.append_value(data_as_bytes) self.assertEqual(self.non_empty_image_sensor.get_num_images(), 3)
def setUp(self): self.example_packet = reader.read_rdvxz_file( test_utils.test_data("example.rdvxz")) self.cloned_packet = self.example_packet.clone()
def setUp(self): self.example_packet = reader.read_rdvxz_file( test_data("example.rdvxz")) self.empty_packet = reader.WrappedRedvoxPacket()
def test_print_single(self): output: str = subprocess.check_output( "python3 -m redvox.cli.cli print-z %s" % test_data("test_a.rdvxz"), shell=True).decode() self.assertTrue("api: 900" in output)
def test_to_rdvxz_single(self): os.system("python3 -m redvox.cli.cli json-to-rdvxz %s" % test_data("test_c.json")) self.assertTrue(os.path.isfile(test_data("test_c.rdvxz"))) self.assertEqual(reader.read_rdvxz_file(test_data("test_c.rdvxz")), reader.read_json_file(test_data("test_c.json")))