Skip to content

Commit

Permalink
Collections: Enhancements, fixes and clanup.
Browse files Browse the repository at this point in the history
- Enhance recently added `Normalizer` to handle also `ignore_order` and
  `ignore_keys`. This way they are supported recursively. Fixes #4952.

- Various fixes for case-insensitive dictionary comparisons. Most
  importantly, expected keys and values are now normalized according
  to possible `keys/values` configuration. Fixes #4343.

- Cleanup and refactor code.

- Enhance documentation.

- Split dictionary related tests to multiple suites. Also cleanup
  tests releated to comparisons.
  • Loading branch information
pekkaklarck committed Nov 22, 2023
1 parent 03553b6 commit 6aec6db
Show file tree
Hide file tree
Showing 9 changed files with 820 additions and 642 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/collections/dictionaries_should_be_equal.robot
Resource atest_resource.robot

*** Test Cases ***
Comparison with itself
Check Test Case ${TESTNAME}

Keys in different order
Check Test Case ${TESTNAME}

Different dictionary types
Check Test Case ${TESTNAME}

First dictionary missing keys
Check Test Case ${TESTNAME}

Second dictionary missing keys
Check Test Case ${TESTNAME}

Both dictionaries missing keys
Check Test Case ${TESTNAME}

Missing keys and custom error message
Check Test Case ${TESTNAME}

Missing keys and custom error message with values
Check Test Case ${TESTNAME}

Different values
Check Test Case ${TESTNAME}

Different values and custom error message
Check Test Case ${TESTNAME}

Different values and custom error message with values
Check Test Case ${TESTNAME}

`ignore_keys`
Check Test Case ${TESTNAME}

`ignore_keys` with non-string keys
Check Test Case ${TESTNAME}

`ignore_keys` recursive
Check Test Case ${TESTNAME}

`ignore_keys` with missing keys
Check Test Case ${TESTNAME}

`ignore_keys` with wrong values
Check Test Case ${TESTNAME}

`ignore_keys` as string must be valid expression
Check Test Case ${TESTNAME}

`ignore_keys` must be list
Check Test Case ${TESTNAME}

`ignore_case`
Check Test Case ${TESTNAME}

