aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/cases/330_neural.robot
blob: a9a338f9537c7295faf7e4095bc737e44b0a11a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
*** Settings ***
Suite Setup      Neural Setup
Suite Teardown   Neural Teardown
Library         Process
Library         ${TESTDIR}/lib/rspamd.py
Resource        ${TESTDIR}/lib/rspamd.robot
Variables       ${TESTDIR}/lib/vars.py

*** Variables ***
${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
${CONFIG}       ${TESTDIR}/configs/neural.conf
${MESSAGE}      ${TESTDIR}/messages/spam_message.eml
${REDIS_SCOPE}  Suite
${RSPAMD_SCOPE}  Suite

*** Test Cases ***
Train
  Sleep  2s  Wait for redis mess
  FOR    ${INDEX}    IN RANGE    0    10
    ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["SPAM_SYMBOL"]}
    Check Rspamc  ${result}  SPAM_SYMBOL
    ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["HAM_SYMBOL"]}
    Check Rspamc  ${result}  HAM_SYMBOL
  END

Check Neural HAM
  Sleep  2s  Wait for neural to be loaded
  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["HAM_SYMBOL"];groups_enabled=["neural"];symbols_disabled = ["NEURAL_LEARN"]}
  Check Rspamc  ${result}  NEURAL_HAM_SHORT
  Check Rspamc  ${result}  NEURAL_SPAM_SHORT  inverse=1

Check Neural SPAM
  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["SPAM_SYMBOL"];groups_enabled=["neural"];symbols_disabled = ["NEURAL_LEARN"]}
  Check Rspamc  ${result}  NEURAL_SPAM_SHORT
  Check Rspamc  ${result}  NEURAL_HAM_SHORT  inverse=1


Train INVERSE
  FOR    ${INDEX}    IN RANGE    0    10
    ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["SPAM_SYMBOL"]; SPAM_SYMBOL = -5;}
    Check Rspamc  ${result}  SPAM_SYMBOL
    ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["HAM_SYMBOL"]; HAM_SYMBOL = 5;}
    Check Rspamc  ${result}  HAM_SYMBOL
  END

Check Neural HAM INVERSE
  Sleep  2s  Wait for neural to be loaded
  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["HAM_SYMBOL"];groups_enabled=["neural"]}
  Check Rspamc  ${result}  NEURAL_SPAM_SHORT
  Check Rspamc  ${result}  NEURAL_HAM_SHORT  inverse=1

Check Neural SPAM INVERSE
  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["SPAM_SYMBOL"];groups_enabled=["neural"]}
  Check Rspamc  ${result}  NEURAL_HAM_SHORT
  Check Rspamc  ${result}  NEURAL_SPAM_SHORT  inverse=1

*** Keywords ***
Neural Setup
  ${TMPDIR} =    Make Temporary Directory
  Set Suite Variable        ${TMPDIR}
  Run Redis
  Generic Setup

Neural Teardown
  Shutdown Process With Children  ${REDIS_PID}
  Normal Teardown