Skip to content

Commit

Permalink
squash. cover GenQuery1 too.
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Jul 23, 2024
1 parent 1adbb2d commit be9e0ef
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions scripts/irods/test/test_prep_genquery_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,25 +1045,27 @@ def test_genquery_iterator_allows_close_member_function_to_be_called_multiple_ti
attr_name = 'test_genquery_iterator_allows_close_member_function_to_be_called_multiple_times__issue_7909'
attr_value = 'success'

# The following rule calls the close() member function of the Query class multiple
# times and then attaches an AVU to the session collection. The AVU is used to
# indicate success.
core.add_rule(dedent(f'''
def pep_api_touch_pre(rule_args, callback, rei):
from genquery import Query, Parser
query = Query(callback, 'COLL_NAME', "COLL_NAME = '{self.admin.session_collection}'", parser=Parser.GENQUERY2)
for _ in query:
pass
query.close()
query.close()
query.close()
callback.msiModAVUMetadata('-C', '{self.admin.session_collection}', 'add', '{attr_name}', '{attr_value}', '')
'''))

# Trigger the PEP.
self.admin.assert_icommand(['itouch', 'issue_7909'], 'STDERR')

# Show the AVU is now attached to the session collection with the expected attribute value.
self.admin.assert_icommand(['imeta', 'ls', '-C', self.admin.session_collection], 'STDOUT', [
f'attribute: {attr_name}\nvalue: {attr_value}\n'
])
for parser in ['GENQUERY1', 'GENQUERY2']:
with self.subTest(f'Using [{parser}]'):
# The following rule calls the close() member function of the Query class multiple
# times and then attaches an AVU to the session collection. The AVU is used to
# indicate success.
core.add_rule(dedent(f'''
def pep_api_touch_pre(rule_args, callback, rei):
from genquery import Query, Parser
query = Query(callback, 'COLL_NAME', "COLL_NAME = '{self.admin.session_collection}'", parser=Parser.{parser})
for _ in query:
pass
query.close()
query.close()
query.close()
callback.msiModAVUMetadata('-C', '{self.admin.session_collection}', 'add', '{attr_name}', '{parser}={attr_value}', '')
'''))

# Trigger the PEP.
self.admin.assert_icommand(['itouch', 'issue_7909'], 'STDERR')

# Show the AVU is now attached to the session collection with the expected attribute value.
self.admin.assert_icommand(['imeta', 'ls', '-C', self.admin.session_collection], 'STDOUT', [
f'attribute: {attr_name}\nvalue: {parser}={attr_value}\n'
])

0 comments on commit be9e0ef

Please sign in to comment.