Skip to content

Commit 2d93079

Browse files
committed
review changes 9/2/26
1 parent 21ed06b commit 2d93079

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

irods/test/rule_test.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#! /usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
import io
45
import json
56
import os
6-
import sys
77
import random
8-
import time
8+
import sys
99
import textwrap
10+
import time
1011
import unittest
12+
from io import open as io_open
13+
1114
from irods.column import Like
12-
from irods.models import DataObject, RuleExec
1315
from irods.exception import (
1416
FAIL_ACTION_ENCOUNTERED_ERR,
1517
RULE_ENGINE_ERROR,
1618
UnknowniRODSError,
1719
)
18-
import irods.test.helpers as helpers
20+
from irods.models import DataObject, RuleExec
1921
from irods.rule import Rule
20-
from io import open as io_open
21-
import io
22-
22+
from irods.test import helpers
2323

2424
RE_Plugins_installed_run_condition_args = (
2525
os.environ.get("PYTHON_RULE_ENGINE_INSTALLED", "*").lower()[:1] == "y",
@@ -439,29 +439,29 @@ def test_rulefile_in_file_like_object_2__336(self):
439439
self.assertRegex(lines[0], r"\[INTEGER\]\[5\]")
440440
self.assertRegex(lines[1], r"\[STRING\]\[A String\]")
441441

442-
443-
def test_rule_exec_context(self):
444-
if self.sess.server_version < (4, 3):
445-
self.skipTest("""RuleExec's "context" attribute not available before 4.3.0""")
446-
442+
def test_rule_exec_context_column_is_available_via_genquery1__issue_823(self):
447443
rule_id = -1
448444

449445
try:
450-
# Schedule a delayed rule.
451-
n_minutes = 15
452-
random_int = random.randint(1<<30, (1<<31)-1)
446+
# Schedule a delayed rule. The amount of delay does not matter as only its existence
447+
# in the catalog matters and we'll be cancelling it immediately after the test.
448+
delay_seconds = 15 * 60
449+
450+
# Generate a unique number for use in querying the rule.
451+
random_int = random.randint(1 << 30, (1 << 31) - 1) # noqa: S311
453452
r = Rule(
454453
self.sess,
455-
body=f'''delay("<PLUSET>{n_minutes}m</PLUSET>") {{ writeLine("serverLog","{random_int}") }}'''
454+
body=f'''delay("<PLUSET>{delay_seconds}</PLUSET>") {{ writeLine("serverLog","{random_int}") }}''',
456455
)
456+
# Schedule the delayed rule.
457457
r.execute()
458458

459459
# Get the delayed rule's ID, needed for cancellation.
460-
l = list(self.sess.query(RuleExec).filter(Like(RuleExec.name,f'%"{random_int}"%')))
461-
rule_id = l[0][RuleExec.id]
460+
results = list(self.sess.query(RuleExec).filter(Like(RuleExec.name, f'%"{random_int}"%')))
461+
rule_id = results[0][RuleExec.id]
462462

463463
# Assert context exists, and is JSON-parsable with a non-null-length result.
464-
rule_context = l[0][RuleExec.context]
464+
rule_context = results[0][RuleExec.context]
465465
self.assertGreater(len(json.loads(rule_context)), 0)
466466
finally:
467467
# Remove the delayed rule from the queue.

0 commit comments

Comments
 (0)