Skip to content

Commit

Permalink
feat: Implement tests for query readings by name and time range
Browse files Browse the repository at this point in the history
Signed-off-by: Cherry Wang <[email protected]>
  • Loading branch information
cherrycl committed Jul 14, 2021
1 parent 30bcc3a commit 5558a9d
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
17 changes: 17 additions & 0 deletions TAF/testCaseModules/keywords/core-data/coreDataAPI.robot
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ Query readings by start/end time
Set Response to Test Variables ${resp}
Run Keyword If ${response}!=200 fail ${response}!=200: ${content}

Query readings by resource and start/end time
[Arguments] ${resource} ${start_time} ${end_time}
Create Session Core Data url=${coreDataUrl} disable_warnings=true
${headers}= Create Dictionary Authorization=Bearer ${jwt_token}
${resp}= GET On Session Core Data
... ${coreDataReadingUri}/resourceName/${resource}/start/${start_time}/end/${end_time}
... headers=${headers} expected_status=any
Set Response to Test Variables ${resp}

Query readings by resource ${resource} and start ${start_time}/end ${end_time} with ${parameter}=${value}
Create Session Core Data url=${coreDataUrl} disable_warnings=true
${headers}= Create Dictionary Authorization=Bearer ${jwt_token}
${resp}= GET On Session Core Data
... ${coreDataReadingUri}/resourceName/${resource}/start/${start_time}/end/${end_time}
... params=${parameter}=${value} headers=${headers} expected_status=any
Set Response to Test Variables ${resp}

Query all readings count
Create Session Core Data url=${coreDataUrl} disable_warnings=true
${headers}= Create Dictionary Authorization=Bearer ${jwt_token}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,34 @@ ErrReadingGET008 - Query readings by start/end time fails (Start>End)
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms

ErrReadingGET09 - Query readings by rsource and start/end time fails (Invalid Start)
${end_time}= Get current nanoseconds epoch time
When Query Readings By Resource And Start/End Time Test_Resource InvalidStart ${end_time}
Then Should Return Status Code "400"
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms

ErrReadingGET010 - Query readings by rsource and start/end time fails (Invalid End)
${start_time}= Get current nanoseconds epoch time
When Query Readings By Resource And Start/End Time Test_Resource ${start_time} InvalidEnd
Then Should Return Status Code "400"
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms

ErrReadingGET011 - Query readings by rsource and start/end time fails (Start>End)
${start_time}= Get current nanoseconds epoch time
${end_time}= Get current nanoseconds epoch time
When Query Readings By Resource And Start/End Time Test_Resource ${end_time} ${start_time}
Then Should Return Status Code "400"
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms

ErrReadingGET012 - Query readings by rsource and start/end time with invalid offset range
${start_time}= Get current nanoseconds epoch time
${end_time}= Evaluate ${start_time}+100000000
Given Create Multiple Events
When Query readings by resource Simple-Reading and start ${start_time}/end ${end_time} with offset=10
Then Should Return Status Code "416"
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms
[Teardown] Delete All Events By Age
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ReadingGET006 - Query readings by start/end time
Given Create Multiple Events Twice To Get Start/End Time
When Query Readings By Start/End Time ${start_time} ${end_time}
Then Should Return Status Code "200"
And Readings Should Be Created Between ${start_time} And ${end_time}
And Total 9 Readings Should Be Created Between ${start_time} And ${end_time}
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms
[Teardown] Delete All Events By Age
Expand All @@ -84,10 +84,29 @@ ReadingGET008 - Query a count of all of readings with specified device by device
And Response Time Should Be Less Than "${default_response_time_threshold}"ms
[Teardown] Delete All Events By Age

ReadingGET009 - Query readings by resource name and time range
${resource_name} Set Variable Simple-Reading
Given Create Multiple Events Twice To Get Start/End Time
When Query Readings By Resource And Start/End Time ${resource_name} ${start_time} ${end_time}
Then Should Return Status Code "200"
And All 6 Readings Resource Should be ${resource_name}
And Total 6 Readings Should Be Created Between ${start_time} And ${end_time}
And Should Return Content-Type "application/json"
And Response Time Should Be Less Than "${default_response_time_threshold}"ms
[Teardown] Delete All Events By Age

*** Keywords ***
Readings Should Be Created Between ${start} And ${end}
${count}= Get Length ${content}[readings]
Should Be Equal As Integers ${count} 9
FOR ${index} IN RANGE 0 9
Should Be True ${end} >= ${content}[readings][${index}][origin] >=${start}
END
Total ${number} Readings Should Be Created Between ${start} And ${end}
${count}= Get Length ${content}[readings]
Should Be Equal As Integers ${count} ${number}
FOR ${index} IN RANGE 0 ${number}
Should Be True ${end} >= ${content}[readings][${index}][origin] >=${start}
END

All ${number} Readings Resource Should be ${resource_name}
${count}= Get Length ${content}[readings]
Should Be Equal As Integers ${count} ${number}
FOR ${index} IN RANGE 0 ${number}
Should Be Equal As Strings ${resource_name} ${content}[readings][${index}][resourceName]
END

0 comments on commit 5558a9d

Please sign in to comment.