Skip to content

Commit

Permalink
Merge pull request #938 from cherrycl/issue-933
Browse files Browse the repository at this point in the history
feat: Add tests for getting device profile basic info API
  • Loading branch information
jumpingliu authored Feb 21, 2025
2 parents 5d08df0 + 82bea71 commit 90600d2
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 16 deletions.
22 changes: 22 additions & 0 deletions TAF/testCaseModules/keywords/core-metadata/coreMetadataAPI.robot
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ Query all device profiles having manufacturer ${manufacturer} and model ${model}
Set Response to Test Variables ${resp}
Run keyword if ${response}!=200 fail

Query all device profiles basic info
Create Session Core Metadata url=${coreMetadataUrl} disable_warnings=true
${headers}= Create Dictionary Authorization=Bearer ${jwt_token}
${resp}= GET On Session Core Metadata ${deviceProfileUri}/basicinfo/all headers=${headers}
... expected_status=any
Set Response to Test Variables ${resp}

Query all device profiles basic info with ${parameter}=${value}
Create Session Core Metadata url=${coreMetadataUrl} disable_warnings=true
${headers}= Create Dictionary Authorization=Bearer ${jwt_token}
${resp}= GET On Session Core Metadata ${deviceProfileUri}/basicinfo/all params=${parameter}=${value}
... headers=${headers} expected_status=any
Set Response to Test Variables ${resp}
Run keyword if ${response}!=200 fail

Query device profile by name
[Arguments] ${device_profile_name}
Create Session Core Metadata url=${coreMetadataUrl} disable_warnings=true
Expand Down Expand Up @@ -196,6 +211,13 @@ Delete deviceCommand by Name ${command_name} in ${profile}
run keyword if ${resp.status_code}!=200 log to console ${resp.content}
Set Response to Test Variables ${resp}

Profiles Should Be Linked To Specified ${property}: ${value}
${profiles}= Set Variable ${content}[profiles]
${property}= Convert To Lower Case ${property}
FOR ${item} IN @{profiles}
Run keyword if "${property}" == "labels" List Should Contain Value ${item}[${property}] ${value}
... ELSE Should Be Equal As Strings ${item}[${property}] ${value}
END

# Device
Create device with ${entity}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
*** Settings ***
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot
Resource TAF/testCaseModules/keywords/core-metadata/coreMetadataAPI.robot
Suite Setup Run Keywords Setup Suite
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Get Token
Suite Teardown Run Teardown Keywords

*** Variables ***
${SUITE} Core Metadata Device Profile GET Positive Test Cases
${LOG_FILE_PATH} ${WORK_DIR}/TAF/testArtifacts/logs/core-metadata-deviceprofile-get-positive.log

*** Test Cases ***
ProfileBasicGET001 - Query all device profiles basic info
Given Generate Multiple Device Profiles Sample
And Create Device Profile ${deviceProfile}
When Query All Device Profiles Basic Info
Then Should Return Status Code "200" And profiles
And totalCount Is Greater Than Zero And ${content}[profiles] Count Should Match totalCount
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms
And deviceResources and deviceCommands Both Should Not Return
[Teardown] Delete Multiple Device Profiles By Names Test-Profile-1 Test-Profile-2 Test-Profile-3

ProfileBasicGET002 - Query all device profiles basic info by offset
Given Generate Multiple Device Profiles Sample
And Create Device Profile ${deviceProfile}
And Set Test Variable ${offset} 2
When Query All Device Profiles Basic Info With offset=${offset}
Then Should Return Status Code "200" And profiles
And totalCount Is Greater Than Zero And ${content}[profiles] Count Should Match totalCount-offset
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms
And deviceResources and deviceCommands Both Should Not Return
[Teardown] Delete Multiple Device Profiles By Names Test-Profile-1 Test-Profile-2 Test-Profile-3

ProfileBasicGET003 - Query all device profiles basic info by limit
Given Generate Multiple Device Profiles Sample
And Create Device Profile ${deviceProfile}
And Set Test Variable ${limit} 2
When Query All Device Profiles Basic Info With limit=${limit}
Then Should Return Status Code "200" And profiles
And totalCount Is Greater Than Zero And ${content}[profiles] Count Should Match limit
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms
And deviceResources and deviceCommands Both Should Not Return
[Teardown] Delete Multiple Device Profiles By Names Test-Profile-1 Test-Profile-2 Test-Profile-3

ProfileBasicGET004 - Query all device profiles basic info by labels
Given Generate Multiple Device Profiles Sample
And Create Device Profile ${deviceProfile}
When Query All Device Profiles Basic Info With labels=bacnet
Then Should Return Status Code "200" And profiles
And totalCount Is Greater Than Zero And ${content}[profiles] Count Should Match totalCount
And Profiles Should Be Linked To Specified Labels: bacnet
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms
And deviceResources and deviceCommands Both Should Not Return
[Teardown] Delete Multiple Device Profiles By Names Test-Profile-1 Test-Profile-2 Test-Profile-3

*** Keywords ***
deviceResources and deviceCommands Both Should Not Return
FOR ${INDEX} IN RANGE len(${content}[profiles])
Dictionary Should Not Contain Key ${content}[profiles][${INDEX}] deviceResources
Dictionary Should Not Contain Key ${content}[profiles][${INDEX}] deviceCommands
END
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,3 @@ Delete Multiple Device Profiles Sample With Different Device Info
Delete Multiple Device Profiles By Names Test-Profile-1 Test-Profile-2 Test-Profile-3
... New-Profile-1 New-Profile-2 New-Profile-3

Profiles Should Be Linked To Specified ${property}: ${value}
# property: model, manufacturer
${profiles}= Set Variable ${content}[profiles]
${property}= Convert To Lower Case ${property}
FOR ${item} IN @{profiles}
Should Be Equal As Strings ${item}[${property}] ${value}
END

Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ ProfileGET008 - Query device profiles by manufacturer and limit
[Teardown] Delete Multiple Device Profiles By Names Test-Profile-1 Test-Profile-2 Test-Profile-3

*** Keywords ***
Profiles Should Be Linked To Specified ${property}: ${value}
${profiles}= Set Variable ${content}[profiles]
${property}= Convert To Lower Case ${property}
FOR ${item} IN @{profiles}
Run keyword if "${property}" == "labels" List Should Contain Value ${item}[${property}] ${value}
... ELSE IF "${property}" == "manufacturer" Should Be Equal As Strings ${item}[${property}] ${value}
END

Create Multiple Device Profiles Sample With Different Manufacturers
Generate Multiple Device Profiles Sample
Set To Dictionary ${deviceProfile}[0][profile] manufacturer=Not_Honeywell
Expand Down

0 comments on commit 90600d2

Please sign in to comment.