Skip to content

Commit 4d08230

Browse files
authored
Test correct transactions management in the updated server's gRPC service (#746)
## Usage and product changes Fix Python's behavior testing framework lists parsing to substitute examples for the first element of the list. Update artifacts and dependencies refs. ## Implementation
1 parent 39b32fa commit 4d08230

File tree

8 files changed

+29
-18
lines changed

8 files changed

+29
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dependencies/typedb/artifacts.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def typedb_artifact():
2525
artifact_name = "typedb-all-{platform}-{version}.{ext}",
2626
tag_source = deployment["artifact"]["release"]["download"],
2727
commit_source = deployment["artifact"]["snapshot"]["download"],
28-
commit = "4859d4f8d7b965028c6dbea332ba2a779b97da66"
28+
commit = "588d742a36b24423b40eaf05d8013c0cd188425f"
2929
)
3030

3131
#def typedb_cloud_artifact():

dependencies/typedb/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ def typedb_behaviour():
3535
git_repository(
3636
name = "typedb_behaviour",
3737
remote = "https://github.com/typedb/typedb-behaviour",
38-
commit = "28e93a9eb2b411d5a3d04efb2812ff3a46363c24", # sync-marker: do not remove this comment, this is used for sync-dependencies by @typedb_behaviour
38+
commit = "3e4fe8c38e5a01ea9b198ee23c31cc832e003086", # sync-marker: do not remove this comment, this is used for sync-dependencies by @typedb_behaviour
3939
)

python/tests/behaviour/config/parameters.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
import parse
2525
from behave import register_type
26-
from behave.model import Table
26+
from behave.model import Table, Row
27+
from behave.runner import Context
2728
from hamcrest import *
2829
from typedb.api.answer.query_type import QueryType
2930
from typedb.api.connection.transaction import TransactionType
@@ -190,8 +191,10 @@ def parse_query_type(value: str) -> QueryType:
190191
register_type(QueryType=parse_query_type)
191192

192193

193-
def parse_list(table: Table) -> list[str]:
194-
return [table.headings[0]] + list(map(lambda row: row[0], table.rows))
194+
def parse_list(context: Context) -> list[str]:
195+
table: Table = context.table
196+
first_element = substitute_if_example(table.headings[0], context.active_outline)
197+
return [first_element] + list(map(lambda row: row[0], table.rows))
195198

196199

197200
def parse_dict(table: Table) -> dict[str, str]:
@@ -221,6 +224,14 @@ def parse_table(table: Table) -> list[list[tuple[str, str]]]:
221224
return [[(table.headings[idx], row[idx]) for idx in range(len(row))] for row in table.rows]
222225

223226

227+
def substitute_if_example(text: str, outline: Row) -> str:
228+
return outline[text[1:-1]] if is_example(text) else text
229+
230+
231+
def is_example(text: str) -> bool:
232+
return text[0] == '<' and text[-1] == '>'
233+
234+
224235
class MayError:
225236

226237
def __init__(self, may_error: bool, message: str = ""):

python/tests/behaviour/connection/database/database_steps.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def step_impl(context: Context, may_error: MayError):
4848

4949
@step("connection create databases")
5050
def step_impl(context: Context):
51-
names = parse_list(context.table)
51+
names = parse_list(context)
5252
create_databases(context.driver, names)
5353

5454

5555
@step("connection create databases in parallel")
5656
def step_impl(context: Context):
57-
names = parse_list(context.table)
57+
names = parse_list(context)
5858
assert_that(len(names), is_(less_than_or_equal_to(context.THREAD_POOL_SIZE)))
5959
with ThreadPoolExecutor(max_workers=context.THREAD_POOL_SIZE) as executor:
6060
for name in names:
@@ -75,12 +75,12 @@ def step_impl(context: Context, name: str, may_error: MayError):
7575

7676
@step("connection delete databases")
7777
def step_impl(context: Context):
78-
delete_databases(context.driver, names=parse_list(context.table))
78+
delete_databases(context.driver, names=parse_list(context))
7979

8080

