Skip to content

Commit c3d5d93

Browse files
ci: lint changes
1 parent 2964d34 commit c3d5d93

File tree

6 files changed

+136
-46
lines changed

6 files changed

+136
-46
lines changed

pytest_splunk_addon_ui_smartx/components/controls/checkbox.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ def __init__(self, browser, container, searchable=True):
3131
if container.by == "xpath":
3232
self.elements.update(
3333
{
34-
"internal_container": Selector(by=By.XPATH,
35-
select=container.select + '//div[@data-test="switch"]'
34+
"internal_container": Selector(
35+
by=By.XPATH,
36+
select=container.select + '//div[@data-test="switch"]',
37+
),
38+
"checkbox": Selector(
39+
by=By.XPATH,
40+
select=container.select + '//div[@data-test="switch"]',
3641
),
37-
"checkbox": Selector(by=By.XPATH,select=container.select + '//div[@data-test="switch"]'),
38-
"checkbox_btn": Selector(by=By.XPATH,
39-
select=container.select + '//button[@role="checkbox"]'
42+
"checkbox_btn": Selector(
43+
by=By.XPATH,
44+
select=container.select + '//button[@role="checkbox"]',
4045
),
4146
}
4247
)
@@ -46,9 +51,12 @@ def __init__(self, browser, container, searchable=True):
4651
"internal_container": Selector(
4752
select=container.select + ' [data-test="switch"]'
4853
),
49-
"checkbox": Selector(select=container.select + ' [data-test="switch"]'),
54+
"checkbox": Selector(
55+
select=container.select + ' [data-test="switch"]'
56+
),
5057
"checkbox_btn": Selector(
51-
select=container.select + ' [data-test="button"][role="checkbox"]'
58+
select=container.select
59+
+ ' [data-test="button"][role="checkbox"]'
5260
),
5361
}
5462
)

pytest_splunk_addon_ui_smartx/components/controls/checkboxgroup.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .checkbox import Checkbox
2222
from .textbox import TextBox
2323

24+
2425
class CheckboxGroup(BaseControl):
2526
"""
2627
Entity_Component : CheckboxGroup
@@ -49,15 +50,23 @@ def is_group_expanded(self, group_name: str) -> bool:
4950
Returns:
5051
bool: True if the group is expanded, False otherwise.
5152
"""
52-
self.elements.update({
53-
f"{group_name}_button": Selector(
54-
by=By.XPATH,
55-
select=self.elements.get("container").select + f'//span[text()="{group_name}"]/ancestor::button'
56-
)
57-
})
58-
return getattr(self, f"{group_name}_button").get_attribute("aria-expanded") == "true"
59-
60-
def select_checkbox_and_set_value(self, checkbox_name: str, checkbox_value: str) -> None:
53+
self.elements.update(
54+
{
55+
f"{group_name}_button": Selector(
56+
by=By.XPATH,
57+
select=self.elements.get("container").select
58+
+ f'//span[text()="{group_name}"]/ancestor::button',
59+
)
60+
}
61+
)
62+
return (
63+
getattr(self, f"{group_name}_button").get_attribute("aria-expanded")
64+
== "true"
65+
)
66+
67+
def select_checkbox_and_set_value(
68+
self, checkbox_name: str, checkbox_value: str
69+
) -> None:
6170
"""
6271
Selects a checkbox and sets a value for the checkbox.
6372
@@ -69,15 +78,17 @@ def select_checkbox_and_set_value(self, checkbox_name: str, checkbox_value: str)
6978
self.browser,
7079
Selector(
7180
by=By.XPATH,
72-
select=self.elements.get("container").select + f"//div[@data-test-field='{checkbox_name}']/parent::div"
73-
)
81+
select=self.elements.get("container").select
82+
+ f"//div[@data-test-field='{checkbox_name}']/parent::div",
83+
),
7484
).check()
7585
TextBox(
7686
self.browser,
7787
Selector(
7888
by=By.XPATH,
79-
select=self.elements.get("container").select + f"//div[@data-test-field='{checkbox_name}' and @data-test='number']"
80-
)
89+
select=self.elements.get("container").select
90+
+ f"//div[@data-test-field='{checkbox_name}' and @data-test='number']",
91+
),
8192
).set_value(checkbox_value)
8293

8394
def select(self, group_name: str, checkbox_name: str, checkbox_value: str) -> None:
@@ -90,7 +101,9 @@ def select(self, group_name: str, checkbox_name: str, checkbox_value: str) -> No
90101
checkbox_value (str): The value to set for the checkbox.
91102
"""
92103
self.expand_group(group_name)
93-
self.select_checkbox_and_set_value(checkbox_name=checkbox_name, checkbox_value=checkbox_value)
104+
self.select_checkbox_and_set_value(
105+
checkbox_name=checkbox_name, checkbox_value=checkbox_value
106+
)
94107

