File tree 2 files changed +17
-13
lines changed
2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 16
16
17
17
18
18
def process_html_filename (options ) -> None :
19
- num_users = options .num_users
20
- spawn_rate = options .spawn_rate
21
- run_time = options .run_time
22
-
23
19
option_mapping = {
24
- "{u}" : num_users ,
25
- "{r}" : spawn_rate ,
26
- "{t}" : run_time ,
20
+ "{u}" : options . num_users ,
21
+ "{r}" : options . spawn_rate ,
22
+ "{t}" : options . run_time ,
27
23
}
28
-
29
- html_filename = options .html_file
30
-
31
24
for option_term , option_value in option_mapping .items ():
32
- html_filename = html_filename .replace (option_term , str (int (option_value )))
33
-
34
- options .html_file = html_filename
25
+ if option_value is not None :
26
+ options .html_file = options .html_file .replace (option_term , str (int (option_value )))
35
27
36
28
37
29
def render_template_from (file , build_path = DEFAULT_BUILD_PATH , ** kwargs ):
Original file line number Diff line number Diff line change @@ -40,3 +40,15 @@ def test_process_html_filename_no_replacement(self):
40
40
41
41
expected_filename = "static_report.html"
42
42
self .assertEqual (mock_options .html_file , expected_filename )
43
+
44
+ def test_process_html_filename_None_arguments (self ):
45
+ mock_options = MagicMock ()
46
+ mock_options .num_users = 5
47
+ # mock_options.spawn_rate = None
48
+ mock_options .run_time = None
49
+ mock_options .html_file = "report_u{u}_r{r}_t{t}.html"
50
+
51
+ process_html_filename (mock_options )
52
+
53
+ expected_filename = "report_u5_r1_t{t}.html"
54
+ self .assertEqual (mock_options .html_file , expected_filename )
You can’t perform that action at this time.
0 commit comments