Skip to content

Commit 23dbccd

Browse files
Added Test folder
1 parent cd1658a commit 23dbccd

File tree

119 files changed

+14064
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+14064
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#** *****************************************************************************
2+
# *
3+
# * If not stated otherwise in this file or this component's LICENSE file the
4+
# * following copyright and licenses apply:
5+
# *
6+
# * Copyright 2024 RDK Management
7+
# *
8+
# * Licensed under the Apache License, Version 2.0 (the "License");
9+
# * you may not use this file except in compliance with the License.
10+
# * You may obtain a copy of the License at
11+
# *
12+
# *
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
# *
15+
# * Unless required by applicable law or agreed to in writing, software
16+
# * distributed under the License is distributed on an "AS IS" BASIS,
17+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# * See the License for the specific language governing permissions and
19+
# * limitations under the License.
20+
# *
21+
#* ******************************************************************************
22+
23+
# This file contains all the common functions required for test framework
24+
25+
import requests
26+
import json
27+
import time
28+
import Config
29+
from Utilities import Utils
30+
from FrontPanel import FrontPanelApis
31+
32+
33+
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#** *****************************************************************************
2+
# *
3+
# * If not stated otherwise in this file or this component's LICENSE file the
4+
# * following copyright and licenses apply:
5+
# *
6+
# * Copyright 2024 RDK Management
7+
# *
8+
# * Licensed under the Apache License, Version 2.0 (the "License");
9+
# * you may not use this file except in compliance with the License.
10+
# * You may obtain a copy of the License at
11+
# *
12+
# *
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
# *
15+
# * Unless required by applicable law or agreed to in writing, software
16+
# * distributed under the License is distributed on an "AS IS" BASIS,
17+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# * See the License for the specific language governing permissions and
19+
# * limitations under the License.
20+
# *
21+
#* ******************************************************************************
22+
23+
# Curl command for activating FrontPanel plugin
24+
activate_command = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc":"2.0","id":"3"
25+
,"method": "Controller.1.activate", "params":{"callsign":"org.rdk.FrontPanel"}}' http://127.0.0.1:55555/jsonrpc'''
26+
27+
# Curl command for deactivating FrontPanel plugin
28+
deactivate_command = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc":"2.0","id":"3"
29+
,"method": "Controller.1.deactivate", "params":{"callsign":"org.rdk.FrontPanel"}}' http://127.0.0.1:55555/jsonrpc'''
30+
31+
# Store the expected output response for activate & deactivate curl command
32+
expected_output_response = '{"jsonrpc":"2.0","id":3,"result":null}'
33+
34+
######################################################################################
35+
36+
# FrontPanel Methods :
37+
38+
get_brightness = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
39+
"method":"org.rdk.FrontPanel.getBrightness","params": {"index": "power_led"}}' http://127.0.0.1:55555/jsonrpc'''
40+
41+
get_brightness_invalid = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
42+
"method":"org.rdk.FrontPanel.getBrightness","params": {"index": "invalid_string"}}' http://127.0.0.1:55555/jsonrpc'''
43+
44+
get_clock_brightness = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0",
45+
"id": 42,"method":"org.rdk.FrontPanel.getClockBrightness"}' http://127.0.0.1:55555/jsonrpc'''
46+
47+
get_frontpanel_leds = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
48+
"method":"org.rdk.FrontPanel.getFrontPanelLights"}' http://127.0.0.1:55555/jsonrpc'''
49+
50+
get_preferences_invalid = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42,
51+
"method":"org.rdk.FrontPanel.getPreferences","params": {"vendorid": "0x4455"}}' http://127.0.0.1:55555/jsonrpc'''
52+
53+
get_preferences = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
54+
"method":"org.rdk.FrontPanel.getPreferences"}' http://127.0.0.1:55555/jsonrpc'''
55+
56+
is_24_hour_clock = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
57+
"method":"org.rdk.FrontPanel.is24HourClock"}' http://127.0.0.1:55555/jsonrpc'''
58+
59+
power_led_off = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42,
60+
"method":"org.rdk.FrontPanel.powerLedOff","params": {"index": power_led}}' http://127.0.0.1:55555/jsonrpc'''
61+
62+
power_led_on = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42,
63+
"method":"org.rdk.FrontPanel.powerLedOn","params": {"index": power_led}}' http://127.0.0.1:55555/jsonrpc'''
64+
65+
power_led_on_invalid = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id":42,
66+
"method":"org.rdk.FrontPanel.powerLedOn","params": {"index": invalid_led}}' http://127.0.0.1:55555/jsonrpc'''
67+
68+
set_24_hour_clock = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
69+
"method":"org.rdk.FrontPanel.set24HourClock", "params": {"is24Hour": false}}' http://127.0.0.1:55555/jsonrpc'''
70+
71+
set_24_hour_clock_invalid = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
72+
"method":"org.rdk.FrontPanel.set24HourClock", "params": {"is24Hour": 1234}}' http://127.0.0.1:55555/jsonrpc'''
73+
74+
75+
set_color_blink = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
76+
"method":"org.rdk.FrontPanel.setBlink", "params": {"blinkInfo": {
77+
"ledIndicator": "power_led",
78+
"iterations": 10,
79+
"pattern": [
80+
{
81+
"brightness": 50,
82+
"duration": 100,
83+
"color": "red",
84+
"red": 0,
85+
"green": 0,
86+
"blue": 0
87+
}
88+
]
89+
}
90+
}}' http://127.0.0.1:55555/jsonrpc'''
91+
92+
93+
set_color_blink_invalid = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
94+
"method":"org.rdk.FrontPanel.setBlink", "params": {"blinkInfo": {
95+
"ledIndicator": "power_led",
96+
"iterations": 10,
97+
"pattern": [
98+
{
99+
"brightness": 0X77,
100+
"duration": "invalid",
101+
"color": "black",
102+
"red": 9876,
103+
"green": "ABCD",
104+
"blue": 0
105+
}
106+
]
107+
}
108+
}}' http://127.0.0.1:55555/jsonrpc'''
109+
110+
set_brightness = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
111+
"method":"org.rdk.FrontPanel.setBrightness", "params": {"brightness": 50,"index": "power_led"}}' http://127.0.0.1:55555/jsonrpc'''
112+
113+
set_brightness_invalid = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
114+
"method":"org.rdk.FrontPanel.setBrightness", "params": {"brightness": "ABCD","index": "power_led"}}' http://127.0.0.1:55555/jsonrpc'''
115+
116+
set_clock_brightness = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
117+
"method":"org.rdk.FrontPanel.setClockBrightness", "params": {"brightness": 50}}' http://127.0.0.1:55555/jsonrpc'''
118+
set_clock_test_pattern = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
119+
"method":"org.rdk.FrontPanel.setClockTestPattern", "params": {"show": true,"timeInterval": 4}}' http://127.0.0.1:55555/jsonrpc'''
120+
121+
set_led = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
122+
"method":"org.rdk.FrontPanel.setLED", "params": {"ledIndicator": "power_led",
123+
"brightness": 50,
124+
"color": "red",
125+
"red": 0,
126+
"green": 0,
127+
"blue": 0
128+
}}' http://127.0.0.1:55555/jsonrpc'''
129+
130+
131+
set_led_invalid = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
132+
"method":"org.rdk.FrontPanel.setLED", "params": {"ledIndicator": "power_led",
133+
"brightness": 999999999,
134+
"color": "no_colour",
135+
"red": "invalid_string",
136+
"green": 0,
137+
"blue": 0
138+
}}' http://127.0.0.1:55555/jsonrpc'''
139+
set_preferences = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
140+
"method":"org.rdk.FrontPanel.setPreferences", "params": {"preferences": {}}}' http://127.0.0.1:55555/jsonrpc'''
141+
142+
set_preferences_invalid = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
143+
"method":"org.rdk.FrontPanel.setPreferences", "params": {"preferences": {1234}}}' http://127.0.0.1:55555/jsonrpc'''
144+
145+
#All the curl commands which has params dependency for hitting without parameters are given here
146+
set_brightness_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
147+
"method":"org.rdk.FrontPanel.setBrightness"}' http://127.0.0.1:55555/jsonrpc'''
148+
get_brightness_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
149+
"method":"org.rdk.FrontPanel.getBrightness"}' http://127.0.0.1:55555/jsonrpc'''
150+
set_powerLedOff_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
151+
"method":"org.rdk.FrontPanel.powerLedOff"}' http://127.0.0.1:55555/jsonrpc'''
152+
set_powerLedOn_withoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
153+
"method":"org.rdk.FrontPanel.powerLedOn"}' http://127.0.0.1:55555/jsonrpc'''
154+
set_24HourClockWithoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
155+
"method":"org.rdk.FrontPanel.set24HourClock"}' http://127.0.0.1:55555/jsonrpc'''
156+
set_blinkWithoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
157+
"method":"org.rdk.FrontPanel.setBlink"}' http://127.0.0.1:55555/jsonrpc'''
158+
set_clockBrightnesswithoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
159+
"method":"org.rdk.FrontPanel.setClockTestPattern"}' http://127.0.0.1:55555/jsonrpc'''
160+
set_ledWithoutParams = '''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
161+
"method":"org.rdk.FrontPanel.setLED"}' http://127.0.0.1:55555/jsonrpc'''
162+
set_preferencesWithoutParams ='''curl --silent --header "Content-Type: application/json" --request POST -d '{"jsonrpc": "2.0", "id": 42,
163+
"method":"org.rdk.FrontPanel.setPreferences"}' http://127.0.0.1:55555/jsonrpc'''
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#** *****************************************************************************
2+
# *
3+
# * If not stated otherwise in this file or this component's LICENSE file the
4+
# * following copyright and licenses apply:
5+
# *
6+
# * Copyright 2024 RDK Management
7+
# *
8+
# * Licensed under the Apache License, Version 2.0 (the "License");
9+
# * you may not use this file except in compliance with the License.
10+
# * You may obtain a copy of the License at
11+
# *
12+
# *
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
# *
15+
# * Unless required by applicable law or agreed to in writing, software
16+
# * distributed under the License is distributed on an "AS IS" BASIS,
17+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# * See the License for the specific language governing permissions and
19+
# * limitations under the License.
20+
# *
21+
#* ******************************************************************************
22+
23+
# Testcase ID : TCID001_DS_FrontPanel_getBrightness
24+
# Testcase Description : Get the brightness of the specified LED or FrontPanel
25+
26+
from Utilities import Utils, ReportGenerator
27+
from FrontPanel import FrontPanelApis
28+
29+
print("TC Description - Get the brightness of the specified LED or FrontPanel")
30+
print("---------------------------------------------------------------------------------------------------------------------------")
31+
# store the expected output response
32+
expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"brightness":100,"success":true}}'
33+
34+
# send the curl command and fetch the output json response
35+
curl_response = Utils.send_curl_command(FrontPanelApis.get_brightness)
36+
if curl_response:
37+
Utils.info_log("curl command to get brightness is sent from the test runner")
38+
else:
39+
Utils.error_log("curl command invoke failed for {}" .format(FrontPanelApis.get_brightness))
40+
41+
print("---------------------------------------------------------------------------------------------------------------------------")
42+
# compare both expected and received output responses
43+
if str(curl_response) == str(expected_output_response):
44+
status = 'Pass'
45+
message = 'Output response is matching with expected one. The brightness ' \
46+
'is obtained in output response'
47+
else:
48+
status = 'Fail'
49+
message = 'Output response is different from expected one'
50+
51+
# generate logs in terminal
52+
tc_id = 'TCID001_DS_FrontPanel_getBrightness'
53+
print("Testcase ID : " + tc_id)
54+
print("Testcase Output Response : " + curl_response)
55+
print("Testcase Status : " + status)
56+
print("Testcase Message : " + message)
57+
print("")
58+
59+
if status == 'Pass':
60+
ReportGenerator.passed_tc_list.append(tc_id)
61+
else:
62+
ReportGenerator.failed_tc_list.append(tc_id)
63+
# push the testcase execution details to report file
64+
ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#** *****************************************************************************
2+
# *
3+
# * If not stated otherwise in this file or this component's LICENSE file the
4+
# * following copyright and licenses apply:
5+
# *
6+
# * Copyright 2024 RDK Management
7+
# *
8+
# * Licensed under the Apache License, Version 2.0 (the "License");
9+
# * you may not use this file except in compliance with the License.
10+
# * You may obtain a copy of the License at
11+
# *
12+
# *
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
# *
15+
# * Unless required by applicable law or agreed to in writing, software
16+
# * distributed under the License is distributed on an "AS IS" BASIS,
17+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# * See the License for the specific language governing permissions and
19+
# * limitations under the License.
20+
# *
21+
#* ******************************************************************************
22+
23+
# Testcase ID : TCID002_DS_FrontPanel_getPreferences
24+
# Testcase Description : Returns the preferences that are saved in the /opt/fp_service_preferences.json file.
25+
26+
from Utilities import Utils, ReportGenerator
27+
from FrontPanel import FrontPanelApis
28+
29+
print("TC Description - Returns the preferences that are saved in the /opt/fp_service_preferences.json file.")
30+
print("---------------------------------------------------------------------------------------------------------------------------")
31+
# store the expected output response
32+
expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"preferences":{},"success":true}}'
33+
34+
# send the curl command and fetch the output json response
35+
curl_response = Utils.send_curl_command(FrontPanelApis.get_preferences)
36+
if curl_response:
37+
Utils.info_log("curl command to get preferences is sent from the test runner")
38+
else:
39+
Utils.error_log("curl command invoke failed {}" .format(FrontPanelApis.get_preferences))
40+
41+
print("---------------------------------------------------------------------------------------------------------------------------")
42+
# compare both expected and received output responses
43+
if str(curl_response) == str(expected_output_response):
44+
status = 'Pass'
45+
message = 'Output response is matching with expected one. The preferences set in opt/fp_service_preferences.json ' \
46+
'is obtained in output response'
47+
else:
48+
status = 'Fail'
49+
message = 'Output response is different from expected one'
50+
51+
# generate logs in terminal
52+
tc_id = 'TCID002_DS_FrontPanel_getPreferences'
53+
print("Testcase ID : " + tc_id)
54+
print("Testcase Output Response : " + curl_response)
55+
print("Testcase Status : " + status)
56+
print("Testcase Message : " + message)
57+
print("")
58+
59+
if status == 'Pass':
60+
ReportGenerator.passed_tc_list.append(tc_id)
61+
else:
62+
ReportGenerator.failed_tc_list.append(tc_id)
63+
# push the testcase execution details to report file
64+
ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#** *****************************************************************************
2+
# *
3+
# * If not stated otherwise in this file or this component's LICENSE file the
4+
# * following copyright and licenses apply:
5+
# *
6+
# * Copyright 2024 RDK Management
7+
# *
8+
# * Licensed under the Apache License, Version 2.0 (the "License");
9+
# * you may not use this file except in compliance with the License.
10+
# * You may obtain a copy of the License at
11+
# *
12+
# *
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
# *
15+
# * Unless required by applicable law or agreed to in writing, software
16+
# * distributed under the License is distributed on an "AS IS" BASIS,
17+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# * See the License for the specific language governing permissions and
19+
# * limitations under the License.
20+
# *
21+
#* ******************************************************************************
22+
23+
# Testcase ID : TCID003_is24HourClock
24+
# Testcase Description : Gets the currently set clock mode (12 or 24 hour).
25+
26+
from Utilities import Utils, ReportGenerator
27+
from FrontPanel import FrontPanelApis
28+
29+
print("TC Description - Gets the currently set clock mode (12 or 24 hour)..")
30+
print("---------------------------------------------------------------------------------------------------------------------------")
31+
# store the expected output response
32+
expected_output_response = '{"jsonrpc":"2.0","id":42,"result":{"is24Hour":false,"success":true}}'
33+
34+
# send the curl command and fetch the output json response
35+
curl_response = Utils.send_curl_command(FrontPanelApis.is_24_hour_clock)
36+
if curl_response:
37+
Utils.info_log("curl command is_24_hour_clock is sent from the test runner")
38+
else:
39+
Utils.error_log("curl command invoke failed {}" .format(FrontPanelApis.is_24_hour_clock))
40+
41+
print("---------------------------------------------------------------------------------------------------------------------------")
42+
# compare both expected and received output responses
43+
if str(curl_response) == str(expected_output_response):
44+
status = 'Pass'
45+
message = 'Output response is matching with expected one. is clock enabled or disabled ' \
46+
'is obtained in output response'
47+
else:
48+
status = 'Fail'
49+
message = 'Output response is different from expected one'
50+
51+
# generate logs in terminal
52+
tc_id = 'TCID003_is24HourClock'
53+
print("Testcase ID : " + tc_id)
54+
print("Testcase Output Response : " + curl_response)
55+
print("Testcase Status : " + status)
56+
print("Testcase Message : " + message)
57+
print("")
58+
59+
if status == 'Pass':
60+
ReportGenerator.passed_tc_list.append(tc_id)
61+
else:
62+
ReportGenerator.failed_tc_list.append(tc_id)
63+
# push the testcase execution details to report file
64+
ReportGenerator.append_test_results_to_csv(tc_id, curl_response, status, message)

0 commit comments

Comments
 (0)