95108
def deselect(self, group_name: str, checkbox_name: str) -> None:
96109
"""
@@ -105,8 +118,9 @@ def deselect(self, group_name: str, checkbox_name: str) -> None:
105118
self.browser,
106119
Selector(
107120
by=By.XPATH,
108-
select=self.elements.get("container").select + f"//div[@data-test-field='{checkbox_name}']/parent::div"
109-
)
121+
select=self.elements.get("container").select
122+
+ f"//div[@data-test-field='{checkbox_name}']/parent::div",
123+
),
110124
).uncheck()
111125

112126
def get_checkbox_value(self, group_name: str, checkbox_name: str) -> str:
@@ -125,8 +139,9 @@ def get_checkbox_value(self, group_name: str, checkbox_name: str) -> str:
125139
self.browser,
126140
Selector(
127141
by=By.XPATH,
128-
select=self.elements.get("container").select + f"//div[@data-test-field='{checkbox_name}' and @data-test='number']"
129-
)
142+
select=self.elements.get("container").select
143+
+ f"//div[@data-test-field='{checkbox_name}' and @data-test='number']",
144+
),
130145
).get_value()
131146

132147
def expand_group(self, group_name: str) -> None:

pytest_splunk_addon_ui_smartx/components/controls/textbox.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ def __init__(self, browser, container, encrypted=False):
3939
self.container = container
4040
self.browser = browser
4141
if container.by == "xpath":
42-
self.elements.update({"input": Selector(by=By.XPATH, select=container.select + "//input")})
42+
self.elements.update(
43+
{"input": Selector(by=By.XPATH, select=container.select + "//input")}
44+
)
4345
else:
44-
self.elements.update({"input": Selector(select=container.select + " input")})
46+
self.elements.update(
47+
{"input": Selector(select=container.select + " input")}
48+
)
4549

4650
def set_value(self, value):
4751
"""

tests/testdata/Splunk_TA_UCCExample/globalConfig.json

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,41 @@
295295
"title": "Proxy"
296296
},
297297
{
298-
"type": "loggingTab"
298+
"name": "logging",
299+
"entity": [
300+
{
301+
"type": "singleSelect",
302+
"label": "Log level",
303+
"options": {
304+
"disableSearch": true,
305+
"autoCompleteFields": [
306+
{
307+
"value": "DEBUG",
308+
"label": "DEBUG"
309+
},
310+
{
311+
"value": "INFO",
312+
"label": "INFO"
313+
},
314+
{
315+
"value": "WARNING",
316+
"label": "WARNING"
317+
},
318+
{
319+
"value": "ERROR",
320+
"label": "ERROR"
321+
},
322+
{
323+
"value": "CRITICAL",
324+
"label": "CRITICAL"
325+
}
326+
]
327+
},
328+
"defaultValue": "INFO",
329+
"field": "loglevel"
330+
}
331+
],
332+
"title": "Logging"
299333
},
300334
{
301335
"name": "custom_tab",
@@ -547,9 +581,16 @@
547581
}
548582
},
549583
{
550-
"type": "interval",
551-
"field": "interval",
584+
"type": "text",
552585
"label": "Interval",
586+
"validators": [
587+
{
588+
"type": "regex",
589+
"errorMsg": "Interval must be an integer.",
590+
"pattern": "^\\-[1-9]\\d*$|^\\d*$"
591+
}
592+
],
593+
"field": "interval",
553594
"help": "Time interval of the data input, in seconds.",
554595
"required": true
555596
},
@@ -708,9 +749,16 @@
708749
"required": true
709750
},
710751
{
711-
"type": "interval",
712-
"field": "interval",
752+
"type": "text",
713753
"label": "Interval",
754+
"validators": [
755+
{
756+
"type": "regex",
757+
"errorMsg": "Interval must be an integer.",
758+
"pattern": "^\\-[1-9]\\d*$|^\\d*$"
759+
}
760+
],
761+
"field": "interval",
714762
"help": "Time interval of the data input, in seconds .",
715763
"required": true
716764
},
@@ -998,9 +1046,16 @@
9981046
"required": true
9991047
},
10001048
{
1001-
"type": "interval",
1002-
"field": "interval",
1049+
"type": "text",
10031050
"label": "Interval",
1051+
"validators": [
1052+
{
1053+
"type": "regex",
1054+
"errorMsg": "Interval must be an integer.",
1055+
"pattern": "^\\-[1-9]\\d*$|^\\d*$"
1056+
}
1057+
],
1058+
"field": "interval",
10041059
"help": "Time interval of the data input, in seconds.",
10051060
"required": true
10061061
}
@@ -1031,9 +1086,16 @@
10311086
"required": true
10321087
},
10331088
{
1034-
"type": "interval",
1035-
"field": "interval",
1089+
"type": "text",
10361090
"label": "Interval",
1091+
"validators": [
1092+
{
1093+
"type": "regex",
1094+
"errorMsg": "Interval must be an integer.",
1095+
"pattern": "^\\-[1-9]\\d*$|^\\d*$"
1096+
}
1097+
],
1098+
"field": "interval",
10371099
"help": "Time interval of the data input, in seconds.",
10381100
"required": true
10391101
}
@@ -1144,7 +1206,7 @@
11441206
"name": "test_alert",
11451207
"label": "Test Alert",
11461208
"description": "Description for test Alert Action",
1147-
"adaptiveResponse": {
1209+
"activeResponse": {
11481210
"task": [
11491211
"Create",
11501212
"Update"
@@ -1167,8 +1229,7 @@
11671229
}
11681230
],
11691231
"drilldownUri": "search?q=search%20index%3D\"_internal\"&earliest=0&latest=",
1170-
"sourcetype": "test:incident",
1171-
"supportsCloud": true
1232+
"sourcetype": "test:incident"
11721233
},
11731234
"entity": [
11741235
{
@@ -1245,7 +1306,6 @@
12451306
"restRoot": "splunk_ta_uccexample",
12461307
"version": "0.0.1",
12471308
"displayName": "Splunk UCC test Add-on",
1248-
"schemaVersion": "0.0.8",
1249-
"_uccVersion": "5.48.0"
1309+
"schemaVersion": "0.0.3"
12501310
}
1251-
}
1311+
}

