]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Rework composites test 3544/head
authorAndrew Lewis <nerf@judo.za.org>
Thu, 5 Nov 2020 13:36:54 +0000 (15:36 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Thu, 5 Nov 2020 13:36:54 +0000 (15:36 +0200)
test/functional/cases/109_composites.robot
test/functional/lib/rspamd.robot

index 8da18fe977bb88244d1534e6c44ddd48f7cbe483..baab438a369b46f4b91d4ef4a6a7c594d2a24622 100644 (file)
@@ -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
 
index e310db4b54d7b243b77c05a717f5cf38f9f70825..6487a2e11189a157ceac313e678d6522be86953c 100644 (file)
@@ -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}