-
Notifications
You must be signed in to change notification settings - Fork 15
[#258] make a test rule for totalrows fix #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
f2681fc
da0141b
352abf9
5934c60
9170a9a
32ccaa1
83b2418
7345ed1
51c432f
a77fa79
7d3431e
9fee0e8
5ab6c01
25e6bba
1db5444
d642c35
d6ae3b6
9f14b36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import datetime | ||
| import pprint as pp | ||
|
d-w-moore marked this conversation as resolved.
Outdated
|
||
| from genquery import Query | ||
|
|
||
| class Err(Exception): pass | ||
|
|
||
| def main(rule_args, callback, rei): | ||
| colls = [] | ||
| home='/tempZone/home/rods' | ||
| now = f'{datetime.datetime.now():%s.%f}' | ||
|
|
||
| # Keep the following an even number: | ||
| n_base_names = 10 | ||
|
d-w-moore marked this conversation as resolved.
Outdated
|
||
|
|
||
| coll_names_lowercase = ['issue-258-'+str(i) for i in range(n_base_names)] | ||
|
|
||
| try: | ||
| for coll in (coll_names_lowercase + [_.capitalize() for _ in coll_names_lowercase]): | ||
| retv = callback.msiCollCreate((coll:=f'{home}/{now}/{coll}'), '1', -1) | ||
| if retv['arguments'][2] != 0: | ||
| raise Err(f'could not create test collection {coll}') | ||
| else: | ||
| colls.append(coll) | ||
|
|
||
| for limit_ in (None, 4, 14): | ||
| for case_sensitive_ in (False, True): | ||
| for offset_ in (0,3): | ||
| query = Query( | ||
| callback, | ||
| ["COLL_NAME"], | ||
| f"""COLL_NAME like '%/issue%' and COLL_PARENT_NAME = '{home}/{now}'""" | ||
| , case_sensitive=case_sensitive_ | ||
| , offset=offset_ | ||
| , limit=limit_ | ||
| ) | ||
|
|
||
| expected_total_rows = n_base_names * (1 if case_sensitive_ else 2) | ||
| expected_result_rows = min( | ||
| max(0, expected_total_rows - offset_), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this always result in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it would, if limit_ were None. if limit_ were sufficiently small integer, say 0, then would get 0 returned
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm referring to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, as far as I can figure, if no effect being exerted by an integer value of Is the formula as-given creating any ill effects in the table? Are the resulting I may be misunderstanding the question still; if so, maybe we can real-time chat outside this forum.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If someone were to pass
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe that case should be included in the test?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After discussion, @d-w-moore and I decided it's worth adding a case which exercises the |
||
| limit_ if limit_ is not None else expected_total_rows | ||
| ) | ||
|
trel marked this conversation as resolved.
|
||
|
|
||
| # Assert that offset=1 produced the correct number of row results. | ||
| if (got_result_rows:=len(list(query))) != expected_result_rows: | ||
|
d-w-moore marked this conversation as resolved.
Outdated
|
||
| raise Err(f'{expected_result_rows=}; {got_result_rows=}') | ||
|
|
||
| # Assert that total_rows found the correct number of total matching rows. | ||
| if (got_total_rows:=query.total_rows()) != expected_total_rows: | ||
|
d-w-moore marked this conversation as resolved.
Outdated
|
||
| raise Err(f'{expected_total_rows=}; {got_total_rows=}') | ||
| except: | ||
| return -1 | ||
| finally: | ||
| callback.msiRmColl(f'{home}/{now}','forceFlag=',-1) | ||
|
|
||
| INPUT null | ||
| OUTPUT ruleExecOut | ||
Uh oh!
There was an error while loading. Please reload this page.