8181
@step("connection delete databases in parallel")
8282
def step_impl(context: Context):
83-
names = parse_list(context.table)
83+
names = parse_list(context)
8484
assert_that(len(names), is_(less_than_or_equal_to(context.THREAD_POOL_SIZE)))
8585
with ThreadPoolExecutor(max_workers=context.THREAD_POOL_SIZE) as executor:
8686
for name in names:
@@ -106,7 +106,7 @@ def step_impl(context: Context, name: str):
106106

107107
@step("connection has databases")
108108
def step_impl(context: Context):
109-
has_databases(context, names=parse_list(context.table))
109+
has_databases(context, names=parse_list(context))
110110

111111

112112
def does_not_have_databases(context: Context, names: list[str]):
@@ -122,7 +122,7 @@ def step_impl(context: Context, name: str):
122122

123123
@step("connection does not have databases")
124124
def step_impl(context: Context):
125-
does_not_have_databases(context, names=parse_list(context.table))
125+
does_not_have_databases(context, names=parse_list(context))
126126

127127

128128
@step("connection get database({name}) has schema")

python/tests/behaviour/connection/transaction/transaction_steps.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def step_impl(context: Context, transaction_type: TransactionType, database_name
4242

4343
@step("connection open transactions for database: {database_name}, of type")
4444
def step_impl(context: Context, database_name: str):
45-
transaction_types = list(map(parse_transaction_type, parse_list(context.table)))
45+
transaction_types = list(map(parse_transaction_type, parse_list(context)))
4646
open_transactions_of_type(context, database_name, transaction_types)
4747

4848

@@ -89,7 +89,7 @@ def for_each_transaction_has_type(context: Context, transaction_types: list):
8989

9090
@step("transactions have type")
9191
def step_impl(context: Context):
92-
transaction_types = list(map(parse_transaction_type, parse_list(context.table)))
92+
transaction_types = list(map(parse_transaction_type, parse_list(context)))
9393
for_each_transaction_has_type(context, transaction_types)
9494

9595

@@ -100,7 +100,7 @@ def step_impl(context: Context, transaction_type: TransactionType):
100100

101101
@step("connection open transactions in parallel for database: {name}, of type")
102102
def step_impl(context: Context, name: str):
103-
types = list(map(parse_transaction_type, parse_list(context.table)))
103+
types = list(map(parse_transaction_type, parse_list(context)))
104104
assert_that(len(types), is_(less_than_or_equal_to(context.THREAD_POOL_SIZE)))
105105
with ThreadPoolExecutor(max_workers=context.THREAD_POOL_SIZE) as executor:
106106
context.transactions_parallel = []
@@ -121,7 +121,7 @@ def step_impl(context: Context, are_open: bool):
121121

122122
@step("transactions in parallel have type")
123123
def step_impl(context: Context):
124-
types = list(map(parse_transaction_type, parse_list(context.table)))
124+
types = list(map(parse_transaction_type, parse_list(context)))
125125
future_transactions = context.transactions_parallel
126126
assert_that(future_transactions, has_length(len(types)))
127127
future_transactions_iter = iter(future_transactions)

python/tests/behaviour/connection/user/user_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
@step("get all users")
2727
def step_impl(context: Context):
28-
assert_collections_equal([db.name for db in context.driver.users.all()], parse_list(context.table))
28+
assert_collections_equal([db.name for db in context.driver.users.all()], parse_list(context))
2929

3030

3131
@step("get all users{may_error:MayError}")

python/tests/behaviour/query/query_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def step_impl(context: Context, count: int, may_error: MayError):
190190
def step_impl(context: Context):
191191
collect_answer_if_needed(context)
192192
column_names = context.collected_answer[0].column_names()
193-
assert_that(sorted(list(column_names)), equal_to(sorted(parse_list(context.table))))
193+
assert_that(sorted(list(column_names)), equal_to(sorted(parse_list(context))))
194194

195195

196196
def get_row_get_concepts(context: Context, row_index: int) -> [Concept]:

0 commit comments

Comments
 (0)