tests/ui/Example_UccLib/input_page.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from pytest_splunk_addon_ui_smartx.components.controls.checkboxgroup import CheckboxGroup
1+
from pytest_splunk_addon_ui_smartx.components.controls.checkboxgroup import (
2+
CheckboxGroup,
3+
)
24
from pytest_splunk_addon_ui_smartx.pages.page import Page
35
from pytest_splunk_addon_ui_smartx.components.base_component import Selector
46
from pytest_splunk_addon_ui_smartx.components.base_component import BaseComponent
@@ -18,6 +20,7 @@
1820

1921
from selenium.webdriver.common.by import By
2022

23+
2124
class ExampleInputOne(Entity):
2225
"""
2326
Form to configure a new Input

tests/ui/test_splunk_ta_example_addon_input_2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def add_input_two(ucc_smartx_rest_helper):
109109
"index": "main",
110110
"start_date": "2016-10-10T12:10:15.000z",
111111
"disabled": 0,
112-
"apis": "ec2_volumes/3600,ec2_instances/100,classic_load_balancers/100"
112+
"apis": "ec2_volumes/3600,ec2_instances/100,classic_load_balancers/100",
113113
}
114114
yield input_page.backend_conf.post_stanza(url, kwargs)
115115

@@ -546,7 +546,7 @@ def test_example_input_two_add_backend_validation(
546546
"input_two_multiple_select": "one,two",
547547
"start_date": "2020-12-11T20:00:32.000z",
548548
"disabled": 0,
549-
"apis": "ec2_volumes/3600,ec2_instances/100,classic_load_balancers/100"
549+
"apis": "ec2_volumes/3600,ec2_instances/100,classic_load_balancers/100",
550550
}
551551
backend_stanza = input_page.backend_conf.get_stanza(
552552
"example_input_two://dummy_input"
@@ -628,7 +628,7 @@ def test_example_input_two_edit_backend_validation(
628628
"input_two_multiple_select": "two",
629629
"start_date": "2020-20-20T20:20:20.000z",
630630
"disabled": 0,
631-
"apis": "ec2_volumes/3600,vpcs/1000"
631+
"apis": "ec2_volumes/3600,vpcs/1000",
632632
}
633633
backend_stanza = input_page.backend_conf.get_stanza(
634634
"example_input_two://dummy_input_two"

0 commit comments

Comments
 (0)