`ignore_case` with ´ignore_keys`
Check Test Case ${TESTNAME}

`ignore_case` when normalized keys have conflict
Check Test Case ${TESTNAME}
159 changes: 0 additions & 159 deletions atest/robot/standard_libraries/collections/dictionary.robot
Original file line number Diff line number Diff line change
Expand Up @@ -65,120 +65,6 @@ Get From Dictionary With Invalid Key
Get From Dictionary With Default
Check Test Case ${TEST NAME}

Dictionary Should Contain Key
Check Test Case ${TEST NAME}

Dictionary Should Contain Key With Missing Key
Check Test Case ${TEST NAME} 1
Check Test Case ${TEST NAME} 2

Dictionary Should Contain Item
Check Test Case ${TEST NAME}

Dictionary Should Contain Item With Missing Key
Check Test Case ${TEST NAME}

Dictionary Should Contain Item With Wrong Value
Check Test Case ${TEST NAME}

Dictionary Should Contain Item With Value Looking Same But With Different Type
Check Test Case ${TEST NAME}

Dictionary Should Contain Item With Custom Message
Check Test Case ${TEST NAME}

Dictionary Should Not Contain Key
Check Test Case ${TEST NAME}

Dictionary Should Not Contain Key With Existing Key
Check Test Case ${TEST NAME}

Dictionary Should (Not) Contain Key Does Not Require `has_key`
Check Test Case ${TEST NAME}

Dictionary Should Contain Value
Check Test Case ${TEST NAME}
Check Test Case ${TEST NAME}

Dictionary Should Contain Value With Missing Value
Check Test Case ${TEST NAME} 1
Check Test Case ${TEST NAME} 2

Dictionary Should Not Contain Value
Check Test Case ${TEST NAME}

Dictionary Should Not Contain Value With Existing Value
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal With Keys In Different Order
Check Test Case ${TEST NAME}

Dictionaries Of Different Type Should Be Equal
Check Test Case ${TEST NAME}

Dictionaries Should Equal With First Dictionary Missing Keys
Check Test Case ${TEST NAME}

Dictionaries Should Equal With Second Dictionary Missing Keys
Check Test Case ${TEST NAME}

Dictionaries Should Equal With Both Dictionaries Missing Keys
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal With Different Keys And Own Error Message
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal With Different Keys And Own And Default Error Messages
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal With Different Values
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal With Different Values And Own Error Message
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal With Different Values And Own And Default Error Messages
Check Test Case ${TEST NAME}

Dictionaries Should Equal With Ignored Keys
Check Test Case ${TEST NAME}

Dictionaries Should Equal With Ignored Keys And Missing Key
Check Test Case ${TEST NAME}

Dictionaries Should Equal With Ignored Keys And Missing Key And Own Error Message
Check Test Case ${TEST NAME}

Dictionaries Should Equal with non-list ignored keys
Check Test Case ${TEST NAME}

Dictionaries Should Equal with invalid ignored keys
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary With Missing Keys
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary With Missing Keys And Own Error Message
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary With Missing Keys And Own And Default Error Message
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary With Different Value
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary With Different Value And Own Error Message
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary With Different Value And Own And Default Error Message
Check Test Case ${TEST NAME}

Log Dictionary With Different Log Levels
${tc} = Check Test Case ${TEST NAME}
${expected} = Catenate SEPARATOR=\n
Expand Down Expand Up @@ -206,48 +92,3 @@ Pop From Dictionary With Default

Check invalid dictionary argument errors
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal With Ignore Case
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal Without Ignoring Wrong Case
Check Test Case ${TEST NAME}

Dictionary Should Contain Item With Ignore Case
Check Test Case ${TEST NAME}

Dictionary Should Contain Item Without Ignoring Wrong Case
Check Test Case ${TEST NAME}

Dictionary Should Contain Key With Ignore Case
Check Test Case ${TEST NAME}

Dictionary Should Contain Key Without Ignoring Wrong Case
Check Test Case ${TEST NAME}

Dictionary Should Not Contain Key With Ignore Case Does Contain Key
Check Test Case ${TEST NAME}

Dictionary Should Contain Value With Ignore Case
Check Test Case ${TEST NAME}

Dictionary Should Contain Value Without Ignoring Wrong Case
Check Test Case ${TEST NAME}

Dictionary Should Not Contain Value With Ignore Case Does Contain Value
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary With Ignore Case
Check Test Case ${TEST NAME}

Dictionary Should Contain Sub Dictionary Without Ignoring Wrong Case
Check Test Case ${TEST NAME}

Dictionary Should Contain Value With Ignore Case And Nested List and Dictionary
Check Test Case ${TEST NAME}

Dictionaries Should Be Equal With Keys In Different Order And Ignore Case
Check Test Case ${TEST NAME}

Dictionaries With Equally Named Keys After Normalizing Cannot Ignore Case
Check Test Case ${TEST NAME}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/collections/dictionary_should_contain.robot
Resource atest_resource.robot

*** Test Cases ***
Should contain key
Check Test Case ${TESTNAME}

Should contain key with custom message
Check Test Case ${TESTNAME}

Should contain key with `ignore_case`
Check Test Case ${TESTNAME}

Should not contain key
Check Test Case ${TESTNAME}

Should not contain key with custom message
Check Test Case ${TESTNAME}

Should not contain key with `ignore_case`
Check Test Case ${TESTNAME}

Should contain value
Check Test Case ${TESTNAME}

Should contain value with custom message
Check Test Case ${TESTNAME}

Should contain value with `ignore_case`
Check Test Case ${TESTNAME}

Should not contain value
Check Test Case ${TESTNAME}

Should not contain value with custom message
Check Test Case ${TESTNAME}

Should not contain value with `ignore_case`
Check Test Case ${TESTNAME}

Should contain item
Check Test Case ${TESTNAME}

Should contain item with missing key
Check Test Case ${TESTNAME}

Should contain item with missing key and custom message
Check Test Case ${TESTNAME}

Should contain item with wrong value
Check Test Case ${TESTNAME}

Should contain item with wrong value and custom message
Check Test Case ${TESTNAME}

Should contain item with values looking same but having different types
Check Test Case ${TESTNAME}

Should contain item with `ignore_case`
Check Test Case ${TESTNAME}

Should contain item with `ignore_case=key`
Check Test Case ${TESTNAME}

Should contain item with `ignore_case=value`
Check Test Case ${TESTNAME}

Should contain sub dictionary
Check Test Case ${TESTNAME}

Should contain sub dictionary with missing keys
Check Test Case ${TESTNAME}

Should contain sub dictionary with missing keys and custom error message
Check Test Case ${TESTNAME}

Should contain sub dictionary with missing keys and custom error message containig values
Check Test Case ${TESTNAME}

Should contain sub dictionary with wrong value
Check Test Case ${TESTNAME}

Should contain sub dictionary with wrong value and custom error message
Check Test Case ${TESTNAME}

Should contain sub dictionary with wrong value and custom error message containing values
Check Test Case ${TESTNAME}

Should contain sub dictionary with `ignore_case`
Check Test Case ${TESTNAME}

`ignore_case` when normalized keys have conflict
Check Test Case ${TESTNAME}

`has_key` is not required
Check Test Case ${TESTNAME}
3 changes: 3 additions & 0 deletions atest/robot/standard_libraries/collections/list.robot
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ Lists Should Be Equal With Named Indices As Dictionary With Too Few Values
Lists Should Be Equal Ignore Order
Check Test Case ${TEST NAME}

Ignore Order Is Recursive
Check Test Case ${TEST NAME}

List Should Contain Sub List
Check Test Case ${TEST NAME}

Expand Down
Loading

0 comments on commit 6aec6db

Please sign in to comment.