Skip to content

Commit

Permalink
Improve test data generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob720 committed Jan 6, 2025
1 parent 8f12f93 commit b0a9094
Show file tree
Hide file tree
Showing 31 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/aa_remove_data/pb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def generate_test_samples(
nano_gap (int, optional): Gap in nanoseconds between samples.
Defaults to 0.
"""
self.header.pvname = "test"
self.header.pvname = "generated_test_data"
self.header.year = year
self.header.type = pv_type

Expand Down
18 changes: 18 additions & 0 deletions tests/generate_test_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Script to generate data for testing purposes.

from pathlib import Path

from aa_remove_data.pb_utils import PBUtils


def generate_test_data():
pb = PBUtils()
for i in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14):
pb.generate_test_samples(pv_type=i, start=i * 100)
pb._write_started = False
pb.write_to_txt(Path(f"tests/test_data/{pb.pv_type}_test_data.txt"))
pb.write_pb(Path(f"tests/test_data/{pb.pv_type}_test_data.pb"))


if __name__ == "__main__":
generate_test_data()
Binary file modified tests/test_data/SCALAR_BYTE_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/SCALAR_BYTE_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, SCALAR_BYTE, 2024
generated_test_data, SCALAR_BYTE, 2024
DATE SECONDS NANO VAL
2024-01-01 00:06:40 400 0 b'\x00\x00'
2024-01-01 00:06:41 401 0 b'\x00\x01'
Expand Down
Binary file modified tests/test_data/SCALAR_DOUBLE_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/SCALAR_DOUBLE_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, SCALAR_DOUBLE, 2024
generated_test_data, SCALAR_DOUBLE, 2024
DATE SECONDS NANO VAL
2024-01-01 00:10:00 600 0 0.0
2024-01-01 00:10:01 601 0 1.0
Expand Down
Binary file modified tests/test_data/SCALAR_ENUM_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/SCALAR_ENUM_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, SCALAR_ENUM, 2024
generated_test_data, SCALAR_ENUM, 2024
DATE SECONDS NANO VAL
2024-01-01 00:05:00 300 0 0
2024-01-01 00:05:01 301 0 1
Expand Down
Binary file modified tests/test_data/SCALAR_FLOAT_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/SCALAR_FLOAT_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, SCALAR_FLOAT, 2024
generated_test_data, SCALAR_FLOAT, 2024
DATE SECONDS NANO VAL
2024-01-01 00:03:20 200 0 0.0
2024-01-01 00:03:21 201 0 1.0
Expand Down
Binary file modified tests/test_data/SCALAR_INT_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/SCALAR_INT_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, SCALAR_INT, 2024
generated_test_data, SCALAR_INT, 2024
DATE SECONDS NANO VAL
2024-01-01 00:08:20 500 0 0
2024-01-01 00:08:21 501 0 1
Expand Down
Binary file modified tests/test_data/SCALAR_SHORT_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/SCALAR_SHORT_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, SCALAR_SHORT, 2024
generated_test_data, SCALAR_SHORT, 2024
DATE SECONDS NANO VAL
2024-01-01 00:01:40 100 0 0
2024-01-01 00:01:41 101 0 1
Expand Down
Binary file modified tests/test_data/SCALAR_STRING_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/SCALAR_STRING_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, SCALAR_STRING, 2024
generated_test_data, SCALAR_STRING, 2024
DATE SECONDS NANO VAL
2024-01-01 00:00:00 0 0 0
2024-01-01 00:00:01 1 0 1
Expand Down
Binary file modified tests/test_data/V4_GENERIC_BYTES_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/V4_GENERIC_BYTES_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, V4_GENERIC_BYTES, 2024
generated_test_data, V4_GENERIC_BYTES, 2024
DATE SECONDS NANO VAL
2024-01-01 00:23:20 1400 0 b'\x00\x00'
2024-01-01 00:23:21 1401 0 b'\x00\x01'
Expand Down
Binary file modified tests/test_data/WAVEFORM_DOUBLE_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/WAVEFORM_DOUBLE_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, WAVEFORM_DOUBLE, 2024
generated_test_data, WAVEFORM_DOUBLE, 2024
DATE SECONDS NANO VAL
2024-01-01 00:21:40 1300 0 [0.0, 1.0, 2.0, 3.0, 4.0]
2024-01-01 00:21:41 1301 0 [5.0, 6.0, 7.0, 8.0, 9.0]
Expand Down
Binary file modified tests/test_data/WAVEFORM_ENUM_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/WAVEFORM_ENUM_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, WAVEFORM_ENUM, 2024
generated_test_data, WAVEFORM_ENUM, 2024
DATE SECONDS NANO VAL
2024-01-01 00:16:40 1000 0 [0, 1, 2, 3, 4]
2024-01-01 00:16:41 1001 0 [5, 6, 7, 8, 9]
Expand Down
Binary file modified tests/test_data/WAVEFORM_FLOAT_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/WAVEFORM_FLOAT_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, WAVEFORM_FLOAT, 2024
generated_test_data, WAVEFORM_FLOAT, 2024
DATE SECONDS NANO VAL
2024-01-01 00:15:00 900 0 [0.0, 1.0, 2.0, 3.0, 4.0]
2024-01-01 00:15:01 901 0 [5.0, 6.0, 7.0, 8.0, 9.0]
Expand Down
Binary file modified tests/test_data/WAVEFORM_INT_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/WAVEFORM_INT_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, WAVEFORM_INT, 2024
generated_test_data, WAVEFORM_INT, 2024
DATE SECONDS NANO VAL
2024-01-01 00:20:00 1200 0 [0, 1, 2, 3, 4]
2024-01-01 00:20:01 1201 0 [5, 6, 7, 8, 9]
Expand Down
Binary file modified tests/test_data/WAVEFORM_SHORT_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/WAVEFORM_SHORT_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, WAVEFORM_SHORT, 2024
generated_test_data, WAVEFORM_SHORT, 2024
DATE SECONDS NANO VAL
2024-01-01 00:13:20 800 0 [0, 1, 2, 3, 4]
2024-01-01 00:13:21 801 0 [5, 6, 7, 8, 9]
Expand Down
Binary file modified tests/test_data/WAVEFORM_STRING_test_data.pb
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_data/WAVEFORM_STRING_test_data.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test, WAVEFORM_STRING, 2024
generated_test_data, WAVEFORM_STRING, 2024
DATE SECONDS NANO VAL
2024-01-01 00:11:40 700 0 ['0', '1', '2', '3', '4']
2024-01-01 00:11:41 701 0 ['5', '6', '7', '8', '9']
Expand Down
9 changes: 0 additions & 9 deletions tests/test_pb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,6 @@ def test_read_write_pb_all_types():
assert are_identical is True


def generate_test_data(): # Not a test - used to generate test data.
pb = PBUtils()
for i in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14):
pb.generate_test_samples(pv_type=i, start=i * 100)
pb._write_started = False
pb.write_to_txt(Path(f"tests/test_data/{pb.pv_type}_test_data.txt"))
pb.write_pb(Path(f"tests/test_data/{pb.pv_type}_test_data.pb"))


def test_chunking_read_all_types():
pv_types = (
"SCALAR_BYTE",
Expand Down

0 comments on commit b0a9094

Please sign in to comment.