Skip to content

Commit

Permalink
Fix ArraySchema's deletion test
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gu <[email protected]>
  • Loading branch information
tylergu committed Oct 14, 2024
1 parent 178984a commit ae6c198
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions acto/schema/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def gen(self, exclude_value=None, minimum: bool = False, **kwargs) -> list:
num = 0
if "size" in kwargs and kwargs["size"] is not None:
num = kwargs["size"]
elif minimum:
num = self.min_items
else:
num = random.randint(self.min_items, self.max_items)

Check warning on line 133 in acto/schema/array.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on line 133

if self.enum is not None:
if exclude_value is not None:
Expand All @@ -145,10 +149,6 @@ def gen(self, exclude_value=None, minimum: bool = False, **kwargs) -> list:

# XXX: need to handle exclude_value, but not important for now for array types
result = []
if minimum:
num = self.min_items
else:
num = random.randint(self.min_items, self.max_items)
for _ in range(num):
result.append(self.item_schema.gen(minimum=minimum))
return result
Expand Down
8 changes: 5 additions & 3 deletions test/integration_tests/test_semantic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ def test_rbop_tests(self):
curr_input_with_schema, field_path, testcase, setup=True
)

if not testcase.test_precondition(
curr_input_with_schema.get_value_by_path(list(field_path))
):
field_curr_value = curr_input_with_schema.get_value_by_path(
list(field_path)
)
if not testcase.test_precondition(field_curr_value):
raise AssertionError(
"Test precondition failed after applying the test case"
f" {testcase} to the field {field_path_str}"
f" current value: {field_curr_value}"
)

group.finish_testcase()
Expand Down

0 comments on commit ae6c198

Please sign in to comment.