Skip to content

Commit

Permalink
add numeric and real data to random tests.
Browse files Browse the repository at this point in the history
Note that we still need to fix the edit script so that round trips for real and
numeric types are output in the right format.
  • Loading branch information
lmcmicu committed Sep 10, 2023
1 parent 431851f commit 8402ab6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 9 additions & 5 deletions test/generate_random_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def get_constrained_cell_value(table, column, row_num, prev_inserts):
+ "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
)
elif CONFIG[table][column]["datatype"] in ["integer", "real", "numeric"]:
# No leading 0s:
# No leading zeros:
cell = "".join(random.choices("123456789", k=1)) + "".join(
random.choices(string.digits, k=TOKEN_LENGTH - 1)
)
Expand All @@ -271,7 +271,8 @@ def get_constrained_cell_value(table, column, row_num, prev_inserts):
cell
+ "."
+ "".join(random.choices("0123456789", k=1))
+ "".join(random.choices(string.digits, k=3))
# No trailing zeros:
+ "".join(random.choices("123456789", k=3))
)
else:
print(
Expand Down Expand Up @@ -357,7 +358,7 @@ def main():
+ "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
)
elif CONFIG[table][column]["datatype"] == "text":
# No leading 0s:
# No leading zeros:
cell = "".join(random.choices("123456789", k=1)) + "".join(
random.choices(string.digits, k=TOKEN_LENGTH - 1)
)
Expand All @@ -367,21 +368,24 @@ def main():
cell
+ "."
+ "".join(random.choices("0123456789", k=1))
+ "".join(random.choices(string.digits, k=3))
# No trailing zeros:
+ "".join(random.choices("123456789", k=3))
)
elif CONFIG[table][column]["datatype"] != "integer":
cell = "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
elif random.choice([True, False]):
cell = "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
else:
# No leading zeros:
cell = "".join(random.choices("123456789", k=1)) + "".join(
random.choices(string.digits, k=TOKEN_LENGTH - 1)
)
cell = (
cell
+ "."
+ "".join(random.choices("0123456789", k=1))
+ "".join(random.choices(string.digits, k=3))
# No trailing zeros:
+ "".join(random.choices("123456789", k=3))
)

row[column] = cell
Expand Down
4 changes: 2 additions & 2 deletions test/random_test_data/column.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ table2 child trimmed_line from(table4.other_foreign_column)
table2 parent empty trimmed_line tree(child)
table2 xyzzy empty trimmed_line under(table2.child, d)
table2 foo empty integer from(table4.numeric_foreign_column)
table2 bar empty text
table2 bar empty numeric
table3 source prefix from(table1.prefix)
table3 id CURIE unique
table3 label label primary
Expand All @@ -38,7 +38,7 @@ table4 foreign_column text unique
table4 other_foreign_column text unique
table4 numeric_foreign_column integer primary
table5 foo word primary
table5 bar integer
table5 bar real
table6 child integer from(table4.numeric_foreign_column)
table6 parent empty integer tree(child)
table6 xyzzy empty integer under(table6.child, 4)
Expand Down
4 changes: 3 additions & 1 deletion test/random_test_data/datatype.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ label trimmed_line match(/\S([^\n]*\S)*/)
line text exclude(/\n/) a line of text input
natural_number integer match(/\d+/) a natural number, including zero INTEGER INTEGER
nonspace trimmed_line exclude(/\s/) text without whitespace
numeric nonspace match(/-?\d+(\.\d+)?/) a positive or negative number NUMERIC NUMERIC
path line exclude(/\n/) a path to a file
prefix word exclude(/\W/) a prefix for a CURIE
real nonspace match(/-?\d+(\.\d+)?/) a positive or negative real number REAL REAL
suffix word exclude(/\W/) a suffix for a CURIE
table_name word exclude(/\W/) a table name
table_type word lowercase in('table', 'column', 'datatype') a table type
text any text TEXT TEXT xsd:string textarea
text any text TEXT VARCHAR(100) xsd:string textarea
trimmed_line line match(/\S([^\n]*\S)*/) a line of text that does not begin or end with whitespace
trimmed_text text exclude(/^\s+|\s+$/) text that does not begin or end with whitespace
word nonspace exclude(/\W/) a single word: letters, numbers, underscore

0 comments on commit 8402ab6

Please sign in to comment.