File tree 2 files changed +22
-8
lines changed
2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change 1
1
import json
2
2
3
3
from integration import run_command
4
- from integration .util import cleanup
4
+ from integration .util import cleanup_after_validation
5
5
6
6
7
7
def _parse_response (response ):
@@ -18,13 +18,16 @@ def test_alert_prints_to_stdout_and_filters_result_between_given_date():
18
18
assert record ["createdAt" ].startswith ("2020-05-18" )
19
19
20
20
21
+ def _validate_severity (response ):
22
+ parsed_response = _parse_response (response )
23
+ for record in parsed_response :
24
+ assert record ["severity" ] == "MEDIUM"
25
+
26
+
27
+ @cleanup_after_validation ("./integration/alerts" )
21
28
def test_alert_writes_to_file_and_filters_result_by_severity ():
22
- command = "code42 alerts write-to ./integration/alerts -b 2020-05-18 -e " \
23
- "2020-05-20 --severity MEDIUM"
29
+ command = "code42 alerts write-to ./integration/alerts -b 2020-05-18 -e 2020-05-20 " \
30
+ "--severity MEDIUM"
24
31
return_code , response = run_command (command )
25
32
assert return_code is 0
26
- with cleanup ("./integration/alerts" ) as f :
27
- response = f .read ()
28
- parsed_response = _parse_response (response )
29
- for record in parsed_response :
30
- assert record ["severity" ] == "MEDIUM"
33
+ return _validate_severity
Original file line number Diff line number Diff line change @@ -10,3 +10,14 @@ def __enter__(self):
10
10
11
11
def __exit__ (self , exc_type , exc_val , exc_tb ):
12
12
run_command ("rm -f {}" .format (self .filename ))
13
+
14
+
15
+ def cleanup_after_validation (filename ):
16
+ def wrap (test_function ):
17
+ def wrapper ():
18
+ validate = test_function ()
19
+ with cleanup (filename ) as f :
20
+ response = f .read ()
21
+ validate (response )
22
+ return wrapper
23
+ return wrap
You can’t perform that action at this time.
0 commit comments