commit f5b931b: [Test] Rework composites test
Andrew Lewis
nerf at judo.za.org
Thu Nov 5 15:14:09 UTC 2020
Author: Andrew Lewis
Date: 2020-11-05 15:36:54 +0200
URL: https://github.com/rspamd/rspamd/commit/f5b931b8146548f0ce6bac07734b014885ace29a (refs/pull/3544/head)
[Test] Rework composites test
---
test/functional/cases/109_composites.robot | 50 +++++++++++++++---------------
test/functional/lib/rspamd.robot | 23 ++++++++++++--
2 files changed, 45 insertions(+), 28 deletions(-)
diff --git a/test/functional/cases/109_composites.robot b/test/functional/cases/109_composites.robot
index 8da18fe97..baab438a3 100644
--- a/test/functional/cases/109_composites.robot
+++ b/test/functional/cases/109_composites.robot
@@ -14,31 +14,31 @@ ${RSPAMD_SCOPE} Suite
*** Test Cases ***
Composites - All in One
Scan File ${MESSAGE}
- Expect Symbol With Score EXPRESSIONS 5
- Expect Symbol With Score EXPRESSIONS_B 0
- Expect Symbol With Score POLICY_REMOVE_WEIGHT 5
- Expect Symbol With Score POLICY_REMOVE_WEIGHT_B 0
- Do Not Expect Symbol POLICY_REMOVE_WEIGHT_A
- Expect Symbol With Score POLICY_FORCE_REMOVE 5.00
- Expect Symbol With Score POLICY_FORCE_REMOVE_A 1.00
- Do Not Expect Symbol POLICY_FORCE_REMOVE_B
- Expect Symbol With Score POLICY_LEAVE 5.00
- Do Not Expect Symbol POLICY_LEAVE_A
- Expect Symbol With Score POLICY_LEAVE_B 1.00
- Expect Symbol With Score DEFAULT_POLICY_REMOVE_WEIGHT 5.00
- Expect Symbol With Score DEFAULT_POLICY_REMOVE_WEIGHT_A 0.00
- Expect Symbol With Score DEFAULT_POLICY_REMOVE_WEIGHT_B 0.00
- Expect Symbol With Score DEFAULT_POLICY_REMOVE_SYMBOL 5.00
- Do Not Expect Symbol DEFAULT_POLICY_REMOVE_SYMBOL_A
- Do Not Expect Symbol DEFAULT_POLICY_REMOVE_SYMBOL_B
- Expect Symbol With Score DEFAULT_POLICY_LEAVE 5.00
- Expect Symbol With Score DEFAULT_POLICY_LEAVE_A 1.00
- Expect Symbol With Score DEFAULT_POLICY_LEAVE_B 1.00
- Expect Symbol With Score SYMBOL_GROUPS 5.00
- Expect Symbol With Score POSITIVE_A -1.00
- Expect Symbol With Score ANY_A -1.00
- Expect Symbol With Score NEGATIVE_B 1.00
- Do Not Expect Symbol NEGATIVE_A
+ Expect Symbols With Scores EXPRESSIONS=5
+ ... EXPRESSIONS_B=0
+ ... POLICY_REMOVE_WEIGHT=5
+ ... POLICY_REMOVE_WEIGHT_B=0
+ ... POLICY_FORCE_REMOVE=5.00
+ ... POLICY_FORCE_REMOVE_A=1.00
+ ... POLICY_LEAVE=5.00
+ ... POLICY_LEAVE_B=1.00
+ ... DEFAULT_POLICY_REMOVE_WEIGHT=5.00
+ ... DEFAULT_POLICY_REMOVE_WEIGHT_A=0.00
+ ... DEFAULT_POLICY_REMOVE_WEIGHT_B=0.00
+ ... DEFAULT_POLICY_REMOVE_SYMBOL=5.00
+ ... DEFAULT_POLICY_LEAVE=5.00
+ ... DEFAULT_POLICY_LEAVE_A=1.00
+ ... DEFAULT_POLICY_LEAVE_B=1.00
+ ... SYMBOL_GROUPS=5.00
+ ... POSITIVE_A=-1.00
+ ... ANY_A=-1.00
+ ... NEGATIVE_B=1.00
+ Do Not Expect Symbols DEFAULT_POLICY_REMOVE_SYMBOL_A
+ ... DEFAULT_POLICY_REMOVE_SYMBOL_B
+ ... NEGATIVE_A
+ ... POLICY_REMOVE_WEIGHT_A
+ ... POLICY_FORCE_REMOVE_B
+ ... POLICY_LEAVE_A
Expect Score 50
Expect Required Score To Be Null
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot
index e310db4b5..6487a2e11 100644
--- a/test/functional/lib/rspamd.robot
+++ b/test/functional/lib/rspamd.robot
@@ -46,8 +46,15 @@ Check Rspamc Match String
Do Not Expect Symbol
[Arguments] ${symbol}
- ${passed} = Run Keyword And Return Status Expect Symbol ${symbol}
- Run Keyword If ${passed} Fail Unexpected symbol ${symbol} was found in result
+ Dictionary Should Not Contain Key ${SCAN_RESULT}[symbols] ${symbol}
+ ... msg=Symbol ${symbol} was not expected to be found in result
+
+Do Not Expect Symbols
+ [Arguments] @{symbols}
+ FOR ${symbol} IN @{symbols}
+ Dictionary Should Not Contain Key ${SCAN_RESULT}[symbols] ${symbol}
+ ... msg=Symbol ${symbol} was not expected to be found in result
+ END
Generic Setup
[Arguments] @{vargs} &{kwargs}
@@ -103,10 +110,20 @@ Expect Symbol With Option
Expect Symbol With Score
[Arguments] ${symbol} ${score}
- Expect Symbol ${symbol}
+ Dictionary Should Contain Key ${SCAN_RESULT}[symbols] ${symbol}
+ ... msg=Symbol ${symbol} wasn't found in result
Should Be Equal As Numbers ${SCAN_RESULT}[symbols][${symbol}][score] ${score}
... msg="Symbol ${symbol} has score of ${SCAN_RESULT}[symbols][${symbol}][score] but expected ${score}"
+Expect Symbols With Scores
+ [Arguments] &{symscores}
+ FOR ${key} ${value} IN &{symscores}
+ Dictionary Should Contain Key ${SCAN_RESULT}[symbols] ${key}
+ ... msg=Symbol ${key} wasn't found in result
+ Should Be Equal As Numbers ${SCAN_RESULT}[symbols][${key}][score] ${value}
+ ... msg="Symbol ${key} has score of ${SCAN_RESULT}[symbols][${key}][score] but expected ${value}"
+ END
+
Expect Symbol With Score And Exact Options
[Arguments] ${symbol} ${score} @{options}
Expect Symbol With Exact Options ${symbol} @{options}
More information about the Commits
mailing list